File tree 4 files changed +53
-0
lines changed
4 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 48
48
name : playwright-report
49
49
path : playwright-report/
50
50
retention-days : 30
51
+ - name : Run playwright test (concurrency)
52
+ run : yarn playwright test mesop/tests/e2e/concurrency/state_test.ts --repeat-each=48 --workers=16
53
+ - uses : actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
54
+ if : always()
55
+ with :
56
+ name : playwright-report
57
+ path : playwright-report/
58
+ retention-days : 30
51
59
- name : Run playwright test with memory state session
52
60
run : MESOP_STATE_SESSION_BACKEND=memory yarn playwright test
53
61
- uses : actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
Original file line number Diff line number Diff line change 6
6
from mesop .examples import buttons as buttons
7
7
from mesop .examples import checkbox_and_radio as checkbox_and_radio
8
8
from mesop .examples import composite as composite
9
+ from mesop .examples import concurrency_state as concurrency_state
9
10
from mesop .examples import custom_font as custom_font
10
11
from mesop .examples import dict_state as dict_state
11
12
from mesop .examples import docs as docs
Original file line number Diff line number Diff line change
1
+ import mesop as me
2
+
3
+
4
+ @me .page (path = "/concurrency_state" )
5
+ def page ():
6
+ me .text ("concurrency_state" )
7
+ me .input (label = "State input" , on_input = on_input )
8
+ me .text ("Input: " + me .state (State ).input )
9
+
10
+
11
+ @me .stateclass
12
+ class State :
13
+ input : str
14
+
15
+
16
+ def on_input (e : me .InputEvent ):
17
+ me .state (State ).input = e .value
Original file line number Diff line number Diff line change
1
+ /**
2
+ * The purpose of this test is to ensure that sessions have proper
3
+ * state isolation, particularly under high concurrency.
4
+ *
5
+ * Run test as:
6
+ * yarn playwright test mesop/tests/e2e/concurrency/state_test.ts --repeat-each=48 --workers=16
7
+ */
8
+ import { test , expect } from '@playwright/test' ;
9
+
10
+ test ( 'state updates correctly' , async ( { page} ) => {
11
+ await page . goto ( '/concurrency_state' ) ;
12
+ const randomString = generateRandomString ( 16 ) ;
13
+ await page . getByLabel ( 'State input' ) . fill ( randomString ) ;
14
+ await expect ( page . getByText ( 'Input: ' + randomString ) ) . toBeVisible ( {
15
+ timeout : 15000 ,
16
+ } ) ;
17
+ } ) ;
18
+
19
+ function generateRandomString ( length : number ) {
20
+ const characters =
21
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;
22
+ let result = '' ;
23
+ for ( let i = 0 ; i < length ; i ++ ) {
24
+ result += characters . charAt ( Math . floor ( Math . random ( ) * characters . length ) ) ;
25
+ }
26
+ return result ;
27
+ }
You can’t perform that action at this time.
0 commit comments