diff --git a/cypress/integration/all/app/hosts.spec.ts b/cypress/integration/all/app/hosts.spec.ts index 7fd6d66651..ac62395919 100644 --- a/cypress/integration/all/app/hosts.spec.ts +++ b/cypress/integration/all/app/hosts.spec.ts @@ -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(() => diff --git a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx index e76582fd44..a82efae05c 100644 --- a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx +++ b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx @@ -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);