Skip to content

Commit 42cb324

Browse files
Add tests for wait-for-size-false command
1 parent fbd1d14 commit 42cb324

34 files changed

+1047
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
instructions = [
2+
"""const timeLimit = page.getDefaultTimeout();
3+
const timeAdd = 50;
4+
let allTime = 0;
5+
let assertSize = null;
6+
while (true) {
7+
while (true) {
8+
assertSize = await page.$$(\"a\");
9+
if (assertSize.length !== 0) {
10+
assertSize = assertSize[0];
11+
break;
12+
}
13+
await new Promise(r => setTimeout(r, timeAdd));
14+
if (timeLimit === 0) {
15+
continue;
16+
}
17+
allTime += timeAdd;
18+
if (allTime >= timeLimit) {
19+
throw new Error(\"The CSS selector \\\"a\\\" was not found\");
20+
}
21+
}
22+
async function checkElemSize(elem) {
23+
return await elem.evaluate(e => {
24+
const innerErrors = [];
25+
const height = e.offsetHeight;
26+
const width = e.offsetWidth;
27+
28+
return innerErrors;
29+
});
30+
}
31+
const errors = [];
32+
errors.push(...await checkElemSize(assertSize));
33+
if (errors.length !== 0) {
34+
break;
35+
}
36+
37+
await new Promise(r => setTimeout(r, timeAdd));
38+
if (timeLimit === 0) {
39+
continue;
40+
}
41+
allTime += timeAdd;
42+
if (allTime >= timeLimit) {
43+
const err = errors.join(\", \");
44+
throw new Error(\"All checks still pass\");
45+
}
46+
}""",
47+
]
48+
wait = false
49+
warnings = [
50+
]
51+
checkResult = true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
instructions = [
2+
"""const timeLimit = page.getDefaultTimeout();
3+
const timeAdd = 50;
4+
let allTime = 0;
5+
let assertSize = null;
6+
while (true) {
7+
while (true) {
8+
assertSize = await page.$$(\"a\");
9+
if (assertSize.length !== 0) {
10+
assertSize = assertSize[0];
11+
break;
12+
}
13+
await new Promise(r => setTimeout(r, timeAdd));
14+
if (timeLimit === 0) {
15+
continue;
16+
}
17+
allTime += timeAdd;
18+
if (allTime >= timeLimit) {
19+
throw new Error(\"The CSS selector \\\"a\\\" was not found\");
20+
}
21+
}
22+
async function checkElemSize(elem) {
23+
return await elem.evaluate(e => {
24+
const innerErrors = [];
25+
const height = e.offsetHeight;
26+
const width = e.offsetWidth;
27+
if (width !== 1) {
28+
innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\");
29+
}
30+
return innerErrors;
31+
});
32+
}
33+
const errors = [];
34+
errors.push(...await checkElemSize(assertSize));
35+
if (errors.length !== 0) {
36+
break;
37+
}
38+
39+
await new Promise(r => setTimeout(r, timeAdd));
40+
if (timeLimit === 0) {
41+
continue;
42+
}
43+
allTime += timeAdd;
44+
if (allTime >= timeLimit) {
45+
const err = errors.join(\", \");
46+
throw new Error(\"All checks still pass\");
47+
}
48+
}""",
49+
]
50+
wait = false
51+
warnings = [
52+
]
53+
checkResult = true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
instructions = [
2+
"""const timeLimit = page.getDefaultTimeout();
3+
const timeAdd = 50;
4+
let allTime = 0;
5+
let assertSize = null;
6+
while (true) {
7+
while (true) {
8+
assertSize = await page.$$(\"a\");
9+
if (assertSize.length !== 0) {
10+
break;
11+
}
12+
await new Promise(r => setTimeout(r, timeAdd));
13+
if (timeLimit === 0) {
14+
continue;
15+
}
16+
allTime += timeAdd;
17+
if (allTime >= timeLimit) {
18+
throw new Error(\"The CSS selector \\\"a\\\" was not found\");
19+
}
20+
}
21+
async function checkElemSize(elem) {
22+
return await elem.evaluate(e => {
23+
const innerErrors = [];
24+
const height = e.offsetHeight;
25+
const width = e.offsetWidth;
26+
if (width !== 1) {
27+
innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\");
28+
}
29+
return innerErrors;
30+
});
31+
}
32+
const errors = [];
33+
for (const elem of assertSize) {
34+
errors.push(...await checkElemSize(elem));
35+
if (errors.length !== 0) {
36+
break;
37+
}
38+
}
39+
if (errors.length !== 0) {
40+
break;
41+
}
42+
43+
await new Promise(r => setTimeout(r, timeAdd));
44+
if (timeLimit === 0) {
45+
continue;
46+
}
47+
allTime += timeAdd;
48+
if (allTime >= timeLimit) {
49+
const err = errors.join(\", \");
50+
throw new Error(\"All checks still pass\");
51+
}
52+
}""",
53+
]
54+
wait = false
55+
warnings = [
56+
]
57+
checkResult = true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
instructions = [
2+
"""const timeLimit = page.getDefaultTimeout();
3+
const timeAdd = 50;
4+
let allTime = 0;
5+
let assertSize = null;
6+
while (true) {
7+
while (true) {
8+
assertSize = await page.$$(\"a\");
9+
if (assertSize.length !== 0) {
10+
assertSize = assertSize[0];
11+
break;
12+
}
13+
await new Promise(r => setTimeout(r, timeAdd));
14+
if (timeLimit === 0) {
15+
continue;
16+
}
17+
allTime += timeAdd;
18+
if (allTime >= timeLimit) {
19+
throw new Error(\"The CSS selector \\\"a\\\" was not found\");
20+
}
21+
}
22+
async function checkElemSize(elem) {
23+
return await elem.evaluate(e => {
24+
const innerErrors = [];
25+
const height = e.offsetHeight;
26+
const width = e.offsetWidth;
27+
if (height !== 1) {
28+
innerErrors.push(\"expected a height of `1`, found `\" + height + \"`\");
29+
}
30+
return innerErrors;
31+
});
32+
}
33+
const errors = [];
34+
errors.push(...await checkElemSize(assertSize));
35+
if (errors.length !== 0) {
36+
break;
37+
}
38+
39+
await new Promise(r => setTimeout(r, timeAdd));
40+
if (timeLimit === 0) {
41+
continue;
42+
}
43+
allTime += timeAdd;
44+
if (allTime >= timeLimit) {
45+
const err = errors.join(\", \");
46+
throw new Error(\"All checks still pass\");
47+
}
48+
}""",
49+
]
50+
wait = false
51+
warnings = [
52+
]
53+
checkResult = true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
instructions = [
2+
"""const timeLimit = page.getDefaultTimeout();
3+
const timeAdd = 50;
4+
let allTime = 0;
5+
let assertSize = null;
6+
while (true) {
7+
while (true) {
8+
assertSize = await page.$$(\"a\");
9+
if (assertSize.length !== 0) {
10+
break;
11+
}
12+
await new Promise(r => setTimeout(r, timeAdd));
13+
if (timeLimit === 0) {
14+
continue;
15+
}
16+
allTime += timeAdd;
17+
if (allTime >= timeLimit) {
18+
throw new Error(\"The CSS selector \\\"a\\\" was not found\");
19+
}
20+
}
21+
async function checkElemSize(elem) {
22+
return await elem.evaluate(e => {
23+
const innerErrors = [];
24+
const height = e.offsetHeight;
25+
const width = e.offsetWidth;
26+
if (height !== 1) {
27+
innerErrors.push(\"expected a height of `1`, found `\" + height + \"`\");
28+
}
29+
return innerErrors;
30+
});
31+
}
32+
const errors = [];
33+
for (const elem of assertSize) {
34+
errors.push(...await checkElemSize(elem));
35+
if (errors.length !== 0) {
36+
break;
37+
}
38+
}
39+
if (errors.length !== 0) {
40+
break;
41+
}
42+
43+
await new Promise(r => setTimeout(r, timeAdd));
44+
if (timeLimit === 0) {
45+
continue;
46+
}
47+
allTime += timeAdd;
48+
if (allTime >= timeLimit) {
49+
const err = errors.join(\", \");
50+
throw new Error(\"All checks still pass\");
51+
}
52+
}""",
53+
]
54+
wait = false
55+
warnings = [
56+
]
57+
checkResult = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error = """expected a JSON dict, found `\"b\"` (a string) (second element of the tuple)"""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error = """unexpected key `\"z\"`, allowed keys are: [`height`, `width`] (second element of the tuple)"""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error = """expected a JSON dict, found `\"b\"` (a string) (second element of the tuple)"""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error = """expected `,` or `)` after `\"b\"`, found `\"c\"`"""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error = """expected `,` or `)` after `\"b\"`, found `\"c\"`"""

0 commit comments

Comments
 (0)