Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
EVG-20815: Enable test isolation for project_settings/notifications a…
Browse files Browse the repository at this point in the history
…nd resolve flake (#2088)
  • Loading branch information
SupaJoon committed Nov 2, 2023
1 parent 6b92620 commit cd3e630
Show file tree
Hide file tree
Showing 8 changed files with 946 additions and 925 deletions.
63 changes: 63 additions & 0 deletions cypress/integration/projectSettings/access.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
getAccessRoute,
project,
projectUseRepoEnabled,
saveButtonEnabled,
} from "./constants";
import { clickSave } from "../../utils";

describe("Access page", () => {
const origin = getAccessRoute(projectUseRepoEnabled);
beforeEach(() => {
cy.visit(origin);
saveButtonEnabled(false);
cy.dataCy("default-to-repo-button")
.should("be.visible")
.should("be.enabled")
.should("not.have.attr", "aria-disabled", "true");
});

it("Changing settings and clicking the save button produces a success toast and the changes are persisted", () => {
cy.contains("label", "Unrestricted").click();
cy.getInputByLabel("Unrestricted").should("be.checked");
// Input and save username
cy.contains("Add Username").click();
cy.getInputByLabel("Username").as("usernameInput");
cy.get("@usernameInput").type("admin");
cy.get("@usernameInput").should("have.value", "admin").should("be.visible");
clickSave();
cy.validateToast("success", "Successfully updated project");
// Assert persistence
cy.reload();
cy.get("@usernameInput").should("have.value", "admin").should("be.visible");
// Delete a username
cy.dataCy("delete-item-button").should("be.visible").click();
cy.get("@usernameInput").should("not.exist");
clickSave();
cy.validateToast("success", "Successfully updated project");
// Assert persistence
cy.reload();
cy.get("@usernameInput").should("not.exist");
});

it("Clicking on 'Default to Repo on Page' selects the 'Default to repo (unrestricted)' radio box and produces a success banner", () => {
cy.dataCy("default-to-repo-button").click();
cy.dataCy("default-to-repo-modal").contains("Confirm").click();
cy.validateToast("success", "Successfully defaulted page to repo");
cy.getInputByLabel("Default to repo (unrestricted)").should("be.checked");
});

it("Submitting an invalid admin username produces an error toast", () => {
cy.visit(getAccessRoute(project));
cy.contains("Add Username").click();
cy.get("[aria-label='Username'")
.should("have.length", 4)
.first()
.type("mongodb_user");
clickSave();
cy.validateToast(
"error",
"There was an error saving the project: error updating project admin roles: no admin role for project 'spruce' found"
);
});
});
40 changes: 40 additions & 0 deletions cypress/integration/projectSettings/attaching_to_repo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { getGeneralRoute, project } from "./constants";
import { clickSave } from "../../utils";

describe("Attaching Spruce to a repo", () => {
const origin = getGeneralRoute(project);

beforeEach(() => {
cy.visit(origin);
});

it("Saves and attaches new repo and shows warnings on the Github/Commit Queue page", () => {
cy.dataCy("repo-input").as("repoInput").clear();
cy.get("@repoInput").type("evergreen");
cy.dataCy("attach-repo-button").should(
"have.attr",
"aria-disabled",
"true"
);
clickSave();
cy.validateToast("success", "Successfully updated project");
cy.dataCy("attach-repo-button").click();
cy.dataCy("attach-repo-modal").contains("button", "Attach").click();
cy.validateToast("success", "Successfully attached to repo");
cy.dataCy("navitem-github-commitqueue").click();
cy.dataCy("pr-testing-enabled-radio-box")
.prev()
.dataCy("warning-banner")
.should("exist");
cy.dataCy("manual-pr-testing-enabled-radio-box")
.prev()
.dataCy("warning-banner")
.should("exist");
cy.dataCy("github-checks-enabled-radio-box").prev().should("not.exist");
cy.dataCy("cq-card").dataCy("warning-banner").should("exist");
cy.dataCy("cq-enabled-radio-box").within(($el) => {
cy.wrap($el).getInputByLabel("Enabled").parent().click();
});
cy.dataCy("cq-card").dataCy("error-banner").should("exist");
});
});
Loading

0 comments on commit cd3e630

Please sign in to comment.