feat: convert all redirect tests to Playwright (#55031)
parent
c1b62b2fc2
commit
5a86bdde0f
|
@ -158,4 +158,4 @@ jobs:
|
|||
config: baseUrl=http://localhost:8000
|
||||
browser: ${{ matrix.browsers }}
|
||||
# Only run one test to keep the run time down.
|
||||
spec: 'cypress/e2e/default/learn/redirects/es6-to-basic-javascript.ts'
|
||||
spec: 'cypress/e2e/default/learn/challenges/failed-updates.ts'
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
describe('ES6 to Basic JavaScript redirects', () => {
|
||||
const basePath = '/learn/javascript-algorithms-and-data-structures';
|
||||
|
||||
it(`should redirect from ${basePath}/es6/explore-differences-between-the-var-and-let-keywords to ${basePath}/basic-javascript/explore-differences-between-the-var-and-let-keywords`, () => {
|
||||
cy.visit(
|
||||
`${basePath}/es6/explore-differences-between-the-var-and-let-keywords`
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
`${basePath}/basic-javascript/explore-differences-between-the-var-and-let-keywords`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it(`should redirect from ${basePath}/es6/declare-a-read-only-variable-with-the-const-keyword to ${basePath}/basic-javascript/declare-a-read-only-variable-with-the-const-keyword`, () => {
|
||||
cy.visit(
|
||||
`${basePath}/es6/declare-a-read-only-variable-with-the-const-keyword`
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
`${basePath}/basic-javascript/declare-a-read-only-variable-with-the-const-keyword`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
describe('Header to heading element redirect', () => {
|
||||
const basePath = '/learn/responsive-web-design/applied-visual-design';
|
||||
|
||||
it(`should redirect from ${basePath}/adjust-the-size-of-a-header-versus-a-paragraph-tag to ${basePath}/adjust-the-size-of-a-heading-element-versus-a-paragraph-element`, () => {
|
||||
cy.visit(`${basePath}/adjust-the-size-of-a-header-versus-a-paragraph-tag`);
|
||||
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
`${basePath}/adjust-the-size-of-a-heading-element-versus-a-paragraph-element`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,52 +0,0 @@
|
|||
const testLocations = {
|
||||
chalSuper: '/challenges/responsive-web-design',
|
||||
chalBlock: '/challenges/responsive-web-design/basic-html-and-html5',
|
||||
chalChallenge:
|
||||
// eslint-disable-next-line max-len
|
||||
'/challenges/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements',
|
||||
learnSuper: '/learn/responsive-web-design/',
|
||||
learnBlock: '/learn/responsive-web-design/basic-html-and-html5/',
|
||||
learnChallenge:
|
||||
// eslint-disable-next-line max-len
|
||||
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
|
||||
};
|
||||
|
||||
describe('challenges/superblock redirect', function () {
|
||||
it('redirects to learn/superblock', () => {
|
||||
cy.visit(testLocations.chalSuper);
|
||||
|
||||
cy.title().should(
|
||||
'eq',
|
||||
'Legacy Responsive Web Design Challenges | freeCodeCamp.org'
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(testLocations.learnSuper);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('challenges/superblock/block redirect', function () {
|
||||
it('redirects to learn/superblock/block', () => {
|
||||
cy.visit(testLocations.chalBlock);
|
||||
|
||||
cy.title().should('eq', 'Basic HTML and HTML5 | freeCodeCamp.org');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(testLocations.learnBlock);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('challenges/superblock/block/challenge redirect', function () {
|
||||
it('redirects to learn/superblock/block/challenge', () => {
|
||||
cy.visit(testLocations.chalChallenge);
|
||||
|
||||
cy.title().should(
|
||||
'eq',
|
||||
// eslint-disable-next-line max-len
|
||||
'Basic HTML and HTML5: Say Hello to HTML Elements | freeCodeCamp.org'
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(testLocations.learnChallenge);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -4,69 +4,74 @@ import { test, expect } from '@playwright/test';
|
|||
// Also, make sure that you have pm2 installed globally via: pnpm install -g pm2
|
||||
|
||||
const pathsToTest = [
|
||||
{ input: '/challenges', expected: '/learn' },
|
||||
{
|
||||
input: '/learn/front-end-libraries',
|
||||
expected: 'learn/front-end-development-libraries'
|
||||
},
|
||||
{
|
||||
input: '/learn/front-end-libraries/bootstrap',
|
||||
expected: 'learn/front-end-development-libraries/bootstrap'
|
||||
},
|
||||
{
|
||||
input: '/learn/front-end-libraries/front-end-libraries-projects',
|
||||
expected:
|
||||
'learn/front-end-development-libraries/front-end-development-libraries-projects'
|
||||
},
|
||||
{
|
||||
input:
|
||||
['/challenges', '/learn'],
|
||||
['/learn/front-end-libraries', 'learn/front-end-development-libraries'],
|
||||
[
|
||||
'/learn/front-end-libraries/bootstrap',
|
||||
'/learn/front-end-development-libraries/bootstrap'
|
||||
],
|
||||
[
|
||||
'/learn/front-end-libraries/front-end-libraries-projects',
|
||||
'/learn/front-end-development-libraries/front-end-development-libraries-projects'
|
||||
],
|
||||
[
|
||||
'/learn/front-end-libraries/front-end-libraries-projects/build-a-random-quote-machine',
|
||||
expected:
|
||||
'learn/front-end-development-libraries/front-end-development-libraries-projects/build-a-random-quote-machine'
|
||||
},
|
||||
{
|
||||
input: '/certification/certifieduser/front-end-libraries',
|
||||
expected: 'certification/certifieduser/front-end-development-libraries'
|
||||
},
|
||||
{
|
||||
input:
|
||||
'/learn/front-end-development-libraries/front-end-development-libraries-projects/build-a-random-quote-machine'
|
||||
],
|
||||
[
|
||||
'/certification/certifieduser/front-end-libraries',
|
||||
'/certification/certifieduser/front-end-development-libraries'
|
||||
],
|
||||
[
|
||||
'/learn/front-end-libraries/bootstrap/use-responsive-design-with-bootstrap-fluid-containers',
|
||||
expected:
|
||||
'learn/front-end-development-libraries/bootstrap/use-responsive-design-with-bootstrap-fluid-containers'
|
||||
},
|
||||
{
|
||||
input: '/learn/apis-and-microservices',
|
||||
expected: 'learn/back-end-development-and-apis'
|
||||
},
|
||||
{
|
||||
input: '/learn/apis-and-microservices/managing-packages-with-npm',
|
||||
expected: 'learn/back-end-development-and-apis/managing-packages-with-npm'
|
||||
},
|
||||
{
|
||||
input:
|
||||
'/learn/front-end-development-libraries/bootstrap/use-responsive-design-with-bootstrap-fluid-containers'
|
||||
],
|
||||
['/learn/apis-and-microservices', 'learn/back-end-development-and-apis'],
|
||||
[
|
||||
'/learn/apis-and-microservices/managing-packages-with-npm',
|
||||
'/learn/back-end-development-and-apis/managing-packages-with-npm'
|
||||
],
|
||||
[
|
||||
'/learn/apis-and-microservices/managing-packages-with-npm/how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package',
|
||||
expected:
|
||||
'learn/back-end-development-and-apis/managing-packages-with-npm/how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package'
|
||||
},
|
||||
{
|
||||
input: '/learn/apis-and-microservices/apis-and-microservices-projects',
|
||||
expected:
|
||||
'learn/back-end-development-and-apis/back-end-development-and-apis-projects'
|
||||
},
|
||||
{
|
||||
input:
|
||||
'/learn/back-end-development-and-apis/managing-packages-with-npm/how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package'
|
||||
],
|
||||
[
|
||||
'/learn/apis-and-microservices/apis-and-microservices-projects',
|
||||
'/learn/back-end-development-and-apis/back-end-development-and-apis-projects'
|
||||
],
|
||||
[
|
||||
'/learn/apis-and-microservices/apis-and-microservices-projects/timestamp-microservice',
|
||||
expected:
|
||||
'learn/back-end-development-and-apis/back-end-development-and-apis-projects/timestamp-microservice'
|
||||
},
|
||||
{
|
||||
input: '/certification/certifieduser/apis-and-microservices',
|
||||
expected: 'certification/certifieduser/back-end-development-and-apis'
|
||||
}
|
||||
'/learn/back-end-development-and-apis/back-end-development-and-apis-projects/timestamp-microservice'
|
||||
],
|
||||
[
|
||||
'/certification/certifieduser/apis-and-microservices',
|
||||
'/certification/certifieduser/back-end-development-and-apis'
|
||||
],
|
||||
[
|
||||
'/learn/responsive-web-design/applied-visual-design/adjust-the-size-of-a-header-versus-a-paragraph-tag',
|
||||
'/learn/responsive-web-design/applied-visual-design/adjust-the-size-of-a-heading-element-versus-a-paragraph-element'
|
||||
],
|
||||
[
|
||||
'/learn/javascript-algorithms-and-data-structures/es6/explore-differences-between-the-var-and-let-keywords',
|
||||
'/learn/javascript-algorithms-and-data-structures/basic-javascript/explore-differences-between-the-var-and-let-keywords'
|
||||
],
|
||||
[
|
||||
'/learn/javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword',
|
||||
'/learn/javascript-algorithms-and-data-structures/basic-javascript/declare-a-read-only-variable-with-the-const-keyword'
|
||||
],
|
||||
['/challenges/responsive-web-design', '/learn/responsive-web-design'],
|
||||
[
|
||||
'/challenges/responsive-web-design/basic-html-and-html5',
|
||||
'/learn/responsive-web-design/basic-html-and-html5'
|
||||
],
|
||||
[
|
||||
'/challenges/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements',
|
||||
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
|
||||
]
|
||||
];
|
||||
|
||||
test.describe('Legacy Challenge Path Redirection Tests', () => {
|
||||
for (const { input, expected } of pathsToTest) {
|
||||
for (const [input, expected] of pathsToTest) {
|
||||
test(`should redirect from ${input} to ${expected}`, async ({ page }) => {
|
||||
await page.goto(input);
|
||||
await expect(page).toHaveURL(new RegExp(`${expected}/?`));
|
||||
|
|
Loading…
Reference in New Issue