🛂(frontend) redirect to correct url after login

If a user wanted to access a doc but was not logged in,
they would be redirected to the login page.
After logging in, they would be redirected to the home page.
This change makes it so that they are
redirected to the doc they originally wanted to access.

Usefull from the mail sent to the user to access the doc
they were invited to.
This commit is contained in:
Anthony LC
2024-08-16 14:51:42 +02:00
committed by Anthony LC
parent a925b0bedf
commit 0512af273c
9 changed files with 58 additions and 52 deletions

View File

@@ -1,10 +1,12 @@
import { expect, test } from '@playwright/test';
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
import { keyCloakSignIn } from './common';
test.describe('Doc Routing', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('checks alias docs url with homepage', async ({ page }) => {
await expect(page).toHaveURL('/');
@@ -14,9 +16,9 @@ test.describe('Doc Routing', () => {
await expect(buttonCreateHomepage).toBeVisible();
await page.goto('/docs');
await page.goto('/docs/');
await expect(buttonCreateHomepage).toBeVisible();
await expect(page).toHaveURL(/\/docs$/);
await expect(page).toHaveURL(/\/docs\/$/);
});
test('checks 404 on docs/[id] page', async ({ page }) => {
@@ -33,3 +35,16 @@ test.describe('Doc Routing', () => {
});
});
});
test.describe('Doc Routing: Not loggued', () => {
test.use({ storageState: { cookies: [], origins: [] } });
test('checks redirect to a doc after login', async ({
page,
browserName,
}) => {
await page.goto('/docs/mocked-document-id/');
await keyCloakSignIn(page, browserName);
await expect(page).toHaveURL(/\/docs\/mocked-document-id\/$/);
});
});