mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Fleet Desktop: e2e test for device user page (#4812)
This commit is contained in:
parent
5edd551e2d
commit
694be80de7
2 changed files with 100 additions and 3 deletions
|
|
@ -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");
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
33
cypress/integration/premium/fleetdesktop.spec.ts
Normal file
33
cypress/integration/premium/fleetdesktop.spec.ts
Normal file
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue