Files
myeasycms-v2/apps/e2e/tests/authentication/auth.spec.ts
Giancarlo Buomprisco 2e20d3e76f 2.18.0: New Invitation flow, refactored Database Webhooks, new ShadCN UI Components (#384)
* Streamlined invitations flow
* Removed web hooks in favor of handling logic directly in server actions
* Added new Shadcn UI Components
2025-10-05 17:54:16 +08:00

94 lines
2.1 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { AuthPageObject } from './auth.po';
test.describe('Auth flow', () => {
test.describe.configure({ mode: 'serial' });
let email: string;
test('will sign-up and redirect to the home page', async ({ page }) => {
const auth = new AuthPageObject(page);
await auth.goToSignUp();
email = auth.createRandomEmail();
console.log(`Signing up with email ${email} ...`);
const signUp = auth.signUp({
email,
password: 'password',
repeatPassword: 'password',
});
const response = page.waitForResponse((resp) => {
return resp.url().includes('auth');
});
await Promise.all([signUp, response]);
await auth.visitConfirmEmailLink(email);
await page.waitForURL('**/home', {
timeout: 5_000,
});
});
test('will sign-in with the correct credentials', async ({ page }) => {
const auth = new AuthPageObject(page);
await auth.goToSignIn();
console.log(`Signing in with email ${email} ...`);
await auth.signIn({
email,
password: 'password',
});
await page.waitForURL('**/home');
});
test('will sign out using the dropdown', async ({ page }) => {
const auth = new AuthPageObject(page);
await page.goto('/home/settings');
await auth.signIn({
email: 'test@makerkit.dev',
password: 'testingpassword',
});
await page.waitForURL('/home/settings', {
timeout: 5_000,
});
await auth.signOut();
await page.waitForURL('/');
});
});
test.describe('Protected routes', () => {
test('when logged out, redirects to the correct page after sign in', async ({
page,
}) => {
const auth = new AuthPageObject(page);
const path = '/home/settings';
await page.goto(path);
await auth.loginAsUser({
email: 'test@makerkit.dev',
next: path,
});
});
test('will redirect to the sign-in page if not authenticated', async ({
page,
}) => {
await page.goto('/home/settings');
expect(page.url()).toContain('/auth/sign-in?next=/home/settings');
});
});