Skip to content
Open
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
22 changes: 22 additions & 0 deletions src/explore-education-statistics-frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ const nextConfig = {
},
];
},
async redirects() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Guy-HiveIT this approach looks good to me! You may or may not be aware that we also have a getRedirectUrl function in server.js, so I don't know if at some point in the future if the 2 methods should be more consolidated into a single approach where it makes sense to do so?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware of that! I don't know which ones will run first when a request comes in, but it probably does make sense to consolidate in one place. I think the server.js getRedirectUrl will have more flexibility but also looks less clear (and less standard, compared to the next recommended approach linked in the PR description).

I can try and move them to server.js now if you think that's best?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon it can be done outside of this PR, but thought I'd just make you aware :)

return [
{
source:
'/find-statistics/:publication/:page(data-guidance|prerelease-access-list)',
destination: '/find-statistics/:publication',
permanent: true,
},
{
source: '/find-statistics/:publication/:release/data-guidance',
destination:
'/find-statistics/:publication/:release/explore#data-guidance-section',
permanent: true,
},
{
source: '/find-statistics/:publication/:release/prerelease-access-list',
destination:
'/find-statistics/:publication/:release/help#pre-release-access-list-section',
permanent: true,
},
];
},
webpack(config, options) {
const { dev, isServer } = options;

Expand Down
31 changes: 31 additions & 0 deletions tests/robot-tests/tests/general_public/redirects_release.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
*** Settings ***
Resource ../libs/public-common.robot
Resource ../seed_data/seed_data_theme_1_constants.robot

Suite Setup user opens the browser
Suite Teardown user closes the browser
Test Setup fail test fast if required

Force Tags GeneralPublic Local Dev Test Preprod


*** Test Cases ***
Verify that deprecated publication data guidance and prerelease access pages redirect to release page
environment variable should be set PUBLIC_URL
user navigates to %{PUBLIC_URL}/find-statistics/${PUPIL_ABSENCE_PUBLICATION_SLUG}/data-guidance
user waits until page contains ${PUPIL_ABSENCE_PUBLICATION_TITLE}
user checks url equals %{PUBLIC_URL}${PUPIL_ABSENCE_PUBLICATION_RELATIVE_URL}
user navigates to %{PUBLIC_URL}/find-statistics/${PUPIL_ABSENCE_PUBLICATION_SLUG}/prerelease-access-list
user waits until page contains ${PUPIL_ABSENCE_PUBLICATION_TITLE}
user checks url equals %{PUBLIC_URL}${PUPIL_ABSENCE_PUBLICATION_RELATIVE_URL}

Verify that deprecated release data guidance page redirects to explore page
user navigates to %{PUBLIC_URL}${PUPIL_ABSENCE_PUBLICATION_RELATIVE_URL}/data-guidance
user waits until page contains ${PUPIL_ABSENCE_PUBLICATION_TITLE}
user checks url equals %{PUBLIC_URL}${PUPIL_ABSENCE_PUBLICATION_RELATIVE_URL}/explore#data-guidance-section

Verify that deprecated release prerelease access page redirects to help page
user navigates to %{PUBLIC_URL}${PUPIL_ABSENCE_PUBLICATION_RELATIVE_URL}/prerelease-access-list
user waits until page contains ${PUPIL_ABSENCE_PUBLICATION_TITLE}
user checks url equals
... %{PUBLIC_URL}${PUPIL_ABSENCE_PUBLICATION_RELATIVE_URL}/help#pre-release-access-list-section
2 changes: 1 addition & 1 deletion tests/robot-tests/tests/general_public/redirects_www.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Suite Setup user opens the browser
Suite Teardown user closes the browser
Test Setup fail test fast if required

Force Tags GeneralPublic Local
Force Tags GeneralPublic Local Dev


*** Test Cases ***
Expand Down