Refactor e2e premium observer spec (#3817)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"baseUrl": "https://localhost:8642",
|
||||
"fixturesFolder": false,
|
||||
"experimentalSessionSupport": true,
|
||||
"testFiles": "{all,premium}/**/*.spec.ts",
|
||||
"retries": {
|
||||
"runMode": 1,
|
||||
|
||||
@@ -1,152 +1,185 @@
|
||||
describe("Premium tier - Observer user", () => {
|
||||
beforeEach(() => {
|
||||
before(() => {
|
||||
Cypress.session.clearAllSavedSessions();
|
||||
cy.setup();
|
||||
cy.login();
|
||||
cy.loginWithCySession();
|
||||
cy.seedPremium();
|
||||
cy.seedQueries();
|
||||
cy.seedPolicies("apples");
|
||||
cy.addDockerHost("apples");
|
||||
cy.logout();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
after(() => {
|
||||
cy.logout();
|
||||
cy.stopDockerHost();
|
||||
});
|
||||
|
||||
it("Can perform the appropriate basic global observer actions", () => {
|
||||
cy.login("oliver@organization.com", "user123#");
|
||||
// Host manage page: Can see team column
|
||||
cy.visit("/hosts/manage");
|
||||
|
||||
// Ensure page is loaded
|
||||
cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting
|
||||
cy.contains("All hosts");
|
||||
|
||||
// Not see the "Manage enroll secret” or "Generate installer" button
|
||||
cy.contains("button", /manage enroll secret/i).should("not.exist");
|
||||
cy.contains("button", /generate installer/i).should("not.exist");
|
||||
|
||||
cy.get("thead").within(() => {
|
||||
cy.findByText(/team/i).should("exist");
|
||||
describe("Global observer", () => {
|
||||
beforeEach(() => {
|
||||
cy.loginWithCySession("oliver@organization.com", "user123#");
|
||||
});
|
||||
|
||||
// Host details page: Can see team on host
|
||||
cy.get("tbody").within(() => {
|
||||
// Test host text varies
|
||||
cy.findByRole("button").click();
|
||||
});
|
||||
|
||||
cy.wait(2000); // eslint-disable-line cypress/no-unnecessary-waiting
|
||||
cy.findByText("Team").should("exist");
|
||||
cy.contains("button", /transfer/i).should("not.exist");
|
||||
cy.contains("button", /delete/i).should("not.exist");
|
||||
cy.contains("button", /query/i).click();
|
||||
cy.contains("button", /create custom query/i).should("not.exist");
|
||||
cy.get(".modal__ex").click();
|
||||
|
||||
// See and not select operating system
|
||||
// TODO
|
||||
|
||||
// TODO - Fix tests according to improved query experience - MP
|
||||
// Query pages: Can see team in select targets dropdown
|
||||
// cy.visit("/queries/manage");
|
||||
|
||||
// cy.findByText(/detect presence/i).click();
|
||||
|
||||
// cy.findByRole("button", { name: /run/i }).click();
|
||||
|
||||
// cy.get(".target-select").within(() => {
|
||||
// cy.findByText(/Label name, host name, IP address, etc./i).click();
|
||||
// cy.findByText(/teams/i).should("exist");
|
||||
// });
|
||||
|
||||
// On the policies manage page, they should…
|
||||
cy.contains("a", "Policies").click();
|
||||
// Not see the "Manage automations" button
|
||||
cy.findByRole("button", { name: /manage automations/i }).should(
|
||||
"not.exist"
|
||||
);
|
||||
|
||||
// Cannot see and select the "Add a policy", "delete", and "edit" policy
|
||||
cy.findByRole("button", { name: /add a policy/i }).should("not.exist");
|
||||
|
||||
// No global policies seeded, switch to team apples to ensure cannot create, delete, edit
|
||||
cy.findByText(/ask yes or no questions/i).should("exist");
|
||||
cy.findByText(/all teams/i).click();
|
||||
cy.findByText(/apples/i).click();
|
||||
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
|
||||
|
||||
// Not see the "Add a policy", "delete", "save", "run" policy
|
||||
cy.findByRole("button", { name: /add a policy/i }).should("not.exist");
|
||||
|
||||
cy.get("tbody").within(() => {
|
||||
cy.get("tr")
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.get(".fleet-checkbox__input").should("not.exist");
|
||||
describe("Manage hosts page", () => {
|
||||
beforeEach(() => cy.visit("/hosts/manage"));
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
// Ensure page is loaded with teams dropdown
|
||||
cy.getAttached(".Select-value-label").contains("All teams");
|
||||
// Not see the "Manage enroll secret” or "Generate installer" button
|
||||
cy.contains("button", /manage enroll secret/i).should("not.exist");
|
||||
cy.contains("button", /generate installer/i).should("not.exist");
|
||||
// Hosts table includes teams column
|
||||
cy.getAttached("thead").within(() => {
|
||||
cy.findByText(/team/i).should("exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
cy.findByText(/filevault enabled/i).click();
|
||||
cy.getAttached(".policy-form__wrapper").within(() => {
|
||||
cy.findByRole("button", { name: /run/i }).should("not.exist");
|
||||
cy.findByRole("button", { name: /save/i }).should("not.exist");
|
||||
describe("Host details page", () => {
|
||||
beforeEach(() => cy.visit("/hosts/manage"));
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
// Navigate to host details page for first host
|
||||
cy.getAttached(".hostname__cell").first().click();
|
||||
|
||||
// Click query button and confirm observer cannot create custom query
|
||||
cy.getAttached(".host-details__query-button").click();
|
||||
cy.contains("button", /create custom query/i).should("not.exist");
|
||||
cy.getAttached(".modal__ex").click();
|
||||
|
||||
// Confirm other actions are not available to observer
|
||||
cy.getAttached(".host-details__action-button-container").within(() => {
|
||||
cy.contains("button", /transfer/i).should("not.exist");
|
||||
cy.contains("button", /delete/i).should("not.exist");
|
||||
});
|
||||
|
||||
// Confirm additional host details for observer
|
||||
cy.getAttached(".info-flex").within(() => {
|
||||
// Team is shown for host
|
||||
cy.findByText(/apples/i).should("exist");
|
||||
// OS is shown for host
|
||||
cy.findByText(/ubuntu/i).should("exist");
|
||||
// Observer cannot create a new OS policy
|
||||
cy.findByRole("button").should("not.exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("Query pages", () => {
|
||||
beforeEach(() => cy.visit("/queries/manage"));
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
// Navigate to query detail page for first query on manage queries page
|
||||
cy.getAttached("tbody").within(() => {
|
||||
cy.getAttached("tr")
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.contains(".fleet-checkbox__input").should("not.exist");
|
||||
cy.findByText(/detect presence/i).click();
|
||||
});
|
||||
});
|
||||
cy.getAttached(".query-form__button-wrap").within(() => {
|
||||
cy.findByRole("button", { name: /run/i }).click();
|
||||
});
|
||||
cy.contains("h3", /teams/i).should("exist");
|
||||
cy.contains(".selector-name", /apples/i).should("exist");
|
||||
});
|
||||
});
|
||||
describe("Policies pages", () => {
|
||||
beforeEach(() => cy.visit("/policies/manage"));
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
// No global policies seeded, placeholder displayed
|
||||
cy.findByText(/ask yes or no questions/i).should("exist");
|
||||
cy.findByText(/all your hosts/i).should("exist");
|
||||
|
||||
// Cannot see "Manage automations" button
|
||||
cy.findByRole("button", { name: /manage automations/i }).should(
|
||||
"not.exist"
|
||||
);
|
||||
// Cannot see "Add a policy" button
|
||||
cy.findByRole("button", { name: /add a policy/i }).should("not.exist");
|
||||
|
||||
// Switch to team policies
|
||||
cy.getAttached(".Select-control").within(() => {
|
||||
cy.findByText(/all teams/i).click();
|
||||
});
|
||||
cy.getAttached(".Select-menu")
|
||||
.contains(/apples/i)
|
||||
.click();
|
||||
cy.findByRole("button", { name: /add a policy/i }).should("not.exist");
|
||||
|
||||
cy.getAttached("tbody").within(() => {
|
||||
cy.getAttached("tr")
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.contains(".fleet-checkbox__input").should("not.exist");
|
||||
cy.findByText(/filevault enabled/i).click();
|
||||
});
|
||||
});
|
||||
cy.getAttached(".policy-form__wrapper").within(() => {
|
||||
cy.findByRole("button", { name: /run/i }).should("not.exist");
|
||||
cy.findByRole("button", { name: /save/i }).should("not.exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Pseudo code for team observer only
|
||||
// TODO: Rebuild this test according to new manual QA
|
||||
it("Can perform the appropriate basic team observer only actions", () => {
|
||||
cy.login("toni@organization.com", "user123#");
|
||||
cy.visit("/hosts/manage");
|
||||
cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting
|
||||
|
||||
// Ensure the page is loaded and teams are visible
|
||||
cy.findByText("Hosts").should("exist");
|
||||
cy.contains(".table-container .data-table__table th", "Team").should(
|
||||
"be.visible"
|
||||
);
|
||||
|
||||
// Nav restrictions
|
||||
cy.findByText(/settings/i).should("not.exist");
|
||||
cy.findByText(/schedule/i).should("not.exist");
|
||||
cy.visit("/settings/organization");
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
cy.visit("/packs/manage");
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
cy.visit("/schedule/manage");
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
|
||||
// On the policies manage page, they should…
|
||||
cy.visit("/policies/manage");
|
||||
|
||||
// Not see and select the "Add a policy", "delete", and "edit" policy
|
||||
cy.findByRole("button", { name: /add a policy/i }).should("not.exist");
|
||||
cy.findByText(/all teams/i).should("not.exist");
|
||||
cy.getAttached("tbody").within(() => {
|
||||
cy.get("tr")
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.get(".fleet-checkbox__input").should("not.exist");
|
||||
describe("Team observer", () => {
|
||||
beforeEach(() => {
|
||||
cy.loginWithCySession("toni@organization.com", "user123#");
|
||||
});
|
||||
describe("Nav restrictions", () => {
|
||||
it("should restrict navigation according to role-based access controls", () => {
|
||||
cy.findByText(/settings/i).should("not.exist");
|
||||
cy.findByText(/schedule/i).should("not.exist");
|
||||
cy.visit("/settings/organization");
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
cy.visit("/packs/manage");
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
cy.visit("/schedule/manage");
|
||||
cy.findByText(/you do not have permissions/i).should("exist");
|
||||
});
|
||||
});
|
||||
describe("Manage hosts page", () => {
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
cy.visit("/hosts/manage");
|
||||
// Hosts table includes teams column
|
||||
cy.getAttached(".data-table__table th")
|
||||
.contains("Team")
|
||||
.should("be.visible");
|
||||
});
|
||||
});
|
||||
describe("Manage policies page", () => {
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
cy.visit("/policies/manage");
|
||||
cy.findByRole("button", { name: /add a policy/i }).should("not.exist");
|
||||
cy.findByText(/all teams/i).should("not.exist");
|
||||
});
|
||||
});
|
||||
describe("Policy detail page", () => {
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
cy.visit("/policies/manage");
|
||||
// Navigate to policy detail page for first policy in manage policies table
|
||||
cy.getAttached("tbody").within(() => {
|
||||
cy.getAttached("tr")
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.contains(".fleet-checkbox__input").should("not.exist");
|
||||
cy.findByText(/filevault enabled/i).click();
|
||||
});
|
||||
});
|
||||
cy.findByText(/filevault enabled/i).click();
|
||||
cy.getAttached(".policy-form__wrapper").within(() => {
|
||||
cy.findByRole("button", { name: /run/i }).should("not.exist");
|
||||
cy.findByRole("button", { name: /save/i }).should("not.exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
cy.getAttached(".policy-form__wrapper").within(() => {
|
||||
cy.findByRole("button", { name: /run/i }).should("not.exist");
|
||||
cy.findByRole("button", { name: /save/i }).should("not.exist");
|
||||
});
|
||||
|
||||
// On the Profile page, they should…
|
||||
// See Global in the Team section and Observer in the Role section
|
||||
cy.visit("/profile");
|
||||
|
||||
cy.getAttached(".user-settings__additional").within(() => {
|
||||
cy.findByText(/team/i)
|
||||
.next()
|
||||
.contains(/apples/i);
|
||||
cy.findByText("Role")
|
||||
.next()
|
||||
.contains(/observer/i);
|
||||
describe("User profile page", () => {
|
||||
it("should render elements according to role-based access controls", () => {
|
||||
cy.visit("/profile");
|
||||
cy.getAttached(".user-settings__additional").within(() => {
|
||||
cy.findByText(/team/i)
|
||||
.next()
|
||||
.contains(/apples/i);
|
||||
cy.findByText("Role")
|
||||
.next()
|
||||
.contains(/observer/i);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,6 +46,18 @@ Cypress.Commands.add("login", (email, password) => {
|
||||
);
|
||||
});
|
||||
|
||||
Cypress.Commands.add("loginWithCySession", (email, password) => {
|
||||
email ||= "admin@example.com";
|
||||
password ||= "user123#";
|
||||
cy.session([email, password], () => {
|
||||
cy.request("POST", "/api/v1/fleet/login", { email, password }).then(
|
||||
(resp) => {
|
||||
window.localStorage.setItem("FLEET::auth_token", resp.body.token);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add("logout", () => {
|
||||
cy.request({
|
||||
url: "/api/v1/fleet/logout",
|
||||
|
||||
Reference in New Issue
Block a user