Skip to content

Commit

Permalink
Add tests for wait-for-document-property-false and `wait-for-window…
Browse files Browse the repository at this point in the history
…-property-false` commands
  • Loading branch information
GuillaumeGomez committed Sep 26, 2024
1 parent 97955d5 commit cb9f3a8
Show file tree
Hide file tree
Showing 41 changed files with 1,613 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instructions = [
]
warnings = [
]
wait = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instructions = [
]
warnings = [
]
wait = false
68 changes: 68 additions & 0 deletions tests/api-output/parseWaitForDocumentPropertyFalse/basic-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
instructions = [
"""const timeLimit = page.getDefaultTimeout();
const timeAdd = 50;
let allTime = 0;
let property = null;
while (true) {
property = await page.evaluate(() => {
function checkObjectPaths(object, path, callback, notFoundCallback) {
const found = [];
for (const subPath of path) {
found.push(subPath);
if (object === undefined || object === null) {
notFoundCallback(found);
return;
}
object = object[subPath];
}
callback(object);
}
const errors = [];
const propertyDict = [[[\"a\"],\"b\"]];
const undefProps = [];
for (const prop of undefProps) {
checkObjectPaths(document, prop, val => {
if (val !== undefined && val !== null) {
const p = prop.map(p => `\"${p}\"`).join('.');
errors.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\");
}
}, _notFound => {},
);
}
for (const [propertyKey, propertyValue] of propertyDict) {
checkObjectPaths(document, propertyKey, val => {
if (val === undefined) {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
return;
}
const property = String(val);
if (property !== propertyValue) {
errors.push(\"expected `\" + propertyValue + \"` for document property `\" + propertyKey + \"`, found `\" + property + \"`\");
}
}, _notFound => {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
});
}
return errors;
});
if (property.length !== 0) {
break;
}
await new Promise(r => setTimeout(r, timeAdd));
if (timeLimit === 0) {
continue;
}
allTime += timeAdd;
if (allTime >= timeLimit) {
const errs = property.join(\", \");
throw new Error(\"The document properties still all match\");
}
}""",
]
wait = false
checkResult = true
warnings = [
]
68 changes: 68 additions & 0 deletions tests/api-output/parseWaitForDocumentPropertyFalse/basic-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
instructions = [
"""const timeLimit = page.getDefaultTimeout();
const timeAdd = 50;
let allTime = 0;
let property = null;
while (true) {
property = await page.evaluate(() => {
function checkObjectPaths(object, path, callback, notFoundCallback) {
const found = [];
for (const subPath of path) {
found.push(subPath);
if (object === undefined || object === null) {
notFoundCallback(found);
return;
}
object = object[subPath];
}
callback(object);
}
const errors = [];
const propertyDict = [[[\"a\"],\"b\"]];
const undefProps = [];
for (const prop of undefProps) {
checkObjectPaths(document, prop, val => {
if (val !== undefined && val !== null) {
const p = prop.map(p => `\"${p}\"`).join('.');
errors.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\");
}
}, _notFound => {},
);
}
for (const [propertyKey, propertyValue] of propertyDict) {
checkObjectPaths(document, propertyKey, val => {
if (val === undefined) {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
return;
}
const property = String(val);
if (property !== propertyValue) {
errors.push(\"expected `\" + propertyValue + \"` for document property `\" + propertyKey + \"`, found `\" + property + \"`\");
}
}, _notFound => {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
});
}
return errors;
});
if (property.length !== 0) {
break;
}
await new Promise(r => setTimeout(r, timeAdd));
if (timeLimit === 0) {
continue;
}
allTime += timeAdd;
if (allTime >= timeLimit) {
const errs = property.join(\", \");
throw new Error(\"The document properties still all match\");
}
}""",
]
wait = false
checkResult = true
warnings = [
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error = """recursive types (`{\"b\": \"c\"}`) are not allowed as value in this JSON dict"""
68 changes: 68 additions & 0 deletions tests/api-output/parseWaitForDocumentPropertyFalse/basic-6.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
instructions = [
"""const timeLimit = page.getDefaultTimeout();
const timeAdd = 50;
let allTime = 0;
let property = null;
while (true) {
property = await page.evaluate(() => {
function checkObjectPaths(object, path, callback, notFoundCallback) {
const found = [];
for (const subPath of path) {
found.push(subPath);
if (object === undefined || object === null) {
notFoundCallback(found);
return;
}
object = object[subPath];
}
callback(object);
}
const errors = [];
const propertyDict = [[[\"\\\"a\"],\"\\'b\"]];
const undefProps = [];
for (const prop of undefProps) {
checkObjectPaths(document, prop, val => {
if (val !== undefined && val !== null) {
const p = prop.map(p => `\"${p}\"`).join('.');
errors.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\");
}
}, _notFound => {},
);
}
for (const [propertyKey, propertyValue] of propertyDict) {
checkObjectPaths(document, propertyKey, val => {
if (val === undefined) {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
return;
}
const property = String(val);
if (property !== propertyValue) {
errors.push(\"expected `\" + propertyValue + \"` for document property `\" + propertyKey + \"`, found `\" + property + \"`\");
}
}, _notFound => {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
});
}
return errors;
});
if (property.length !== 0) {
break;
}
await new Promise(r => setTimeout(r, timeAdd));
if (timeLimit === 0) {
continue;
}
allTime += timeAdd;
if (allTime >= timeLimit) {
const errs = property.join(\", \");
throw new Error(\"The document properties still all match\");
}
}""",
]
wait = false
checkResult = true
warnings = [
]
68 changes: 68 additions & 0 deletions tests/api-output/parseWaitForDocumentPropertyFalse/basic-7.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
instructions = [
"""const timeLimit = page.getDefaultTimeout();
const timeAdd = 50;
let allTime = 0;
let property = null;
while (true) {
property = await page.evaluate(() => {
function checkObjectPaths(object, path, callback, notFoundCallback) {
const found = [];
for (const subPath of path) {
found.push(subPath);
if (object === undefined || object === null) {
notFoundCallback(found);
return;
}
object = object[subPath];
}
callback(object);
}
const errors = [];
const propertyDict = [];
const undefProps = [[\"a\"]];
for (const prop of undefProps) {
checkObjectPaths(document, prop, val => {
if (val !== undefined && val !== null) {
const p = prop.map(p => `\"${p}\"`).join('.');
errors.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\");
}
}, _notFound => {},
);
}
for (const [propertyKey, propertyValue] of propertyDict) {
checkObjectPaths(document, propertyKey, val => {
if (val === undefined) {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
return;
}
const property = String(val);
if (property !== propertyValue) {
errors.push(\"expected `\" + propertyValue + \"` for document property `\" + propertyKey + \"`, found `\" + property + \"`\");
}
}, _notFound => {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
});
}
return errors;
});
if (property.length !== 0) {
break;
}
await new Promise(r => setTimeout(r, timeAdd));
if (timeLimit === 0) {
continue;
}
allTime += timeAdd;
if (allTime >= timeLimit) {
const errs = property.join(\", \");
throw new Error(\"The document properties still all match\");
}
}""",
]
wait = false
checkResult = true
warnings = [
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error = """expected a tuple or a JSON dict, found nothing"""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error = """expected a tuple or a JSON dict, found `hello` (an ident)"""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error = """unexpected ident `b`. Allowed idents are: [`null`]"""
68 changes: 68 additions & 0 deletions tests/api-output/parseWaitForDocumentPropertyFalse/extra-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
instructions = [
"""const timeLimit = page.getDefaultTimeout();
const timeAdd = 50;
let allTime = 0;
let property = null;
while (true) {
property = await page.evaluate(() => {
function checkObjectPaths(object, path, callback, notFoundCallback) {
const found = [];
for (const subPath of path) {
found.push(subPath);
if (object === undefined || object === null) {
notFoundCallback(found);
return;
}
object = object[subPath];
}
callback(object);
}
const errors = [];
const propertyDict = [[[\"a\"],\"b\"]];
const undefProps = [];
for (const prop of undefProps) {
checkObjectPaths(document, prop, val => {
if (val !== undefined && val !== null) {
const p = prop.map(p => `\"${p}\"`).join('.');
errors.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\");
}
}, _notFound => {},
);
}
for (const [propertyKey, propertyValue] of propertyDict) {
checkObjectPaths(document, propertyKey, val => {
if (val === undefined) {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
return;
}
const property = String(val);
if (!property.startsWith(propertyValue)) {
errors.push(\"document property `\" + propertyKey + \"` (`\" + property + \"`) doesn't start with `\" + propertyValue + \"` (for STARTS_WITH check)\");
}
}, _notFound => {
const p = propertyKey.map(p => `\"${p}\"`).join('.');
errors.push(\"document doesn't have a property `\" + p + \"`\");
});
}
return errors;
});
if (property.length !== 0) {
break;
}
await new Promise(r => setTimeout(r, timeAdd));
if (timeLimit === 0) {
continue;
}
allTime += timeAdd;
if (allTime >= timeLimit) {
const errs = property.join(\", \");
throw new Error(\"The document properties still all match\");
}
}""",
]
wait = false
checkResult = true
warnings = [
]
Loading

0 comments on commit cb9f3a8

Please sign in to comment.