1- import { test , expect } from '@playwright/test' ;
1+ import { test , expect } from '@playwright/test' ;
22
3- const EXAMPLE = '01-lock' ;
43const BASE_URL = process . env . BASE_URL || 'http://localhost' ;
54
6- test . describe . serial ( '01-lock - Double-Click Protection' , ( ) => {
7- test . beforeEach ( async ( { request } ) => {
5+ test . describe . serial ( '01-global- lock - Double-Click Protection' , ( ) => {
6+ test . beforeEach ( async ( { request} ) => {
87 // Clear all Redis keys for this example
9- const response = await request . get ( `${ BASE_URL } /examples/ reset.php?example= ${ EXAMPLE } ` ) ;
8+ const response = await request . get ( `${ BASE_URL } /reset` ) ;
109 console . log ( 'Reset response:' , await response . json ( ) ) ;
1110 } ) ;
1211
13- test ( 'should display initial state correctly' , async ( { page } ) => {
14- await page . goto ( '/examples/01 -lock/' ) ;
12+ test ( 'should display initial state correctly' , async ( { page} ) => {
13+ await page . goto ( '/global -lock/' ) ;
1514
1615 await expect ( page . locator ( 'h1' ) ) . toHaveText ( 'Airlock: Double-Click Protection' ) ;
1716 await expect ( page . locator ( '#go' ) ) . toBeEnabled ( ) ;
1817 await expect ( page . locator ( '#status' ) ) . toBeEmpty ( ) ;
1918 } ) ;
2019
21- test ( 'should process action and show done state' , async ( { page } ) => {
22- await page . goto ( '/examples/01 -lock/' ) ;
20+ test ( 'should process action and show done state' , async ( { page} ) => {
21+ await page . goto ( '/global -lock/' ) ;
2322
2423 await page . locator ( '#go' ) . click ( ) ;
2524
@@ -28,12 +27,12 @@ test.describe.serial('01-lock - Double-Click Protection', () => {
2827 await expect ( page . locator ( '#status' ) ) . toHaveClass ( / w a i t / ) ;
2928
3029 // Wait for completion (5s work + buffer)
31- await expect ( page . locator ( '#status' ) ) . toContainText ( 'Done' , { timeout : 10000 } ) ;
30+ await expect ( page . locator ( '#status' ) ) . toContainText ( 'Done' , { timeout : 4000 } ) ;
3231 await expect ( page . locator ( '#status' ) ) . toHaveClass ( / o k / ) ;
3332 } ) ;
3433
35- test ( 'should block double-click with instant rejection' , async ( { page } ) => {
36- await page . goto ( '/examples/01 -lock/' ) ;
34+ test ( 'should block double-click with instant rejection' , async ( { page} ) => {
35+ await page . goto ( '/global -lock/' ) ;
3736
3837 // First click - starts processing
3938 await page . locator ( '#go' ) . click ( ) ;
@@ -45,7 +44,7 @@ test.describe.serial('01-lock - Double-Click Protection', () => {
4544 await expect ( page . locator ( '#status' ) ) . toHaveClass ( / e r r o r / ) ;
4645 } ) ;
4746
48- test ( 'second user should be blocked when lock is held' , async ( { browser } ) => {
47+ test ( 'second user should be blocked when lock is held' , async ( { browser} ) => {
4948 // Create two browser contexts (simulating two users)
5049 const context1 = await browser . newContext ( ) ;
5150 const context2 = await browser . newContext ( ) ;
@@ -54,18 +53,18 @@ test.describe.serial('01-lock - Double-Click Protection', () => {
5453
5554 try {
5655 // First user starts action
57- await page1 . goto ( '/examples/01 -lock/' ) ;
56+ await page1 . goto ( '/global -lock/' ) ;
5857 await page1 . locator ( '#go' ) . click ( ) ;
5958 await expect ( page1 . locator ( '#status' ) ) . toContainText ( 'Submitting' ) ;
6059
6160 // Second user tries to start - should be instantly blocked
62- await page2 . goto ( '/examples/01 -lock/' ) ;
61+ await page2 . goto ( '/global -lock/' ) ;
6362 await page2 . locator ( '#go' ) . click ( ) ;
6463 await expect ( page2 . locator ( '#status' ) ) . toContainText ( 'Already processing' ) ;
6564 await expect ( page2 . locator ( '#status' ) ) . toHaveClass ( / e r r o r / ) ;
6665
6766 // Wait for first user to complete
68- await expect ( page1 . locator ( '#status' ) ) . toContainText ( 'Done' , { timeout : 10000 } ) ;
67+ await expect ( page1 . locator ( '#status' ) ) . toContainText ( 'Done' , { timeout : 5000 } ) ;
6968
7069 // Second user can now start
7170 await page2 . locator ( '#go' ) . click ( ) ;
0 commit comments