11const { test, expect } = require ( '@playwright/test' ) ;
22
3- test ( 'hello world test' , async ( { page } ) => {
4- await page . goto ( 'http://localhost:3000' ) ; // Adjust the URL as needed
5- const title = await page . title ( ) ;
6- expect ( title ) . toBe ( 'Expected Title' ) ; // Replace with the expected title of your application
7- } ) ;
3+ // Simple smoke test to ensure the profile/login app is up
4+ test ( 'profile login page loads' , async ( { page } ) => {
5+ await page . goto ( 'http://localhost:3000/login' ) ;
6+ await expect ( page ) . toHaveTitle ( / D u n g e o n C r a w l e r - L o g i n / i) ;
7+ } ) ;
8+
9+ // Happy path: register -> login -> go to game client -> create party -> see Start Dungeon enabled
10+ test ( 'can register, login, open game, and create a party' , async ( { page } ) => {
11+ const unique = Date . now ( ) ;
12+ const username = `testuser_${ unique } ` ;
13+ const password = 'TestPass123!' ;
14+
15+ // Go to register page
16+ await page . goto ( 'http://localhost:3000/register' ) ;
17+
18+ // Fill and submit registration form
19+ await page . getByLabel ( / U s e r n a m e / i) . fill ( username ) ;
20+ await page . getByLabel ( / P a s s w o r d / i) . fill ( password ) ;
21+ await page . getByLabel ( / C o n f i r m P a s s w o r d / i) . fill ( password ) ;
22+ await page . getByRole ( 'button' , { name : / R e g i s t e r / i } ) . click ( ) ;
23+
24+ // After successful register, we should land on /home
25+ await page . waitForURL ( '**/home' ) ;
26+
27+ // From home, open the game client via the "⚔️ Enter Game" button
28+ const playButton = await page . getByRole ( 'button' , { name : / E n t e r G a m e / i } ) ;
29+ await playButton . click ( ) ;
30+
31+ // New tab/window with game client at 5173
32+ const [ gamePage ] = await Promise . all ( [
33+ page . context ( ) . waitForEvent ( 'page' ) ,
34+ ] ) ;
35+
36+ await gamePage . waitForLoadState ( 'domcontentloaded' ) ;
37+
38+ // Ensure we are on game client
39+ await expect ( gamePage ) . toHaveTitle ( / D u n g e o n C r a w l e r / i) ;
40+
41+ // Open Social tab
42+ await gamePage . getByRole ( 'button' , { name : 'Social' } ) . click ( ) ;
43+
44+ // Click "Create Party"
45+ await gamePage . getByRole ( 'button' , { name : / C r e a t e P a r t y / i } ) . click ( ) ;
46+
47+ // Wait for Start Dungeon button to appear and be enabled
48+ const startButton = await gamePage . getByRole ( 'button' , { name : / S t a r t D u n g e o n / i } ) ;
49+ await expect ( startButton ) . toBeEnabled ( ) ;
50+ } ) ;
0 commit comments