From 694be80de7cacab4e3bef12472d7cf139c717b30 Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Tue, 12 Jul 2022 13:24:08 -0400 Subject: [PATCH] Fleet Desktop: e2e test for device user page (#4812) --- .../integration/all/app/fleetdesktop.spec.ts | 70 ++++++++++++++++++- .../integration/premium/fleetdesktop.spec.ts | 33 +++++++++ 2 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 cypress/integration/premium/fleetdesktop.spec.ts diff --git a/cypress/integration/all/app/fleetdesktop.spec.ts b/cypress/integration/all/app/fleetdesktop.spec.ts index 8fbbe1b915..5790d58f9f 100644 --- a/cypress/integration/all/app/fleetdesktop.spec.ts +++ b/cypress/integration/all/app/fleetdesktop.spec.ts @@ -15,10 +15,74 @@ describe("Fleet Desktop", () => { describe("Fleet Desktop device user page", () => { beforeEach(() => { Cypress.session.clearAllSavedSessions(); - }); - it("serves device user page if url includes valid token", () => { cy.visit(`/device/${fakeDeviceToken}`); - cy.findByText(/my device/i).should("exist"); }); + it("renders the device user information and info modal", () => { + cy.findByText(/my device/i).should("exist"); + cy.getAttached(".status--online").should("exist"); + cy.getAttached(".info-flex").within(() => { + cy.findByText(/operating system/i) + .next() + .contains(/ubuntu 20/i); + }); + cy.getAttached(".info-grid").within(() => { + cy.findByText(/private ip address/i) + .next() + .findByText(/---/i) + .should("not.exist"); + }); + cy.getAttached(".device-user__action-button-container").within(() => { + cy.getAttached('img[alt="Host info icon"]').click(); + }); + cy.getAttached(".device-user-info__modal").within(() => { + cy.getAttached(".device-user-info__btn").click(); + }); + }); + it("renders and searches the host's software", () => { + cy.getAttached(".react-tabs__tab-list").within(() => { + cy.findByText(/software/i).click(); + }); + let initialCount = 0; + cy.getAttached(".section--software").within(() => { + cy.getAttached(".table-container__results-count") + .invoke("text") + .then((text) => { + const fullText = text; + const pattern = /[0-9]+/g; + const newCount = fullText.match(pattern); + initialCount = parseInt(newCount[0], 10); + expect(initialCount).to.be.at.least(1); + }); + cy.findByPlaceholderText(/search software/i).type("lib"); + // Ensures search completes + cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting + cy.getAttached(".table-container__results-count") + .invoke("text") + .then((text) => { + const fullText = text; + const pattern = /[0-9]+/g; + const newCount = fullText.match(pattern); + const searchCount = parseInt(newCount[0], 10); + expect(searchCount).to.be.lessThan(initialCount); + }); + }); + }); + it( + "refetches host vitals", + { + retries: { + runMode: 2, + }, + defaultCommandTimeout: 15000, + }, + () => { + cy.getAttached(".hostname-container").within(() => { + cy.contains("button", /refetch/i).click(); + cy.findByText(/fetching/i).should("exist"); + cy.contains("button", /refetch/i).should("exist"); + cy.findByText(/less than a minute/i).should("exist"); + }); + } + ); }); }); diff --git a/cypress/integration/premium/fleetdesktop.spec.ts b/cypress/integration/premium/fleetdesktop.spec.ts new file mode 100644 index 0000000000..0e1695d90c --- /dev/null +++ b/cypress/integration/premium/fleetdesktop.spec.ts @@ -0,0 +1,33 @@ +const fakeDeviceToken = "phAK3d3vIC37OK3n"; + +describe("Fleet Desktop", () => { + before(() => { + Cypress.session.clearAllSavedSessions(); + cy.setup(); + cy.loginWithCySession(); + cy.addDockerHost(); + cy.setDesktopToken(1, fakeDeviceToken); + cy.viewport(1200, 660); + cy.seedPolicies(); + }); + after(() => { + cy.stopDockerHost(); + }); + describe("Fleet Desktop device user page", () => { + beforeEach(() => { + Cypress.session.clearAllSavedSessions(); + cy.visit(`/device/${fakeDeviceToken}`); + }); + it("renders policies and provides instructions for self-remediation", () => { + cy.getAttached(".react-tabs__tab-list").within(() => { + cy.findByText(/policies/i).click(); + }); + cy.getAttached(".section--policies").within(() => { + cy.findByText(/is filevault enabled/i).click(); + }); + cy.getAttached(".policy-details-modal").within(() => { + cy.findByText(/click turn on filevault/i).should("exist"); + }); + }); + }); +});