-
-
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.
Add tests for
wait-for-document-property-false
and `wait-for-window…
…-property-false` commands
- Loading branch information
1 parent
97955d5
commit cb9f3a8
Showing
41 changed files
with
1,613 additions
and
2 deletions.
There are no files selected for viewing
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""" |
68 changes: 68 additions & 0 deletions
68
tests/api-output/parseWaitForDocumentPropertyFalse/basic-6.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-7.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 = []; | ||
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 = [ | ||
] |
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 = """expected a tuple or a JSON dict, found nothing""" |
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 = """expected a tuple or a JSON dict, found `hello` (an ident)""" |
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 = """unexpected ident `b`. Allowed idents are: [`null`]""" |
68 changes: 68 additions & 0 deletions
68
tests/api-output/parseWaitForDocumentPropertyFalse/extra-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,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 = [ | ||
] |
Oops, something went wrong.