diff --git a/.buildkite/e2e_on_pull_requests/README.md b/.buildkite/e2e_on_pull_requests/README.md index 2386612534..67d440bc16 100644 --- a/.buildkite/e2e_on_pull_requests/README.md +++ b/.buildkite/e2e_on_pull_requests/README.md @@ -11,40 +11,17 @@ It's moderately fiddly, so this README tries to outline the broad approach. ## What it looks like for devs -At the end of a "build + test" job, devs get asked whether they want to run end-to-end tests: +At the end of a "build + test" job on a branch other than `main`, devs get asked whether they want to run end-to-end tests: -If you select **Yes, run e2e tests now**, Buildkite will start running the end-to-end tests as part of the same "build + test" job. +If you select **Yes, run e2e tests now**, we use `buildkite-agent pipeline upload` to dynamically add more steps to the pipeline. Buildkite will start running these end-to-end tests steps as part of the same "build + test" job. +See [additional steps](pipeline.e2e-pull-requests.yml) for more details. If you select **Not now, maybe later**, Buildkite will complete the current build, but ask you again when you push new commits. -This is useful if you know your PR is a draft or work-in-progress, and it's not worth running e2e tests yet. +This is useful if you know your PR is a draft or work-in-progress, and it's not worth running e2e tests yet. -If you select **No, not needed for this PR**, Buildkite will complete the current build, and won't ask you again when you push new commits. -Instead, it adds the `e2es not required` label to your PR. -If you want to re-run e2es later, remove this label. - -## How it works - -This is the rough flow: - -```mermaid -flowchart TD - B["Buildkite runs tests on PR
(see pipeline.yml)"] - B --> HL{is there a
'skip e2e tests'
label?} - HL -->|yes| X[nothing to do,
build completes] - HL -->|no| ASK{ask the user
if they want
to run e2es
on this PR} - - ASK -->|yes, now| Y["run e2e tests"] - ASK -->|no, maybe later| ML[nothing to do,
build completes] - ASK -->|no, not needed| N[add the 'skip e2e tests' label
in GitHub, build completes] -``` - -At both the choice steps, we're using `buildkite-agent pipeline upload` to dynamically add more steps to the pipeline. -See the individual scripts/YAML files for more explanatory comments. ## Implementation notes -* We use GitHub labels to track when a dev has declined to run e2es, because they're easily visible and use an interface we're already familiar with. - * We only turn on the e2e cluster when we're running tests, to reduce costs. diff --git a/.buildkite/e2e_on_pull_requests/check_if_we_need_to_ask.sh b/.buildkite/e2e_on_pull_requests/check_if_we_need_to_ask.sh deleted file mode 100755 index 692f7e54b2..0000000000 --- a/.buildkite/e2e_on_pull_requests/check_if_we_need_to_ask.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -# This script checks if we need to ask the user about running e2es. -# -# It uses the GitHub API to look for an "e2es not required" label. -# -# If it finds one, then the user has already opted to skip e2es -- so -# we don't need to ask again. -# -# If it doesn't find one, it adds two new steps to Buildkite: -# one to ask the user whether to run end-to-end tests on their PR, -# and one to react to their choice. - -set -o errexit -set -o nounset - -# Buildkite freezes all its environment variables at the point when -# the build starts -- this means that if it starts building a commit -# on a branch before there's a pull request created from that branch, -# then this variable won't point to anything. -# -# In this case, we don't bother checking for labels on the PR -- -# we know there won't be any, as it's too soon. -# -# Additionally, we don't offer the option to skip e2es forever on -# this PR -- we don't have enough information to apply the tag to -# the PR yet. -if [[ "$BUILDKITE_PULL_REQUEST" != "false" ]] -then - GITHUB_API_TOKEN=$(aws secretsmanager get-secret-value \ - --secret-id builds/github_wecobot/e2e_pull_request_labels \ - | jq -r .SecretString) - - HAS_SKIP_E2E_LABEL=$( - curl -L \ - -H 'Accept: application/vnd.github+json' \ - -H "Authorization: Bearer $GITHUB_API_TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/repos/wellcomecollection/wellcomecollection.org/issues/$BUILDKITE_PULL_REQUEST/labels" \ - | jq '. | map(select(.name == "e2es not required")) | length' - ) - - if (( HAS_SKIP_E2E_LABEL == 1 )) - then - exit 0 - fi -fi - -if [[ "$BUILDKITE_PULL_REQUEST" != "false" ]] -then - buildkite-agent pipeline upload << EOF - - wait - - - input: "Do you want to run end-to-end tests on this pull request?" - key: "ask-user-if-should-run-e2es" - fields: - - select: "Run e2es?" - key: "should-run-e2es" - options: - - label: "Yes, run e2e tests now" - value: "yes" - - label: "Not now, maybe later" - value: "maybe-later" - - label: "No, not needed for this PR" - value: "no" - - - label: "Add steps for e2e tests (if necessary)" - command: ".buildkite/e2e_on_pull_requests/react_to_user_choice_about_e2e_on_pull_request.sh" - depends_on: "ask-user-if-should-run-e2es" - - agents: - queue: nano -EOF -else - buildkite-agent pipeline upload << EOF - - wait - - - input: "Do you want to run end-to-end tests on this pull request?" - key: "ask-user-if-should-run-e2es" - fields: - - select: "Run e2es?" - key: "should-run-e2es" - options: - - label: "Yes, run e2e tests now" - value: "yes" - - label: "Not now, maybe later" - value: "maybe-later" - - - label: "Add steps for e2e tests (if necessary)" - command: ".buildkite/e2e_on_pull_requests/react_to_user_choice_about_e2e_on_pull_request.sh" - depends_on: "ask-user-if-should-run-e2es" - - agents: - queue: nano -EOF -fi - diff --git a/.buildkite/e2e_on_pull_requests/e2e_dev_picker.png b/.buildkite/e2e_on_pull_requests/e2e_dev_picker.png index d49fe8f874..317bf7bf15 100644 Binary files a/.buildkite/e2e_on_pull_requests/e2e_dev_picker.png and b/.buildkite/e2e_on_pull_requests/e2e_dev_picker.png differ diff --git a/.buildkite/e2e_on_pull_requests/react_to_user_choice_about_e2e_on_pull_request.sh b/.buildkite/e2e_on_pull_requests/react_to_user_choice_about_e2e_on_pull_request.sh deleted file mode 100755 index 7c3420d65b..0000000000 --- a/.buildkite/e2e_on_pull_requests/react_to_user_choice_about_e2e_on_pull_request.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# This script runs after the user has picked whether they want -# to run e2e tests in the Buildkite UI. -# -# If they select "yes", it adds new steps to Buildkite to run the e2es. -# -# If they select "no, never", it uses the GitHub API to add the "skip e2es" -# label to the pull request. -# -# If they select "not now, maybe later", it just exits without doing -# anything else. - -set -o errexit -set -o nounset - -if [[ "$(buildkite-agent meta-data get should-run-e2es)" == "yes" ]] -then - buildkite-agent pipeline upload .buildkite/e2e_on_pull_requests/pipeline.e2e-pull-requests.yml -fi - -if [[ "$(buildkite-agent meta-data get should-run-e2es)" == "no" ]] -then - GITHUB_API_TOKEN=$(aws secretsmanager get-secret-value \ - --secret-id builds/github_wecobot/e2e_pull_request_labels \ - | jq -r .SecretString) - - curl -L -X POST \ - -H 'Accept: application/vnd.github+json' \ - -H "Authorization: Bearer $GITHUB_API_TOKEN" \ - -H 'X-GitHub-Api-Version: 2022-11-28' \ - "https://api.github.com/repos/wellcomecollection/wellcomecollection.org/issues/$BUILDKITE_PULL_REQUEST" \ - -d '{"labels": ["e2es not required"]}' -fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index bc3f074996..46fb94b1e2 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -129,10 +129,28 @@ # # It doesn't run on main, because we run e2es on main by deploying # into our stage/prod environments instead. -- label: 'check if we need to run e2es' - command: .buildkite/e2e_on_pull_requests/check_if_we_need_to_ask.sh - if: build.branch != "main" +- wait + +- input: "Run end-to-end tests on this pull request?" + if: build.branch != "main" + key: "ask-user-if-should-run-e2es" + fields: + - select: "Run e2es?" + key: "should-run-e2es" + options: + - label: "Yes, run e2e tests now" + value: "yes" + - label: "Not now, maybe later" + value: "maybe-later" + +- label: "Add steps for e2e tests (if necessary)" + depends_on: "ask-user-if-should-run-e2es" + command: | + if [[ "$$(buildkite-agent meta-data get should-run-e2es)" == "yes" ]]; then + buildkite-agent pipeline upload .buildkite/e2e_on_pull_requests/pipeline.e2e-pull-requests.yml + fi + agents: queue: nano diff --git a/cache/edge_lambdas/src/redirects.ts b/cache/edge_lambdas/src/redirects.ts index 2de6fb4d59..255a99277a 100644 --- a/cache/edge_lambdas/src/redirects.ts +++ b/cache/edge_lambdas/src/redirects.ts @@ -235,6 +235,17 @@ export const literalRedirects: Record = { // Requested by Content team // See https://github.com/wellcomecollection/wellcomecollection.org/issues/9765 '/lbe-festival': '/event-series/ZFt3UBQAAMFmEIya', + + // Old Exhibition guide content type to new Highlights Tour/Text format. + // See https://github.com/wellcomecollection/wellcomecollection.org/issues/11140 + '/guides/exhibitions/Zdcs4BEAACMA6abC': + '/guides/exhibitions/ZthrZRIAACQALvCC', + '/guides/exhibitions/Zdcs4BEAACMA6abC/audio-without-descriptions': + '/guides/exhibitions/ZthrZRIAACQALvCC/audio-without-descriptions', + '/guides/exhibitions/Zdcs4BEAACMA6abC/bsl': + '/guides/exhibitions/ZthrZRIAACQALvCC/bsl', + '/guides/exhibitions/Zdcs4BEAACMA6abC/captions-and-transcripts': + '/guides/exhibitions/ZthrZRIAACQALvCC/captions-and-transcripts', }; // Query redirects have the form: diff --git a/dash/webapp/package.json b/dash/webapp/package.json index 99000a8fdb..81cfabaf4f 100644 --- a/dash/webapp/package.json +++ b/dash/webapp/package.json @@ -12,7 +12,7 @@ "@babel/runtime": "^7.24.7", "@types/react": "^18.3.3", "cookies-next": "^4.2.1", - "next": "^14.2.4", + "next": "^14.2.10", "react": "^18.3.1", "react-dom": "^18.3.1", "styled-components": "^6.1.11", diff --git a/dash/webapp/yarn.lock b/dash/webapp/yarn.lock index 6c47e6e242..6e93f4c4e3 100644 --- a/dash/webapp/yarn.lock +++ b/dash/webapp/yarn.lock @@ -271,55 +271,55 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@next/env@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.4.tgz#5546813dc4f809884a37d257b254a5ce1b0248d7" - integrity sha512-3EtkY5VDkuV2+lNmKlbkibIJxcO4oIHEhBWne6PaAp+76J9KoSsGvNikp6ivzAT8dhhBMYrm6op2pS1ApG0Hzg== - -"@next/swc-darwin-arm64@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.4.tgz#da9f04c34a3d5f0b8401ed745768420e4a604036" - integrity sha512-AH3mO4JlFUqsYcwFUHb1wAKlebHU/Hv2u2kb1pAuRanDZ7pD/A/KPD98RHZmwsJpdHQwfEc/06mgpSzwrJYnNg== - -"@next/swc-darwin-x64@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.4.tgz#46dedb29ec5503bf171a72a3ecb8aac6e738e9d6" - integrity sha512-QVadW73sWIO6E2VroyUjuAxhWLZWEpiFqHdZdoQ/AMpN9YWGuHV8t2rChr0ahy+irKX5mlDU7OY68k3n4tAZTg== - -"@next/swc-linux-arm64-gnu@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.4.tgz#c9697ab9eb422bd1d7ffd0eb0779cc2aefa9d4a1" - integrity sha512-KT6GUrb3oyCfcfJ+WliXuJnD6pCpZiosx2X3k66HLR+DMoilRb76LpWPGb4tZprawTtcnyrv75ElD6VncVamUQ== - -"@next/swc-linux-arm64-musl@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.4.tgz#cbbceb2008571c743b5a310a488d2e166d200a75" - integrity sha512-Alv8/XGSs/ytwQcbCHwze1HmiIkIVhDHYLjczSVrf0Wi2MvKn/blt7+S6FJitj3yTlMwMxII1gIJ9WepI4aZ/A== - -"@next/swc-linux-x64-gnu@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.4.tgz#d79184223f857bacffb92f643cb2943a43632568" - integrity sha512-ze0ShQDBPCqxLImzw4sCdfnB3lRmN3qGMB2GWDRlq5Wqy4G36pxtNOo2usu/Nm9+V2Rh/QQnrRc2l94kYFXO6Q== - -"@next/swc-linux-x64-musl@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.4.tgz#6b6c3e5ac02ca5e63394d280ec8ee607491902df" - integrity sha512-8dwC0UJoc6fC7PX70csdaznVMNr16hQrTDAMPvLPloazlcaWfdPogq+UpZX6Drqb1OBlwowz8iG7WR0Tzk/diQ== - -"@next/swc-win32-arm64-msvc@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.4.tgz#dbad3906e870dba84c5883d9d4c4838472e0697f" - integrity sha512-jxyg67NbEWkDyvM+O8UDbPAyYRZqGLQDTPwvrBBeOSyVWW/jFQkQKQ70JDqDSYg1ZDdl+E3nkbFbq8xM8E9x8A== - -"@next/swc-win32-ia32-msvc@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.4.tgz#6074529b91ba49132922ce89a2e16d25d2ec235d" - integrity sha512-twrmN753hjXRdcrZmZttb/m5xaCBFa48Dt3FbeEItpJArxriYDunWxJn+QFXdJ3hPkm4u7CKxncVvnmgQMY1ag== - -"@next/swc-win32-x64-msvc@14.2.4": - version "14.2.4" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.4.tgz#e65a1c6539a671f97bb86d5183d6e3a1733c29c7" - integrity sha512-tkLrjBzqFTP8DVrAAQmZelEahfR9OxWpFR++vAI9FBhCiIxtwHwBHC23SBHCTURBtwB4kc/x44imVOnkKGNVGg== +"@next/env@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.12.tgz#15f1d1065a420416e92f177fc8c94ee4ecc2669d" + integrity sha512-3fP29GIetdwVIfIRyLKM7KrvJaqepv+6pVodEbx0P5CaMLYBtx+7eEg8JYO5L9sveJO87z9eCReceZLi0hxO1Q== + +"@next/swc-darwin-arm64@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.12.tgz#263c68fd55538624a6236552d153a3487d601a33" + integrity sha512-crHJ9UoinXeFbHYNok6VZqjKnd8rTd7K3Z2zpyzF1ch7vVNKmhjv/V7EHxep3ILoN8JB9AdRn/EtVVyG9AkCXw== + +"@next/swc-darwin-x64@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.12.tgz#0fc05a99094ac531692d552743f62f7dbbcb5bc8" + integrity sha512-JbEaGbWq18BuNBO+lCtKfxl563Uw9oy2TodnN2ioX00u7V1uzrsSUcg3Ep9ce+P0Z9es+JmsvL2/rLphz+Frcw== + +"@next/swc-linux-arm64-gnu@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.12.tgz#56214b10cdb1c47d6f26ae2dd00bc9b32fd2a694" + integrity sha512-qBy7OiXOqZrdp88QEl2H4fWalMGnSCrr1agT/AVDndlyw2YJQA89f3ttR/AkEIP9EkBXXeGl6cC72/EZT5r6rw== + +"@next/swc-linux-arm64-musl@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.12.tgz#017ccb35e94dd5336f38bdab90ccc7163467e0d1" + integrity sha512-EfD9L7o9biaQxjwP1uWXnk3vYZi64NVcKUN83hpVkKocB7ogJfyH2r7o1pPnMtir6gHZiGCeHKagJ0yrNSLNHw== + +"@next/swc-linux-x64-gnu@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.12.tgz#b5df80780eceef6b44a0cedfe7234d34a60af1f9" + integrity sha512-iQ+n2pxklJew9IpE47hE/VgjmljlHqtcD5UhZVeHICTPbLyrgPehaKf2wLRNjYH75udroBNCgrSSVSVpAbNoYw== + +"@next/swc-linux-x64-musl@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.12.tgz#553ad8dd26e8fce343f2b01d741dffc8bb909e37" + integrity sha512-rFkUkNwcQ0ODn7cxvcVdpHlcOpYxMeyMfkJuzaT74xjAa5v4fxP4xDk5OoYmPi8QNLDs3UgZPMSBmpBuv9zKWA== + +"@next/swc-win32-arm64-msvc@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.12.tgz#cf9c3907f43b9a0cbe2f10a46f6c9f5de05ba9dc" + integrity sha512-PQFYUvwtHs/u0K85SG4sAdDXYIPXpETf9mcEjWc0R4JmjgMKSDwIU/qfZdavtP6MPNiMjuKGXHCtyhR/M5zo8g== + +"@next/swc-win32-ia32-msvc@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.12.tgz#cad79313b383e95e6d53bdb631b47a26e63146e0" + integrity sha512-FAj2hMlcbeCV546eU2tEv41dcJb4NeqFlSXU/xL/0ehXywHnNpaYajOUvn3P8wru5WyQe6cTZ8fvckj/2XN4Vw== + +"@next/swc-win32-x64-msvc@14.2.12": + version "14.2.12" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.12.tgz#9d5b2f2733221ae85c3e5c6d4b6f8f1da32d5cae" + integrity sha512-yu8QvV53sBzoIVRHsxCHqeuS8jYq6Lrmdh0briivuh+Brsp6xjg80MAozUsBTAV9KNmY08KlX0KYTWz1lbPzEg== "@swc/counter@^0.1.3": version "0.1.3" @@ -540,12 +540,12 @@ nanoid@^3.3.6, nanoid@^3.3.7: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== -next@^14.2.4: - version "14.2.4" - resolved "https://registry.yarnpkg.com/next/-/next-14.2.4.tgz#ef66c39c71e2d8ad0a3caa0383c8933f4663e4d1" - integrity sha512-R8/V7vugY+822rsQGQCjoLhMuC9oFj9SOi4Cl4b2wjDrseD0LRZ10W7R6Czo4w9ZznVSshKjuIomsRjvm9EKJQ== +next@^14.2.10: + version "14.2.12" + resolved "https://registry.yarnpkg.com/next/-/next-14.2.12.tgz#39d52c090c40980f4ae56f485ad234b777ebc955" + integrity sha512-cDOtUSIeoOvt1skKNihdExWMTybx3exnvbFbb9ecZDIxlvIbREQzt9A5Km3Zn3PfU+IFjyYGsHS+lN9VInAGKA== dependencies: - "@next/env" "14.2.4" + "@next/env" "14.2.12" "@swc/helpers" "0.5.5" busboy "1.6.0" caniuse-lite "^1.0.30001579" @@ -553,15 +553,15 @@ next@^14.2.4: postcss "8.4.31" styled-jsx "5.1.1" optionalDependencies: - "@next/swc-darwin-arm64" "14.2.4" - "@next/swc-darwin-x64" "14.2.4" - "@next/swc-linux-arm64-gnu" "14.2.4" - "@next/swc-linux-arm64-musl" "14.2.4" - "@next/swc-linux-x64-gnu" "14.2.4" - "@next/swc-linux-x64-musl" "14.2.4" - "@next/swc-win32-arm64-msvc" "14.2.4" - "@next/swc-win32-ia32-msvc" "14.2.4" - "@next/swc-win32-x64-msvc" "14.2.4" + "@next/swc-darwin-arm64" "14.2.12" + "@next/swc-darwin-x64" "14.2.12" + "@next/swc-linux-arm64-gnu" "14.2.12" + "@next/swc-linux-arm64-musl" "14.2.12" + "@next/swc-linux-x64-gnu" "14.2.12" + "@next/swc-linux-x64-musl" "14.2.12" + "@next/swc-win32-arm64-msvc" "14.2.12" + "@next/swc-win32-ia32-msvc" "14.2.12" + "@next/swc-win32-x64-msvc" "14.2.12" node-releases@^2.0.14: version "2.0.14" diff --git a/playwright/test/exhibition-guides.test.ts b/playwright/test/exhibition-guides.test.ts index 4470b10b8a..a7d26aa8a3 100644 --- a/playwright/test/exhibition-guides.test.ts +++ b/playwright/test/exhibition-guides.test.ts @@ -1,8 +1,8 @@ import { test, expect } from '@playwright/test'; import { baseUrl } from './helpers/utils'; -import { gotoWithoutCache } from './helpers/contexts'; +import { CookieProps, digitalGuide } from './helpers/contexts'; -const bslCookie = [ +const bslCookie: CookieProps[] = [ { name: 'WC_userPreferenceGuideType', value: 'bsl', @@ -22,6 +22,9 @@ const egWorkCookies = [ }, ]; +const newJasonGuideId = 'ZthrZRIAACQALvCC'; +const newJasonGuideRelativeURL = `/guides/exhibitions/${newJasonGuideId}`; + test.describe.configure({ mode: 'parallel' }); // TODO remove when we stop supporting legacy QRs @@ -30,13 +33,12 @@ test('(1) | Redirects to another format if we have an EG preference and come fro context, page, }) => { - // Add cookie for BSL preference - await context.addCookies(bslCookie); - // Go to In Plain Sight Audio exhibition guide with the QR code params - await gotoWithoutCache( - `${baseUrl}/guides/exhibitions/YzwsAREAAHylrxau/audio-without-descriptions?usingQRCode=true&stopId=witness#witness`, - page + await digitalGuide( + 'YzwsAREAAHylrxau/audio-without-descriptions?usingQRCode=true&stopId=witness#witness', + context, + page, + egWorkCookies ); // Check we've been redirected to the BSL guide and kept the extra params @@ -52,13 +54,12 @@ test.describe('(2) | with egWork toggle: ', () => { context, page, }) => { - // Add cookie for BSL preference - await context.addCookies(egWorkCookies); - // Go to In Plain Sight Audio exhibition guide with the QR code params - await gotoWithoutCache( - `${baseUrl}/guides/exhibitions/YzwsAREAAHylrxau/audio-without-descriptions?usingQRCode=true&stopId=witness#witness`, - page + await digitalGuide( + 'YzwsAREAAHylrxau/audio-without-descriptions?usingQRCode=true&stopId=witness#witness', + context, + page, + egWorkCookies ); // Check we've been redirected to the BSL guide and kept the extra params @@ -71,12 +72,12 @@ test.describe('(2) | with egWork toggle: ', () => { context, page, }) => { - await context.addCookies(egWorkCookies); - - // Kola Nuts with the QR code params and Stop #2 - await gotoWithoutCache( - `${baseUrl}/guides/exhibitions/ZrHvtxEAACYAWmfc?usingQRCode=true&stopNumber=2`, - page + // Jason with the QR code params and Stop #2 + await digitalGuide( + `${newJasonGuideId}?usingQRCode=true&stopNumber=2`, + context, + page, + egWorkCookies ); // Check we've been redirected to the BSL guide's second stop, and kept the extra params @@ -87,17 +88,17 @@ test.describe('(2) | with egWork toggle: ', () => { context, page, }) => { - await context.addCookies(egWorkCookies); - - // Kola Nuts with the QR code params and Stop #2 - await gotoWithoutCache( - `${baseUrl}/guides/exhibitions/ZrHvtxEAACYAWmfc?stopNumber=2`, - page + // Jason with the QR code params and Stop #2 + await digitalGuide( + `${newJasonGuideId}?stopNumber=2`, + context, + page, + egWorkCookies ); // Nothing happens, URL is the same await expect(page).toHaveURL( - /\/guides\/exhibitions\/ZrHvtxEAACYAWmfc[?]stopNumber=2/ + /\/guides\/exhibitions\/ZthrZRIAACQALvCC[?]stopNumber=2/ ); }); @@ -105,93 +106,90 @@ test.describe('(2) | with egWork toggle: ', () => { context, page, }) => { - await context.addCookies(egWorkCookies); - - // Kola Nuts with the QR code params and Stop #1 - await gotoWithoutCache( - `${baseUrl}/guides/exhibitions/ZrHvtxEAACYAWmfc?usingQRCode=true&stopNumber=1`, - page + // Jason with the QR code params and Stop #1 + await digitalGuide( + `${newJasonGuideId}?usingQRCode=true&stopNumber=1`, + context, + page, + egWorkCookies ); // Nothing happens, URL is the same await expect(page).toHaveURL( - /\/guides\/exhibitions\/ZrHvtxEAACYAWmfc\/bsl/ + /\/guides\/exhibitions\/ZthrZRIAACQALvCC\/bsl/ ); }); - // TODO uncomment this once we have content for it in production - // Currently only works with Prismic staging content, but it is a good test to have. - // https://github.com/wellcomecollection/wellcomecollection.org/issues/11131 - test.describe.skip('New: If no type preference set, ', () => { - test('links to BSL and Audio now go straight to stop page instead of landing', async ({ + test.describe('New: If no type preference set, links to BSL and Audio on the EG landing page: ', () => { + test('go straight to stop page instead of listing page', async ({ context, page, }) => { - await context.addCookies([ - { - name: 'toggle_egWork', - value: 'true', - path: '/', - domain: new URL(baseUrl).host, - }, - { - name: 'CookieControl', - value: '{}', - path: '/', - domain: new URL(baseUrl).host, - }, // Civic UK banner - ]); - - // Kola Nuts with the QR code params and Stop #2 - await gotoWithoutCache( - `${baseUrl}/guides/exhibitions/ZrHvtxEAACYAWmfc?usingQRCode=true&stopNumber=2`, - page + // Jason with the QR code params and Stop #2 + await digitalGuide( + `${newJasonGuideId}?usingQRCode=true&stopNumber=2`, + context, + page, + [ + { + name: 'toggle_egWork', + value: 'true', + path: '/', + domain: new URL(baseUrl).host, + }, + { + name: 'CookieControl', + value: '{}', + path: '/', + domain: new URL(baseUrl).host, + }, // Civic UK banner + ] ); await expect( - page.getByRole('link', { name: 'Audio descriptive tour with' }) + page.getByRole('link', { name: 'Listen to audio' }).first() ).toHaveAttribute( 'href', - '/guides/exhibitions/ZrHvtxEAACYAWmfc/audio-without-descriptions/2' + `${newJasonGuideRelativeURL}/audio-without-descriptions/2` ); await expect( - page.getByRole('link', { name: 'British Sign Language tour' }) - ).toHaveAttribute('href', '/guides/exhibitions/ZrHvtxEAACYAWmfc/bsl/2'); + page.getByRole('link', { name: 'Watch British Sign Language' }).first() + ).toHaveAttribute('href', `${newJasonGuideRelativeURL}/bsl/2`); }); test('unless it is the first stop', async ({ context, page }) => { - await context.addCookies([ - { - name: 'toggle_egWork', - value: 'true', - path: '/', - domain: new URL(baseUrl).host, - }, - { - name: 'CookieControl', - value: '{}', - path: '/', - domain: new URL(baseUrl).host, - }, // Civic UK banner - ]); - - // Kola Nuts with the QR code params and Stop #1 - await gotoWithoutCache( - `${baseUrl}/guides/exhibitions/ZrHvtxEAACYAWmfc?usingQRCode=true&stopNumber=1`, - page + // Jason with the QR code params and Stop #1 + await digitalGuide( + `${newJasonGuideId}?usingQRCode=true&stopNumber=1`, + context, + page, + [ + { + name: 'toggle_egWork', + value: 'true', + path: '/', + domain: new URL(baseUrl).host, + }, + { + name: 'CookieControl', + value: '{}', + path: '/', + domain: new URL(baseUrl).host, + }, // Civic UK banner + ] ); await expect( - page.getByRole('link', { name: 'Audio descriptive tour with' }) + page.getByRole('link', { name: 'Listen to audio' }).first() ).toHaveAttribute( 'href', - '/guides/exhibitions/ZrHvtxEAACYAWmfc/audio-without-descriptions' + `${newJasonGuideRelativeURL}/audio-without-descriptions` ); await expect( - page.getByRole('link', { name: 'British Sign Language tour' }) - ).toHaveAttribute('href', '/guides/exhibitions/ZrHvtxEAACYAWmfc/bsl'); + page.getByRole('link', { name: 'Watch British Sign Language' }).first() + ).toHaveAttribute('href', `${newJasonGuideRelativeURL}/bsl`); }); }); }); diff --git a/playwright/test/helpers/contexts.ts b/playwright/test/helpers/contexts.ts index ff6c25ad86..d03e255986 100644 --- a/playwright/test/helpers/contexts.ts +++ b/playwright/test/helpers/contexts.ts @@ -54,7 +54,20 @@ export const gotoWithoutCache = async ( } }; -const createCookie = ({ name, value }: { name: string; value: string }) => { +export type CookieProps = { + name: string; + value: string; + path: string; + domain: string; +}; + +const createCookie = ({ + name, + value, +}: { + name: string; + value: string; +}): CookieProps => { return { name, value, @@ -265,6 +278,16 @@ const visualStory = async ( await gotoWithoutCache(`${baseUrl}/visual-stories/${id}`, page); }; +const digitalGuide = async ( + path: string, + context: BrowserContext, + page: Page, + cookies: CookieProps[] +): Promise => { + await context.addCookies([...requiredCookies, ...cookies]); + await gotoWithoutCache(`${baseUrl}/guides/exhibitions/${path}`, page); +}; + const whatsOn = async (context: BrowserContext, page: Page): Promise => { await context.addCookies(requiredCookies); await gotoWithoutCache(`${baseUrl}/whats-on`, page); @@ -303,6 +326,7 @@ export { isMobile, event, visualStory, + digitalGuide, whatsOn, mediaOffice, };