Add e2e tests for export hosts feature (#5895)

This commit is contained in:
Luke Heath 2022-05-25 10:29:50 -05:00 committed by GitHub
parent e3f1dda641
commit 16209b4ec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -29,7 +29,6 @@ describe("Hosts flow", () => {
cy.visit("/hosts/manage");
cy.getAttached(".manage-hosts").within(() => {
// cy.getAttached(".manage-hosts__export-btn").click(); // Feature pushed back from 4.13 release
cy.contains("button", /add hosts/i).click();
});
cy.getAttached(".react-tabs").within(() => {
@ -71,6 +70,20 @@ describe("Hosts flow", () => {
});
}
});
it(`exports hosts to CSV`, () => {
cy.visit("/hosts/manage");
cy.getAttached(".manage-hosts").within(() => {
cy.getAttached(".manage-hosts__export-btn").click();
});
if (Cypress.platform !== "win32") {
// windows has issues with downloads location
const formattedTime = format(new Date(), "yyyy-MM-dd");
const filename = `Hosts ${formattedTime}.csv`;
cy.readFile(path.join(Cypress.config("downloadsFolder"), filename), {
timeout: 5000,
});
}
});
it(`hides and shows "Used by" column`, () => {
cy.visit("/hosts/manage");
cy.getAttached("thead").within(() =>

View file

@ -1281,7 +1281,7 @@ const ManageHostsPage = ({
evt.preventDefault();
const hiddenColumnsStorage = localStorage.getItem("hostHiddenColumns");
let currentHiddenColumns;
let currentHiddenColumns = [];
let visibleColumns;
if (hiddenColumnsStorage) {
currentHiddenColumns = JSON.parse(hiddenColumnsStorage);