diff --git a/CHANGELOG.md b/CHANGELOG.md index 877e7e3e9..0bb943d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,17 @@ 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.48.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.47.1...v0.48.0) + +- Fix/styles [`#1560`](https://github.com/isomerpages/isomercms-frontend/pull/1560) +- fix(e2e): utlise new backend endpoint to reset e2e repos [`#1536`](https://github.com/isomerpages/isomercms-frontend/pull/1536) +- Hotfix/v0.47.1 [`#1557`](https://github.com/isomerpages/isomercms-frontend/pull/1557) +- release(0.47.0): merge to `develop` [`#1553`](https://github.com/isomerpages/isomercms-frontend/pull/1553) + #### [v0.47.1](https://github.com/isomerpages/isomercms-frontend/compare/v0.47.0...v0.47.1) +> 3 October 2023 + - fix(hero.scss): css fix [`af09212`](https://github.com/isomerpages/isomercms-frontend/commit/af09212f81dbf845eae7579632fecb2a26d3eb1a) #### [v0.47.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.46.0...v0.47.0) diff --git a/package-lock.json b/package-lock.json index 71f29d2d0..01578cd50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "isomercms-frontend", - "version": "0.47.1", + "version": "0.48.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "isomercms-frontend", - "version": "0.47.1", + "version": "0.48.0", "hasInstallScript": true, "dependencies": { "@braintree/sanitize-url": "^6.0.1", @@ -113,7 +113,6 @@ "@typescript-eslint/parser": "^5.55.0", "auto-changelog": "^2.4.0", "babel-jest": "^29.5.0", - "btoa": "^1.2.1", "chromatic": "^6.5.6", "cypress": "^12.8.0", "cypress-pipe": "^2.0.0", @@ -13550,17 +13549,6 @@ "node-int64": "^0.4.0" } }, - "node_modules/btoa": { - "version": "1.2.1", - "dev": true, - "license": "(MIT OR Apache-2.0)", - "bin": { - "btoa": "bin/btoa.js" - }, - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/buffer": { "version": "5.2.1", "dev": true, diff --git a/package.json b/package.json index 1d8591296..f3739e70f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "isomercms-frontend", - "version": "0.47.1", + "version": "0.48.0", "private": true, "engines": { "node": ">=16.0.0" @@ -159,7 +159,6 @@ "@typescript-eslint/parser": "^5.55.0", "auto-changelog": "^2.4.0", "babel-jest": "^29.5.0", - "btoa": "^1.2.1", "chromatic": "^6.5.6", "cypress": "^12.8.0", "cypress-pipe": "^2.0.0", diff --git a/scripts/build.js b/scripts/build.js index a47ee3010..ab11fe00d 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -2,23 +2,28 @@ const { spawn } = require("child_process") const axios = require("axios") -const btoa = require("btoa") -// login credentials -const { PERSONAL_ACCESS_TOKEN, USERNAME } = process.env -if (!PERSONAL_ACCESS_TOKEN || !USERNAME) { +// Login credentials +const { + CYPRESS_COOKIE_NAME, + CYPRESS_COOKIE_VALUE, + CYPRESS_BACKEND_URL, +} = process.env +if (!CYPRESS_COOKIE_NAME || !CYPRESS_COOKIE_VALUE) { throw new Error( - `E2E tests require env vars PERSONAL_ACCESS_TOKEN (${PERSONAL_ACCESS_TOKEN}) and USERNAME (${USERNAME}) to be set.` + `E2E tests require env vars CYPRESS_COOKIE_NAME and CYPRESS_COOKIE_VALUE to be set.` ) } -const CREDENTIALS = `${USERNAME}:${PERSONAL_ACCESS_TOKEN}` -const headers = { - authorization: `basic ${btoa(CREDENTIALS)}`, - accept: "application/json", +const emailHeaders = { + Cookie: `${CYPRESS_COOKIE_NAME}=${CYPRESS_COOKIE_VALUE}; e2eUserType=Email admin; site=e2e email test site; email=admin@e2e.gov.sg`, } -// cypress commands +const githubHeaders = { + Cookie: `${CYPRESS_COOKIE_NAME}=${CYPRESS_COOKIE_VALUE}; e2eUserType=Github user`, +} + +// Cypress test runner const cypressCommand = process.argv[2] // either `run` or `open` const baseCypressCommand = `npx cypress ${cypressCommand}` // if we are running tests, record them on the dashboard so that github will show the corresponding status @@ -27,49 +32,40 @@ const runCypressCommand = ? `${baseCypressCommand} --record` : baseCypressCommand -// reset e2e-test-repo -const { E2E_COMMIT_HASH } = process.env -if (!E2E_COMMIT_HASH) { - throw new Error( - `E2E tests require env var E2E_COMMIT_HASH (${E2E_COMMIT_HASH}) to be set.` - ) +// E2E test repositories +const e2eTestRepositoriesWithHashes = { + "e2e-test-repo": "bcfe46da1288b3302c5bb5f72c5c58b50574f26c", + "e2e-email-test-repo": "93593ceb8ee8af690267e49ea787701fc73baed8", + "e2e-notggs-test-repo": "1ccc5253dd06e06a088d1e6ec86a38c870c0a3d6", } -const GITHUB_ORG_NAME = "isomerpages" -const E2E_GITHUB_REPO_NAME = "e2e-test-repo" -const E2E_EMAIL_REPO_NAME = "e2e-email-test-repo" -const E2E_EMAIL_COMMIT_HASH = "93593ceb8ee8af690267e49ea787701fc73baed8" -const resetRepo = async (repo, hash, branch) => { - const endpoint = `https://api.github.com/repos/${GITHUB_ORG_NAME}/${repo}/git/refs/heads/${branch}` - await axios.patch( +// Reset test repositories +const resetRepository = async (repository, branchName, userType) => { + const endpoint = `${CYPRESS_BACKEND_URL}/sites/${repository}/admin/resetRepo` + const headers = userType === "github" ? githubHeaders : emailHeaders + await axios.post( endpoint, { - sha: hash, - force: true, + commitSha: e2eTestRepositoriesWithHashes[repository], + branchName, }, - { - headers, - } + { headers }, + { withCredentials: true } + ) + console.log( + `Successfully reset ${repository} (${branchName}) to ${e2eTestRepositoriesWithHashes[repository]}}` ) - console.log(`Successfully reset ${repo} to ${hash}`) -} - -const resetGithubE2eTestRepo = () => - resetRepo(E2E_GITHUB_REPO_NAME, E2E_COMMIT_HASH, "staging") - -const resetEmailE2eTestRepo = () => { - resetRepo(E2E_EMAIL_REPO_NAME, E2E_EMAIL_COMMIT_HASH, "staging") - resetRepo(E2E_EMAIL_REPO_NAME, E2E_EMAIL_COMMIT_HASH, "master") } -const resetE2eTestRepo = async () => { - await resetGithubE2eTestRepo() - await resetEmailE2eTestRepo() +const resetE2ETestRepositories = async () => { + resetRepository("e2e-test-repo", "staging", "github") + resetRepository("e2e-notggs-test-repo", "staging", "github") + resetRepository("e2e-email-test-repo", "staging", "email") + resetRepository("e2e-email-test-repo", "master", "email") } -// resets the e2e repo then runs the corresponding cypress command -const runE2eTests = async () => - resetE2eTestRepo() +const runE2ETests = async () => { + resetE2ETestRepositories() .then(() => { const child = spawn(runCypressCommand, { shell: true }) child.stderr.on("data", (data) => { @@ -83,7 +79,8 @@ const runE2eTests = async () => // NOTE: Cypress uses the exit code to show the number of failed tests. // If we do not exit here, the child process (that's running the test) will not be able to feedback // to Github Actions if the tests pass. - process.exit(exitCode) + // If exitCode is null, means that the child process was killed by a signal. + process.exit(exitCode || 1) }) }) .catch((err) => { @@ -92,8 +89,9 @@ const runE2eTests = async () => // This also prevents CI from recording this as a successful step. process.exit(1) }) +} module.exports = { - runE2eTests, - resetE2eTestRepo, + runE2ETests, + resetE2ETestRepositories, } diff --git a/scripts/reset-e2e.js b/scripts/reset-e2e.js index 1d5df1d20..e2ec4b6f2 100644 --- a/scripts/reset-e2e.js +++ b/scripts/reset-e2e.js @@ -1,3 +1,3 @@ -const { resetE2eTestRepo } = require("./build") +const { resetE2ETestRepositories } = require("./build") -resetE2eTestRepo() +resetE2ETestRepositories() diff --git a/scripts/run-e2e.js b/scripts/run-e2e.js index 3aee7d219..090ce50b5 100644 --- a/scripts/run-e2e.js +++ b/scripts/run-e2e.js @@ -1,3 +1,3 @@ -const { runE2eTests } = require("./build") +const { runE2ETests } = require("./build") -runE2eTests() +runE2ETests() diff --git a/src/layouts/components/Homepage/AnnouncementBody.tsx b/src/layouts/components/Homepage/AnnouncementBody.tsx index 37487ae3d..64125224e 100644 --- a/src/layouts/components/Homepage/AnnouncementBody.tsx +++ b/src/layouts/components/Homepage/AnnouncementBody.tsx @@ -74,8 +74,7 @@ export const AnnouncementBody = ({ Announcements - {`You can display up to ${MAX_ANNOUNCEMENTS} announcements at a time. Newly added - announcements are shown on the top of the list`} + {`You can display up to ${MAX_ANNOUNCEMENTS} announcements at a time.`} - + Hero Interactions - + Content type - Button Text + Button text {errors.description} - - - Cards - - - Cards are displayed side by side on a desktop screen. You can add up - to 4 cards - - - - - - - {cards.map((card, cardIndex) => ( - - - + Cards + + + Cards are displayed side by side on a desktop screen. You can add up to + 4 cards + + + + + + + {cards.map((card, cardIndex) => ( + + + + Title + + + {cardErrors[cardIndex].title} + + + + Description +