mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: convert adding development redirect tests to Playwright (#54897)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -1,98 +0,0 @@
|
||||
// These tests require the client to be built and served with additional
|
||||
// redirect configuration. The Cypress action in .github/workflows/cypress.yml
|
||||
// contains the necessary commands to do this.
|
||||
|
||||
describe('Legacy redirects', () => {
|
||||
it('should redirect from front-end-libraries to front-end-development-libraries', () => {
|
||||
cy.visit('learn/front-end-libraries');
|
||||
cy.url().should('include', 'learn/front-end-development-libraries');
|
||||
|
||||
cy.visit('learn/front-end-libraries/bootstrap');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/learn/front-end-development-libraries/bootstrap/'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit('learn/front-end-libraries/front-end-libraries-projects');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/learn/front-end-development-libraries/front-end-development-libraries-projects/'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit(
|
||||
'learn/front-end-libraries/front-end-libraries-projects/build-a-random-quote-machine'
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/learn/front-end-development-libraries/front-end-development-libraries-projects/build-a-random-quote-machine'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit('certification/certifieduser/front-end-libraries');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/certification/certifieduser/front-end-development-libraries'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit(
|
||||
'learn/front-end-libraries/bootstrap/use-responsive-design-with-bootstrap-fluid-containers'
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/learn/front-end-development-libraries/bootstrap/use-responsive-design-with-bootstrap-fluid-containers'
|
||||
);
|
||||
});
|
||||
// Bit of hack: but we need to make sure the page is fully loaded before
|
||||
// moving on.
|
||||
cy.get('.react-monaco-editor-container').should('be.visible');
|
||||
});
|
||||
|
||||
it('should redirect from /apis-and-microservices to /back-end-development-and-apis', () => {
|
||||
cy.visit('learn/apis-and-microservices');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq('/learn/back-end-development-and-apis/');
|
||||
});
|
||||
|
||||
cy.visit('learn/apis-and-microservices/managing-packages-with-npm');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/learn/back-end-development-and-apis/managing-packages-with-npm/'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit(
|
||||
'learn/apis-and-microservices/managing-packages-with-npm/how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package'
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/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'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit('learn/apis-and-microservices/apis-and-microservices-projects');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/learn/back-end-development-and-apis/back-end-development-and-apis-projects/'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit(
|
||||
'learn/apis-and-microservices/apis-and-microservices-projects/timestamp-microservice'
|
||||
);
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/learn/back-end-development-and-apis/back-end-development-and-apis-projects/timestamp-microservice'
|
||||
);
|
||||
});
|
||||
|
||||
cy.visit('certification/certifieduser/apis-and-microservices');
|
||||
cy.location().should(loc => {
|
||||
expect(loc.pathname).to.eq(
|
||||
'/certification/certifieduser/back-end-development-and-apis'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
// TODO: are there other paths that need tests?
|
||||
const pathsToTest = [{ input: '/challenges', expected: '/learn' }];
|
||||
|
||||
test.describe('Legacy Challenge Path Redirection Tests', () => {
|
||||
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}/?`));
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
// To run this test locally you will need to run: pnpm run start-ci;
|
||||
// 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:
|
||||
'/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-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/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/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'
|
||||
}
|
||||
];
|
||||
|
||||
test.describe('Legacy Challenge Path Redirection Tests', () => {
|
||||
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}/?`));
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user