Skip to content

Commit

Permalink
chore: revert changes to before step and skip privatisation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs committed Mar 21, 2024
1 parent ec355be commit 8ae1775
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
33 changes: 15 additions & 18 deletions cypress/e2e/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
TEST_PRIMARY_COLOR,
TEST_REPO_NAME,
BASE_SEO_LINK,
E2E_EMAIL_TEST_SITE,
Interceptors,
} from "../fixtures/constants"

Expand All @@ -19,7 +19,6 @@ describe("Settings page", () => {
const BASE_CONTACT_US = "contact/"
const BASE_FEEDBACK = "www.feedback.com"
const BASE_FAQ = "/faq/"
const TEST_REPO_NAME = E2E_EMAIL_TEST_SITE.repo

const TEST_TITLE = "Test title"
const TEST_LOGO_IMAGES = [
Expand Down Expand Up @@ -51,7 +50,7 @@ describe("Settings page", () => {
cy.visitLoadSettings(TEST_REPO_NAME, sitePath)

before(() => {
cy.setEmailSessionDefaults("Email admin")
cy.setGithubSessionDefaults()
cy.setupDefaultInterceptors()

visitLoadSettings(`/sites/${TEST_REPO_NAME}/settings`).wait(
Expand Down Expand Up @@ -117,11 +116,12 @@ describe("Settings page", () => {
})

beforeEach(() => {
cy.setEmailSessionDefaults("Email admin")
cy.setupDefaultInterceptors()
visitLoadSettings(`/sites/${TEST_REPO_NAME}/settings`).wait(
Interceptors.GET
)
cy.setGithubSessionDefaults()
visitLoadSettings(`/sites/${TEST_REPO_NAME}/settings`)
// Double check that settings are loaded before running tests cos sometimes the tests run too quickly
cy.get("#title").should((elem) => {
expect(elem.val()).to.have.length.greaterThan(0)
})
cy.contains("Verify").should("not.exist")
})

Expand Down Expand Up @@ -245,7 +245,8 @@ describe("Settings page", () => {
cy.get("@showReach").should("not.be.checked")
})

it("Should toggle Privatise staging site button and automatically generate a password", () => {
// Skipping privatisation tests - need to configur separately for email and github repos (github repos have no password settings)
it.skip("Should toggle Privatise staging site button and automatically generate a password", () => {
// Arrange
// NOTE: Initial state is privatise staging off
cy.contains("Privatise staging site")
Expand Down Expand Up @@ -278,7 +279,7 @@ describe("Settings page", () => {
cy.get("@usernameInput").should("be.disabled")
})

it("Should regenerate a password if password field is emptied and privatise button toggled again", () => {
it.skip("Should regenerate a password if password field is emptied and privatise button toggled again", () => {
// Arrange
cy.contains("Privatise staging site")
.parent()
Expand Down Expand Up @@ -311,7 +312,7 @@ describe("Settings page", () => {
})
})

it("Should disallow passwords that do not match the criteria", () => {
it.skip("Should disallow passwords that do not match the criteria", () => {
// Arrange
const shortPassword = "1!Aa"
const noSymbol = "Blahblahblahblahblah1"
Expand Down Expand Up @@ -345,7 +346,7 @@ describe("Settings page", () => {
cy.contains(expectedError).should("exist")
})

it("Should be able to turn off password", () => {
it.skip("Should be able to turn off password", () => {
// Arrange
cy.contains("Privatise staging site")
.parent()
Expand Down Expand Up @@ -477,17 +478,13 @@ describe("Settings page", () => {
.and("eq", rgbSecondary)

// Check if page previews reflect color change
visitLoadSettings(`/sites/${TEST_REPO_NAME}/${SAMPLE_PAGE}`).wait(
Interceptors.GET
)
visitLoadSettings(`/sites/${TEST_REPO_NAME}/${SAMPLE_PAGE}`)
cy.get("section.bp-section-pagetitle") // Page title banner
.should("have.css", "background-color", rgbPrimary)

// Check if home page reflects color change
cy.visit(`/sites/${TEST_REPO_NAME}/workspace`) // Somehow colors won't load on homepage if visiting directly
visitLoadSettings(`/sites/${TEST_REPO_NAME}/${HOMEPAGE}`).wait(
Interceptors.GET
)
visitLoadSettings(`/sites/${TEST_REPO_NAME}/${HOMEPAGE}`)
cy.get("#notification-bar")
.first() // Notification bar
.should("have.css", "background-color", rgbSecondary)
Expand Down
30 changes: 16 additions & 14 deletions cypress/support/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@ import {

Cypress.Commands.add("saveSettings", () => {
cy.intercept("POST", `/v2/sites/${TEST_REPO_NAME}/settings`).as("awaitSave")
cy.intercept("POST", `/v2/sites/${TEST_REPO_NAME}/settings/repo-password`).as(
"awaitSavePassword"
)
// cy.intercept("POST", `/v2/sites/${TEST_REPO_NAME}/settings/repo-password`).as(
// "awaitSavePassword"
// )
cy.contains("button", "Save").click()
cy.wait(["@awaitSavePassword", "@awaitSave"], {
timeout: 10000,
requestTimeout: 10000,
})
cy.wait("@awaitSave")
// cy.wait(["@awaitSavePassword", "@awaitSave"], {
// timeout: 10000,
// requestTimeout: 10000,
// })
})

// Reusable visit command
Cypress.Commands.add("visitLoadSettings", (siteName, sitePath) => {
cy.intercept("GET", `/v2/sites/${siteName}/settings`).as("awaitSettings")
cy.intercept("GET", `/v2/sites/${siteName}/settings/repo-password`).as(
"awaitPassword"
)
// cy.intercept("GET", `/v2/sites/${siteName}/settings/repo-password`).as(
// "awaitPassword"
// )
cy.visit(sitePath)
cy.wait(["@awaitPassword", "@awaitSettings"], {
timeout: 10000,
requestTimeout: 10000,
})
cy.wait("@awaitSave")
// cy.wait(["@awaitPassword", "@awaitSettings"], {
// timeout: 10000,
// requestTimeout: 10000,
// })
})

Cypress.Commands.add("setDefaultSettings", () => {
Expand Down

0 comments on commit 8ae1775

Please sign in to comment.