From 11eb7a514e1896e278a823fdd742148d2d8d5716 Mon Sep 17 00:00:00 2001 From: seaerchin Date: Mon, 29 Jan 2024 12:46:32 +0800 Subject: [PATCH] refactor(cypress): delete replaced spec --- cypress/e2e/editPage.spec.ts | 147 ----------------------------------- 1 file changed, 147 deletions(-) diff --git a/cypress/e2e/editPage.spec.ts b/cypress/e2e/editPage.spec.ts index 9ae92dbbe..cda6539a5 100644 --- a/cypress/e2e/editPage.spec.ts +++ b/cypress/e2e/editPage.spec.ts @@ -23,153 +23,6 @@ describe("editPage.spec", () => { cy.setGithubSessionDefaults() }) - describe("Edit collection page", () => { - const TEST_FOLDER_TITLE = "Test Edit Collection Category" - const TEST_FOLDER_TITLE_SLUGIFIED = slugifyCategory(TEST_FOLDER_TITLE) - - const TEST_PAGE_TITLE = "Test Collection Page" - const TEST_PAGE_FILENAME = titleToPageFileName(TEST_PAGE_TITLE) - const TEST_PAGE_TITLE_ENCODED = encodeURIComponent(TEST_PAGE_FILENAME) - - const TEST_PAGE_CONTENT = "lorem ipsum" - - const DEFAULT_IMAGE_TITLE = "isomer-logo.svg" - - const ADDED_FILE_TITLE = "singapore-pages.pdf" - - const LINK_TITLE = "link" - const LINK_URL = "https://www.google.com" - - before(() => { - cy.setGithubSessionDefaults() - - // Set up test resource categories - // NOTE: We need to repeat the interceptor here as - // cypress resolves by type before nesting level. - // Hence, the alias here will not be resolved as the `before` hook - // will be resolved before the outer `beforeEach` - cy.setupDefaultInterceptors() - - // Set up test collection - cy.visit(`/sites/${TEST_REPO_NAME}/workspace`) - cy.contains("a", "Create folder").should("exist").click({ force: true }) - cy.get("input#newDirectoryName").clear().type(TEST_FOLDER_TITLE) - cy.contains("Next").click() - cy.contains("Skip").click() - - cy.wait(Interceptors.POST) - - // Set up test collection page - cy.visit( - `/sites/${TEST_REPO_NAME}/folders/${TEST_FOLDER_TITLE_SLUGIFIED}` - ) - cy.contains("Create page").should("exist").click() - cy.get("#title").clear().type(TEST_PAGE_TITLE) - cy.contains("Save").click() - - cy.wait(Interceptors.POST) - }) - - beforeEach(() => { - cy.visit( - `/sites/${TEST_REPO_NAME}/folders/${TEST_FOLDER_TITLE_SLUGIFIED}/editPage/${TEST_PAGE_TITLE_ENCODED}` - ).wait(Interceptors.GET) - }) - - it("Edit page (collection) should have correct colour", () => { - cy.get("#display-header").should( - "have.css", - "background-color", - PRIMARY_COLOUR - ) - }) - - it("Edit page (collection) should have name of title", () => { - cy.contains(TEST_PAGE_TITLE) - }) - - it("Edit page (collection) should have third nav menu", () => { - cy.wait(Interceptors.GET) - // NOTE: Wait for the markdown editor + preview to load - cy.get(".spinner-border").should("not.exist") - cy.get("#sidenav") - .should("be.visible") - .contains(TEST_PAGE_TITLE) - .should("exist") - }) - - it("Edit page (collection) should provide a warning to users when navigating away", () => { - cy.get(".CodeMirror-scroll").type(TEST_PAGE_CONTENT) - cy.get('button[aria-label="Back to sites"]').click() - - cy.contains("Warning") - cy.contains(":button", "No").click() - - // Sanity check: still in edit collection pages and content still present - cy.url().should( - "include", - `${CMS_BASEURL}/sites/${TEST_REPO_NAME}/folders/${TEST_FOLDER_TITLE_SLUGIFIED}/editPage/${TEST_PAGE_TITLE_ENCODED}` - ) - cy.contains(TEST_PAGE_CONTENT) - - cy.get('button[aria-label="Back to sites"]').click() - - cy.contains("Warning") - cy.contains(":button", "Yes").click() - - // Assert: in Collection folder - cy.url().should( - "include", - `${CMS_BASEURL}/sites/${TEST_REPO_NAME}/folders/${TEST_FOLDER_TITLE_SLUGIFIED}` - ) - }) - - it("Edit page (collection) should allow user to modify and save content", () => { - cy.get(".CodeMirror-scroll").type(TEST_PAGE_CONTENT) - cy.contains(":button", "Save").click() - - // Asserts - // 1. Toast - cy.contains(SUCCESSFUL_EDIT_PAGE_TOAST) - - // 2. Content is there even after refreshing - cy.reload() - cy.contains(TEST_PAGE_CONTENT).should("exist") - }) - - it("Edit page (collection) should allow user to add existing image", () => { - // NOTE: Multiple GET requests are fired off and hence, unable to use default GET to match - cy.intercept("**/images").as("getImages") - cy.get(".image").click().wait("@getImages") - cy.contains(DEFAULT_IMAGE_TITLE).click() - cy.contains(":button", "Select").click() - - cy.get("#altText").clear().type("Hello World") - cy.contains(":button", "Save").click() - cy.contains(`/images/${DEFAULT_IMAGE_TITLE}`) - }) - - it("Edit page (collection) should allow user to add existing file", () => { - cy.get(".file").click() - cy.contains(ADDED_FILE_TITLE).click() - cy.contains(":button", "Select").click() - - cy.get("#altText").clear().type("Hello World") - cy.contains(":button", "Save").click() - cy.contains(`/files/${ADDED_FILE_TITLE}`) - }) - - it("Edit page (collection) should allow user to add link", () => { - cy.get(".link").click() - - cy.get('input[id="text"]').type(LINK_TITLE) - cy.get('input[id="link"]').type(LINK_URL) - cy.contains(":button", "Save").click() - - cy.contains(`[${LINK_TITLE}](${LINK_URL})`) - }) - }) - describe("Edit resource page", () => { const TEST_CATEGORY = "Test Edit Resource Category" const TEST_CATEGORY_SLUGIFIED = slugifyCategory(TEST_CATEGORY)