From 6cc33adb8818dc3c4db4bc14d90f2a06ee9e2603 Mon Sep 17 00:00:00 2001 From: binit Date: Thu, 29 Jan 2026 01:08:47 +0530 Subject: [PATCH] feat: UI auth flow test --- playwright.config.ts | 2 +- tests/web/web-auth-flow.spec.ts | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/web/web-auth-flow.spec.ts diff --git a/playwright.config.ts b/playwright.config.ts index b6aede0..c463a33 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -37,7 +37,7 @@ export default defineConfig({ video: 'on', screenshot: 'only-on-failure', connectOptions: process.env.CI ? undefined : { - wsEndpoint: 'ws://127.0.0.1:3000/', + wsEndpoint: 'ws://127.0.0.1:3001/', }, }, diff --git a/tests/web/web-auth-flow.spec.ts b/tests/web/web-auth-flow.spec.ts new file mode 100644 index 0000000..84277b3 --- /dev/null +++ b/tests/web/web-auth-flow.spec.ts @@ -0,0 +1,53 @@ +import {test, expect} from "@playwright/test"; +import dotenv from "dotenv"; +import path from "path"; + +dotenv.config({ path: path.resolve(__dirname, '../../apps/api/.env.test') }); + +const getTestUser = () => { + return { + name: `UI Tester ${Date.now()}`, + email: `ui_test_${Date.now()}@example.com`, + password: 'Password123!' + } +} + +const USER = getTestUser(); + +test.describe('web auth flow test', ()=>{ + test.describe.configure({ mode: 'serial' }); + + test('register new user', async({page})=>{ + await page.goto('/signup'); + + const nameInput = page.getByLabel(/name/i); + const emailInput = page.getByLabel(/email/i); + const passwordInput = page.getByRole('textbox', { name: 'Password' }); + const submitRegBtn = page.getByRole('button', {name: /create/i}) + + await nameInput.fill(USER.name); + await emailInput.fill(USER.email); + await passwordInput.fill(USER.password); + + await submitRegBtn.click(); + + await page.waitForURL('/app') + await expect(page).toHaveURL('/app') + }) + + test('login existing user', async({page})=>{ + await page.goto('/login'); + + const emailInput = page.getByLabel(/email/i); + const passwordInput = page.getByRole('textbox', { name: 'Password' }); + const submitLoginBtn = page.getByRole('button', {name: /sign in/i}) + + await emailInput.fill(USER.email); + await passwordInput.fill(USER.password); + + await submitLoginBtn.click(); + + await page.waitForURL('/app') + await expect(page).toHaveURL('/app') + }) +})