-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #616 from GuillaumeGomez/wait-false
Add `wait-for-document-property-false` and `wait-for-window-property-false` commands
- Loading branch information
Showing
45 changed files
with
1,703 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
tests/api-output/parseWaitForDocumentPropertyFalse/basic-1.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
instructions = [ | ||
] | ||
warnings = [ | ||
] | ||
wait = false |
5 changes: 5 additions & 0 deletions
5
tests/api-output/parseWaitForDocumentPropertyFalse/basic-2.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
instructions = [ | ||
] | ||
warnings = [ | ||
] | ||
wait = false |
68 changes: 68 additions & 0 deletions
68
tests/api-output/parseWaitForDocumentPropertyFalse/basic-3.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
68
tests/api-output/parseWaitForDocumentPropertyFalse/basic-4.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [ | ||
] |
1 change: 1 addition & 0 deletions
1
tests/api-output/parseWaitForDocumentPropertyFalse/basic-5.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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""" |
Oops, something went wrong.