E2e test stability: Fix free observer detached dom flakiness, remove waits on visit profile RBAC (#3659)

This commit is contained in:
RachelElysia 2022-01-13 13:01:14 -05:00 committed by GitHub
parent a85e47b28b
commit 0f1bb337bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 42 deletions

View file

@ -39,11 +39,14 @@ describe("Reset user sessions flow", () => {
cy.login();
cy.visit("/profile");
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
cy.findByRole("button", { name: /get api token/i }).click();
cy.findByText(/reveal token/i).click();
cy.get(".user-settings__secret-input").within(() => {
cy.getAttached(".user-settings__additional").within(() => {
cy.findByRole("button", { name: /get api token/i }).click();
});
cy.getAttached(".modal__content").within(() => {
cy.findByText(/reveal token/i).click();
});
cy.getAttached(".user-settings__secret-input").within(() => {
cy.get("input").invoke("val").as("token2");
});

View file

@ -160,9 +160,11 @@ describe(
// On the Profile page, they should…
// See Admin in Role section, and no Team section
cy.visit("/profile");
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
cy.findByText(/teams/i).should("not.exist");
cy.findByText("Role").next().contains(/admin/i);
cy.getAttached(".user-settings__additional").within(() => {
cy.findByText(/teams/i).should("not.exist");
cy.findByText("Role").next().contains(/admin/i);
});
});
}
);

View file

@ -180,10 +180,13 @@ describe(
// On the Profile page, they should…
// See Maintainer in Role section, and no Team section
cy.visit("/profile");
cy.findByText(/teams/i).should("not.exist");
cy.findByText("Role")
.next()
.contains(/maintainer/i);
cy.getAttached(".user-settings__additional").within(() => {
cy.findByText(/teams/i).should("not.exist");
cy.findByText("Role")
.next()
.contains(/maintainer/i);
});
});
}
);

View file

@ -60,7 +60,7 @@ describe("Free tier - Observer user", () => {
// Queries pages: Observer can or cannot run UI
cy.visit("/queries/manage");
cy.get("thead").within(() => {
cy.getAttached("thead").within(() => {
cy.findByText(/observer can run/i).should("not.exist");
});
@ -85,14 +85,15 @@ describe("Free tier - Observer user", () => {
// 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.getAttached("tbody").within(() => {
cy.get("tr")
.first()
.within(() => {
cy.get(".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");
@ -102,10 +103,11 @@ describe("Free tier - Observer user", () => {
// See Observer in Role section, and no Team section
cy.visit("/profile");
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
cy.findByText(/teams/i).should("not.exist");
cy.findByText("Role")
.next()
.contains(/observer/i);
cy.getAttached(".user-settings__additional").within(() => {
cy.findByText(/teams/i).should("not.exist");
cy.findByText("Role")
.next()
.contains(/observer/i);
});
});
});

View file

@ -273,12 +273,13 @@ describe(
// On the Profile page, they should…
// See Global in the Team section and Admin in the Role section
cy.visit("/profile");
cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting
cy.findByText(/team/i)
.next()
.contains(/global/i);
cy.findByText("Role").next().contains(/admin/i);
cy.getAttached(".user-settings__additional").within(() => {
cy.findByText(/team/i)
.next()
.contains(/global/i);
cy.findByText("Role").next().contains(/admin/i);
});
}
);
}

View file

@ -121,12 +121,15 @@ describe(
// On the Profile page, they should…
// See Global in the Team section and Maintainer in the Role section
cy.visit("/profile");
cy.findByText(/team/i)
.next()
.contains(/global/i);
cy.findByText("Role")
.next()
.contains(/maintainer/i);
cy.getAttached(".user-settings__additional").within(() => {
cy.findByText(/team/i)
.next()
.contains(/global/i);
cy.findByText("Role")
.next()
.contains(/maintainer/i);
});
});
}
);

View file

@ -139,11 +139,14 @@ describe("Premium tier - Observer user", () => {
// On the Profile page, they should…
// See Global in the Team section and Observer in the Role section
cy.visit("/profile");
cy.findByText(/team/i)
.next()
.contains(/apples/i);
cy.findByText("Role")
.next()
.contains(/observer/i);
cy.getAttached(".user-settings__additional").within(() => {
cy.findByText(/team/i)
.next()
.contains(/apples/i);
cy.findByText("Role")
.next()
.contains(/observer/i);
});
});
});

View file

@ -265,12 +265,15 @@ describe(
// On the Profile page, they should…
// See 2 Teams in the Team section and Various in the Role section
cy.visit("/profile");
cy.findByText("Teams")
.next()
.contains(/2 teams/i);
cy.findByText("Role")
.next()
.contains(/various/i);
cy.getAttached(".user-settings__additional").within(() => {
cy.findByText("Teams")
.next()
.contains(/2 teams/i);
cy.findByText("Role")
.next()
.contains(/various/i);
});
});
}
);