Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release(0.37.0): merge to master #1388

Merged
merged 17 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ env:
ISOMER_COMMENT_WORKFLOW_NAME: chromatic.yml
# Use GitHub Token
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Required for the chromatic action
REACT_APP_BACKEND_URL: "https://cms-api.isomer.gov.sg/v1"

# List of jobs
jobs:
Expand Down Expand Up @@ -60,7 +62,7 @@ jobs:
trigger: "${{ env.ISOMER_TRIGGER_COMMENT }}"
prefix_only: "true"
reaction: "+1"
- name: Dont run job if user is not part of Isomer core team or trigger words are not present
- name: Don't run job if user is not part of Isomer core team or trigger words are not present
if: ${{ steps.checkUserMember.outputs.isTeamMember != 'true' || !(github.event_name == 'issue_comment' && github.event.issue.pull_request && steps.check.outputs.triggered == 'true') }}
run: exit 0
- uses: actions/checkout@v1
Expand Down
3 changes: 3 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import "@fontsource/ibm-plex-mono"
import "inter-ui/inter.css"

import { ThemeProvider, useToast } from "@opengovsg/design-system-react"
import { initialize, mswDecorator } from "msw-storybook-addon"
import { QueryClient, QueryClientProvider } from "react-query"
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,29 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.37.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.36.0...v0.37.0)

- fix(feedbackmodal): import order [`#1389`](https://github.com/isomerpages/isomercms-frontend/pull/1389)
- Test/review requests [`#1379`](https://github.com/isomerpages/isomercms-frontend/pull/1379)
- feat(nps): update UI [`#1370`](https://github.com/isomerpages/isomercms-frontend/pull/1370)
- fix(useToastHook): make sure hook is not called conditionally [`#1341`](https://github.com/isomerpages/isomercms-frontend/pull/1341)
- fix(deps): upgrade design system [`#1329`](https://github.com/isomerpages/isomercms-frontend/pull/1329)
- fix(header): fix context [`#1386`](https://github.com/isomerpages/isomercms-frontend/pull/1386)
- Fix: Copy Changes [`#1385`](https://github.com/isomerpages/isomercms-frontend/pull/1385)
- test(e2e): add homepage [`#1374`](https://github.com/isomerpages/isomercms-frontend/pull/1374)
- IS-349-FE-only-admins-can-launch-sites [`#1384`](https://github.com/isomerpages/isomercms-frontend/pull/1384)
- feat(site launch): add in refetch behvaiour [`#1380`](https://github.com/isomerpages/isomercms-frontend/pull/1380)
- feat: storybook improvement for site launch pad [`#1382`](https://github.com/isomerpages/isomercms-frontend/pull/1382)
- Is 259 write e2e test spec for notifs [`#1354`](https://github.com/isomerpages/isomercms-frontend/pull/1354)
- Fix/copy changes [`#1352`](https://github.com/isomerpages/isomercms-frontend/pull/1352)
- fix(chromatic.yml): fix failing workflows [`#1378`](https://github.com/isomerpages/isomercms-frontend/pull/1378)
- feat(preview): added preview images [`#1360`](https://github.com/isomerpages/isomercms-frontend/pull/1360)
- Release 0.36.0 [`#1375`](https://github.com/isomerpages/isomercms-frontend/pull/1375)

#### [v0.36.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.35.0...v0.36.0)

> 27 July 2023

- Feat/sgid experimental integration [`#1369`](https://github.com/isomerpages/isomercms-frontend/pull/1369)
- Revert "refactor(e2e): change naming (#1362)" [`#1371`](https://github.com/isomerpages/isomercms-frontend/pull/1371)
- feat(setup.md): add command [`#1353`](https://github.com/isomerpages/isomercms-frontend/pull/1353)
Expand Down
142 changes: 142 additions & 0 deletions cypress/api/pages.api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,71 @@
import { DirectoryData } from "types/directory"

import { UnlinkedPageDto } from "../../src/types/pages"
import { BACKEND_URL } from "../fixtures/constants"

export const listCollectionPages = (
site: string,
collectionName: string
): Cypress.Chainable<DirectoryData[]> => {
return cy
.request(
"GET",
`${BACKEND_URL}/sites/${site}/collections/${collectionName}`
)
.then(({ body }) => body)
}

export const listUnlinkedPages = (
site: string
): Cypress.Chainable<DirectoryData[]> => {
return cy
.request("GET", `${BACKEND_URL}/sites/${site}/pages`)
.then(({ body }) => body)
}

export const addCollectionPage = (
pageName: string,
collectionName: string,
title: string,
permalink: string,
pageContent: string,
site: string
): void => {
cy.request(
"POST",
`${BACKEND_URL}/sites/${site}/collections/${collectionName}/pages`,
{
content: {
frontMatter: {
title,
permalink,
},
pageBody: pageContent,
},
newFileName: pageName,
}
)
}

export const addUnlinkedPage = (
pageName: string,
title: string,
permalink: string,
pageContent: string,
site: string
): void => {
cy.request("POST", `${BACKEND_URL}/sites/${site}/pages/pages`, {
content: {
frontMatter: {
title,
permalink,
},
pageBody: pageContent,
},
newFileName: pageName,
})
}

export const editUnlinkedPage = (
pageName: string,
pageContent: string,
Expand Down Expand Up @@ -29,3 +94,80 @@ export const readUnlinkedPage = (
.request("GET", `${BACKEND_URL}/sites/${site}/pages/pages/${pageName}`)
.then(({ body }) => body)
}

export const readCollectionPage = (
pageName: string,
collectionName: string,
site: string
): Cypress.Chainable<UnlinkedPageDto> => {
return cy
.request(
"GET",
`${BACKEND_URL}/sites/${site}/collections/${collectionName}/pages/${pageName}`
)
.then(({ body }) => body)
}

export const deleteUnlinkedPage = (pageName: string, site: string): void => {
readUnlinkedPage(pageName, site).then(({ sha }) => {
return cy.request(
"DELETE",
`${BACKEND_URL}/sites/${site}/pages/pages/${pageName}`,
{
sha,
}
)
})
}

export const deleteCollectionPage = (
pageName: string,
collectionName: string,
site: string
): void => {
readCollectionPage(pageName, collectionName, site).then(({ sha }) => {
return cy.request(
"DELETE",
`${BACKEND_URL}/sites/${site}/collections/${collectionName}/pages/${pageName}`,
{
sha,
}
)
})
}

export const renameUnlinkedPage = (
pageName: string,
newPageName: string,
site: string
): void => {
readUnlinkedPage(pageName, site).then(({ sha, content }) => {
return cy.request(
"POST",
`${BACKEND_URL}/sites/${site}/pages/pages/${pageName}`,
{
content,
sha,
newFileName: newPageName,
}
)
})
}

export const moveUnlinkedPage = (
pageName: string,
targetCollectionName: string,
site: string
): void => {
cy.request("POST", `${BACKEND_URL}/sites/${site}/pages/move`, {
target: {
collectionName: targetCollectionName,
},
items: [
{
name: pageName,
type: "file",
},
],
})
}
10 changes: 7 additions & 3 deletions cypress/api/reviewRequest.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ export const createReviewRequest = (
.then(({ body }) => body.pullRequestNumber)
}

export const listReviewRequests = (): Cypress.Chainable<{ id: number }[]> => {
export const listReviewRequests = (): Cypress.Chainable<
{ id: number; author: string; status: string }[]
> => {
return cy
.request("GET", `${BASE_URL}/summary`)
.then(({ body }) => body.reviews)
}

export const closeReviewRequests = (): void => {
listReviewRequests().then((reviewRequests) => {
reviewRequests.forEach(({ id }) => {
closeReviewRequest(id)
reviewRequests.forEach(({ id, author }) => {
// Only the requestor can close their own review request
cy.actAsEmailUser(author, "Email admin")
cy.request("DELETE", `${BASE_URL}/${id}`)
})
})
}
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/collaborators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
addCollaborator,
getCollaboratorsModal,
inputCollaborators,
removeOtherCollaborators,
removeFirstCollaborator,
} from "../utils/collaborators"

const collaborator = E2E_EMAIL_COLLAB.email
Expand Down Expand Up @@ -62,7 +62,7 @@ describe("collaborators flow", () => {
})

describe("Admin adding a collaborator", () => {
after(() => removeOtherCollaborators())
after(() => removeFirstCollaborator())

it("should not be able to click the add collaborator button when the input is empty", () => {
// Act
Expand Down Expand Up @@ -137,7 +137,7 @@ describe("collaborators flow", () => {
it("should not be able to remove the last site member", () => {
// Act
// NOTE: Remove all collaborators except the initial admin
removeOtherCollaborators()
removeFirstCollaborator()

// Assert
cy.get(DELETE_COLLABORATOR_BUTTON_SELECTOR).should("be.disabled")
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/comments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ignoreNotFoundError,
openCommentsDrawer,
openReviewRequest,
removeOtherCollaborators,
removeFirstCollaborator,
setUserAsUnauthorised,
visitE2eEmailTestRepo,
getCommentInput,
Expand Down Expand Up @@ -201,7 +201,7 @@ describe("Comments", () => {
.then((id) => {
reviewId = id
})
removeOtherCollaborators()
removeFirstCollaborator()
})

// This is required so that subsequent tests do not fail
Expand Down
16 changes: 12 additions & 4 deletions cypress/e2e/folders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ describe("Folders flow", () => {

cy.get("#title").clear().type(EDITED_TEST_PAGE_TITLE)
cy.contains("button", "Save").click().wait(Interceptors.POST)
cy.contains("Successfully updated page!").should("exist")
cy.contains(
"Changes saved. See a preview on Staging, or request a Review for them to be published."
).should("exist")

// Asserts
// 1. New page title should be reflected in Folders
Expand All @@ -318,7 +320,9 @@ describe("Folders flow", () => {

cy.get("#title").clear().type(EDITED_TEST_PAGE_TITLE_2)
cy.contains("button", "Save").click().wait(Interceptors.POST)
cy.contains("Successfully updated page!").should("exist")
cy.contains(
"Changes saved. See a preview on Staging, or request a Review for them to be published."
).should("exist")

// Asserts
// 1. New page title should be reflected in Folders
Expand Down Expand Up @@ -445,7 +449,9 @@ describe("Folders flow", () => {

cy.get("#title").clear().type(EDITED_TEST_PAGE_TITLE)
cy.contains("button", "Save").click().wait(Interceptors.POST)
cy.contains("Successfully updated page!").should("exist")
cy.contains(
"Changes saved. See a preview on Staging, or request a Review for them to be published."
).should("exist")

// Asserts
// 1. New page title should be reflected in Folders
Expand All @@ -468,7 +474,9 @@ describe("Folders flow", () => {

cy.get("#title").clear().type(EDITED_TEST_PAGE_TITLE_2)
cy.contains("button", "Save").click().wait(Interceptors.POST)
cy.contains("Successfully updated page!").should("exist")
cy.contains(
"Changes saved. See a preview on Staging, or request a Review for them to be published."
).should("exist")

// Asserts
// 1. New page title should be reflected in Folders
Expand Down
Loading