@@ -15,93 +15,120 @@ describe.runIf(isServe)('main', () => {
15
15
} )
16
16
17
17
test ( 'default import' , async ( ) => {
18
- expect ( await page . textContent ( '.full' ) ) . toBe ( stringified )
18
+ await expect . poll ( ( ) => page . textContent ( '.full' ) ) . toBe ( stringified )
19
19
} )
20
20
21
21
test ( 'named import' , async ( ) => {
22
- expect ( await page . textContent ( '.named' ) ) . toBe ( testJSON . msg )
22
+ await expect . poll ( ( ) => page . textContent ( '.named' ) ) . toBe ( testJSON . msg )
23
23
} )
24
24
25
25
test ( 'safe fetch' , async ( ) => {
26
26
expect ( await page . textContent ( '.safe-fetch' ) ) . toMatch ( 'KEY=safe' )
27
- expect ( await page . textContent ( '.safe-fetch-status' ) ) . toBe ( '200' )
27
+ await expect . poll ( ( ) => page . textContent ( '.safe-fetch-status' ) ) . toBe ( '200' )
28
28
} )
29
29
30
30
test ( 'safe fetch with query' , async ( ) => {
31
31
expect ( await page . textContent ( '.safe-fetch-query' ) ) . toMatch ( 'KEY=safe' )
32
- expect ( await page . textContent ( '.safe-fetch-query-status' ) ) . toBe ( '200' )
32
+ await expect
33
+ . poll ( ( ) => page . textContent ( '.safe-fetch-query-status' ) )
34
+ . toBe ( '200' )
33
35
} )
34
36
35
37
test ( 'safe fetch with special characters' , async ( ) => {
36
38
expect (
37
39
await page . textContent ( '.safe-fetch-subdir-special-characters' ) ,
38
40
) . toMatch ( 'KEY=safe' )
39
- expect (
40
- await page . textContent ( '.safe-fetch-subdir-special-characters-status' ) ,
41
- ) . toBe ( '200' )
41
+ await expect
42
+ . poll ( ( ) =>
43
+ page . textContent ( '.safe-fetch-subdir-special-characters-status' ) ,
44
+ )
45
+ . toBe ( '200' )
42
46
} )
43
47
44
48
test ( 'unsafe fetch' , async ( ) => {
45
49
expect ( await page . textContent ( '.unsafe-fetch' ) ) . toMatch ( '403 Restricted' )
46
- expect ( await page . textContent ( '.unsafe-fetch-status' ) ) . toBe ( '403' )
50
+ await expect
51
+ . poll ( ( ) => page . textContent ( '.unsafe-fetch-status' ) )
52
+ . toBe ( '403' )
47
53
} )
48
54
49
55
test ( 'unsafe fetch with special characters (#8498)' , async ( ) => {
50
- expect ( await page . textContent ( '.unsafe-fetch-8498' ) ) . toBe ( '' )
51
- expect ( await page . textContent ( '.unsafe-fetch-8498-status' ) ) . toBe ( '404' )
56
+ await expect . poll ( ( ) => page . textContent ( '.unsafe-fetch-8498' ) ) . toBe ( '' )
57
+ await expect
58
+ . poll ( ( ) => page . textContent ( '.unsafe-fetch-8498-status' ) )
59
+ . toBe ( '404' )
52
60
} )
53
61
54
62
test ( 'unsafe fetch with special characters 2 (#8498)' , async ( ) => {
55
- expect ( await page . textContent ( '.unsafe-fetch-8498-2' ) ) . toBe ( '' )
56
- expect ( await page . textContent ( '.unsafe-fetch-8498-2-status' ) ) . toBe ( '404' )
63
+ await expect . poll ( ( ) => page . textContent ( '.unsafe-fetch-8498-2' ) ) . toBe ( '' )
64
+ await expect
65
+ . poll ( ( ) => page . textContent ( '.unsafe-fetch-8498-2-status' ) )
66
+ . toBe ( '404' )
57
67
} )
58
68
59
69
test ( 'safe fs fetch' , async ( ) => {
60
- expect ( await page . textContent ( '.safe-fs-fetch' ) ) . toBe ( stringified )
61
- expect ( await page . textContent ( '.safe-fs-fetch-status' ) ) . toBe ( '200' )
70
+ await expect
71
+ . poll ( ( ) => page . textContent ( '.safe-fs-fetch' ) )
72
+ . toBe ( stringified )
73
+ await expect
74
+ . poll ( ( ) => page . textContent ( '.safe-fs-fetch-status' ) )
75
+ . toBe ( '200' )
62
76
} )
63
77
64
78
test ( 'safe fs fetch' , async ( ) => {
65
- expect ( await page . textContent ( '.safe-fs-fetch-query' ) ) . toBe ( stringified )
66
- expect ( await page . textContent ( '.safe-fs-fetch-query-status' ) ) . toBe ( '200' )
79
+ await expect
80
+ . poll ( ( ) => page . textContent ( '.safe-fs-fetch-query' ) )
81
+ . toBe ( stringified )
82
+ await expect
83
+ . poll ( ( ) => page . textContent ( '.safe-fs-fetch-query-status' ) )
84
+ . toBe ( '200' )
67
85
} )
68
86
69
87
test ( 'safe fs fetch with special characters' , async ( ) => {
70
- expect ( await page . textContent ( '.safe-fs-fetch-special-characters' ) ) . toBe (
71
- stringified ,
72
- )
73
- expect (
74
- await page . textContent ( '.safe-fs-fetch-special-characters-status' ) ,
75
- ) . toBe ( '200' )
88
+ await expect
89
+ . poll ( ( ) => page . textContent ( '.safe-fs-fetch-special-characters' ) )
90
+ . toBe ( stringified )
91
+ await expect
92
+ . poll ( ( ) => page . textContent ( '.safe-fs-fetch-special-characters-status' ) )
93
+ . toBe ( '200' )
76
94
} )
77
95
78
96
test ( 'unsafe fs fetch' , async ( ) => {
79
- expect ( await page . textContent ( '.unsafe-fs-fetch' ) ) . toBe ( '' )
80
- expect ( await page . textContent ( '.unsafe-fs-fetch-status' ) ) . toBe ( '403' )
97
+ await expect . poll ( ( ) => page . textContent ( '.unsafe-fs-fetch' ) ) . toBe ( '' )
98
+ await expect
99
+ . poll ( ( ) => page . textContent ( '.unsafe-fs-fetch-status' ) )
100
+ . toBe ( '403' )
81
101
} )
82
102
83
103
test ( 'unsafe fs fetch with special characters (#8498)' , async ( ) => {
84
- expect ( await page . textContent ( '.unsafe-fs-fetch-8498' ) ) . toBe ( '' )
85
- expect ( await page . textContent ( '.unsafe-fs-fetch-8498-status' ) ) . toBe ( '404' )
104
+ await expect . poll ( ( ) => page . textContent ( '.unsafe-fs-fetch-8498' ) ) . toBe ( '' )
105
+ await expect
106
+ . poll ( ( ) => page . textContent ( '.unsafe-fs-fetch-8498-status' ) )
107
+ . toBe ( '404' )
86
108
} )
87
109
88
110
test ( 'unsafe fs fetch with special characters 2 (#8498)' , async ( ) => {
89
- expect ( await page . textContent ( '.unsafe-fs-fetch-8498-2' ) ) . toBe ( '' )
90
- expect ( await page . textContent ( '.unsafe-fs-fetch-8498-2-status' ) ) . toBe ( '404' )
111
+ await expect
112
+ . poll ( ( ) => page . textContent ( '.unsafe-fs-fetch-8498-2' ) )
113
+ . toBe ( '' )
114
+ await expect
115
+ . poll ( ( ) => page . textContent ( '.unsafe-fs-fetch-8498-2-status' ) )
116
+ . toBe ( '404' )
91
117
} )
92
118
93
119
test ( 'nested entry' , async ( ) => {
94
- expect ( await page . textContent ( '.nested-entry' ) ) . toBe ( 'foobar' )
120
+ await expect . poll ( ( ) => page . textContent ( '.nested-entry' ) ) . toBe ( 'foobar' )
95
121
} )
96
122
97
123
test ( 'denied' , async ( ) => {
98
- expect ( await page . textContent ( '.unsafe-dotenv' ) ) . toBe ( '403' )
124
+ await expect . poll ( ( ) => page . textContent ( '.unsafe-dotenv' ) ) . toBe ( '403' )
99
125
} )
100
126
101
127
test ( 'denied EnV casing' , async ( ) => {
102
128
// It is 403 in case insensitive system, 404 in others
103
- const code = await page . textContent ( '.unsafe-dotEnV-casing' )
104
- expect ( code === '403' || code === '404' ) . toBeTruthy ( )
129
+ await expect
130
+ . poll ( ( ) => page . textContent ( '.unsafe-dotEnV-casing' ) )
131
+ . toStrictEqual ( expect . toBeOneOf ( [ '403' , '404' ] ) )
105
132
} )
106
133
} )
107
134
0 commit comments