Skip to content

Commit

Permalink
test: legacy redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
raisedadead committed Sep 18, 2024
1 parent fb1e9f4 commit 3b3fa55
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/legacy-redirect.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { test, expect } from '@playwright/test';

const legacyRoutes = [
{ from: '/#/how-to-translate-files', to: '/how-to-translate-files/' },
{ from: '/#/how-to-setup-wsl', to: '/how-to-setup-wsl/' },
{
from: '/#/how-to-setup-freecodecamp-locally',
to: '/how-to-setup-freecodecamp-locally/'
},
{ from: '/#/devops', to: '/devops/' },
{
from: '/#/how-to-add-playwright-tests',
to: '/how-to-add-playwright-tests/'
}
];

test.describe('Legacy URL redirects', () => {
for (const route of legacyRoutes) {
test(`should redirect ${route.from} to ${route.to}`, async ({ page }) => {
await page.goto(route.from);
await expect(page).toHaveURL(route.to);
});
}

test('should handle query parameters in legacy URLs', async ({ page }) => {
await page.goto(
'/#/how-to-add-playwright-tests?id=run-the-playwright-tests'
);
await expect(page).toHaveURL(
'/how-to-add-playwright-tests/#run-the-playwright-tests'
);
});
});

0 comments on commit 3b3fa55

Please sign in to comment.