-
-
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-property-false
command
- Loading branch information
1 parent
82d021c
commit 0afaa70
Showing
25 changed files
with
1,120 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
instructions = [ | ||
"""async function checkPropForElem(elem) { | ||
return await elem.evaluate(e => { | ||
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 nonMatchingProps = []; | ||
const parseWaitForPropDict = []; | ||
const nullProps = []; | ||
for (const prop of nullProps) { | ||
checkObjectPaths(e, prop, val => { | ||
if (val !== undefined && val !== null) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\"); | ||
return; | ||
} | ||
}, _notFound => { | ||
}); | ||
} | ||
for (const [parseWaitForPropKey, parseWaitForPropValue] of parseWaitForPropDict) { | ||
checkObjectPaths(e, parseWaitForPropKey, val => { | ||
if (val === undefined) { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
return; | ||
} | ||
if (val !== parseWaitForPropValue) { | ||
nonMatchingProps.push(\"expected `\" + parseWaitForPropValue + \"` for property `\" + parseWaitForPropKey + \"`, found `\" + val + \"`\"); | ||
} | ||
}, _notFound => { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
}); | ||
} | ||
return nonMatchingProps; | ||
}); | ||
} | ||
const timeLimit = page.getDefaultTimeout(); | ||
const timeAdd = 50; | ||
let allTime = 0; | ||
let parseWaitForProp = null; | ||
while (true) { | ||
while (true) { | ||
parseWaitForProp = await page.$$(\"a\"); | ||
if (parseWaitForProp.length !== 0) { | ||
parseWaitForProp = parseWaitForProp[0]; | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
throw new Error(\"The CSS selector \\\"a\\\" was not found\"); | ||
} | ||
} | ||
const nonMatchingProps = await checkPropForElem(parseWaitForProp); | ||
if (nonMatchingProps.length !== 0) { | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
const props = nonMatchingProps.join(\", \"); | ||
throw new Error(\"All properties still match\"); | ||
} | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] | ||
checkResult = true |
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,88 @@ | ||
instructions = [ | ||
"""async function checkPropForElem(elem) { | ||
return await elem.evaluate(e => { | ||
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 nonMatchingProps = []; | ||
const parseWaitForPropDict = [[[\"x\"],\"1\"]]; | ||
const nullProps = []; | ||
for (const prop of nullProps) { | ||
checkObjectPaths(e, prop, val => { | ||
if (val !== undefined && val !== null) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\"); | ||
return; | ||
} | ||
}, _notFound => { | ||
}); | ||
} | ||
for (const [parseWaitForPropKey, parseWaitForPropValue] of parseWaitForPropDict) { | ||
checkObjectPaths(e, parseWaitForPropKey, val => { | ||
if (val === undefined) { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
return; | ||
} | ||
if (val !== parseWaitForPropValue) { | ||
nonMatchingProps.push(\"expected `\" + parseWaitForPropValue + \"` for property `\" + parseWaitForPropKey + \"`, found `\" + val + \"`\"); | ||
} | ||
}, _notFound => { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
}); | ||
} | ||
return nonMatchingProps; | ||
}); | ||
} | ||
const timeLimit = page.getDefaultTimeout(); | ||
const timeAdd = 50; | ||
let allTime = 0; | ||
let parseWaitForProp = null; | ||
while (true) { | ||
while (true) { | ||
parseWaitForProp = await page.$$(\"a\"); | ||
if (parseWaitForProp.length !== 0) { | ||
parseWaitForProp = parseWaitForProp[0]; | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
throw new Error(\"The CSS selector \\\"a\\\" was not found\"); | ||
} | ||
} | ||
const nonMatchingProps = await checkPropForElem(parseWaitForProp); | ||
if (nonMatchingProps.length !== 0) { | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
const props = nonMatchingProps.join(\", \"); | ||
throw new Error(\"All properties still match\"); | ||
} | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] | ||
checkResult = true |
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,88 @@ | ||
instructions = [ | ||
"""async function checkPropForElem(elem) { | ||
return await elem.evaluate(e => { | ||
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 nonMatchingProps = []; | ||
const parseWaitForPropDict = [[[\"x\"],\"1\"],[[\"y\"],\"2\"]]; | ||
const nullProps = []; | ||
for (const prop of nullProps) { | ||
checkObjectPaths(e, prop, val => { | ||
if (val !== undefined && val !== null) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\"); | ||
return; | ||
} | ||
}, _notFound => { | ||
}); | ||
} | ||
for (const [parseWaitForPropKey, parseWaitForPropValue] of parseWaitForPropDict) { | ||
checkObjectPaths(e, parseWaitForPropKey, val => { | ||
if (val === undefined) { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
return; | ||
} | ||
if (val !== parseWaitForPropValue) { | ||
nonMatchingProps.push(\"expected `\" + parseWaitForPropValue + \"` for property `\" + parseWaitForPropKey + \"`, found `\" + val + \"`\"); | ||
} | ||
}, _notFound => { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
}); | ||
} | ||
return nonMatchingProps; | ||
}); | ||
} | ||
const timeLimit = page.getDefaultTimeout(); | ||
const timeAdd = 50; | ||
let allTime = 0; | ||
let parseWaitForProp = null; | ||
while (true) { | ||
while (true) { | ||
parseWaitForProp = await page.$$(\"a\"); | ||
if (parseWaitForProp.length !== 0) { | ||
parseWaitForProp = parseWaitForProp[0]; | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
throw new Error(\"The CSS selector \\\"a\\\" was not found\"); | ||
} | ||
} | ||
const nonMatchingProps = await checkPropForElem(parseWaitForProp); | ||
if (nonMatchingProps.length !== 0) { | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
const props = nonMatchingProps.join(\", \"); | ||
throw new Error(\"All properties still match\"); | ||
} | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] | ||
checkResult = true |
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,88 @@ | ||
instructions = [ | ||
"""async function checkPropForElem(elem) { | ||
return await elem.evaluate(e => { | ||
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 nonMatchingProps = []; | ||
const parseWaitForPropDict = [[[\"color\"],\"blue\"]]; | ||
const nullProps = []; | ||
for (const prop of nullProps) { | ||
checkObjectPaths(e, prop, val => { | ||
if (val !== undefined && val !== null) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\"); | ||
return; | ||
} | ||
}, _notFound => { | ||
}); | ||
} | ||
for (const [parseWaitForPropKey, parseWaitForPropValue] of parseWaitForPropDict) { | ||
checkObjectPaths(e, parseWaitForPropKey, val => { | ||
if (val === undefined) { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
return; | ||
} | ||
if (val !== parseWaitForPropValue) { | ||
nonMatchingProps.push(\"expected `\" + parseWaitForPropValue + \"` for property `\" + parseWaitForPropKey + \"`, found `\" + val + \"`\"); | ||
} | ||
}, _notFound => { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
}); | ||
} | ||
return nonMatchingProps; | ||
}); | ||
} | ||
const timeLimit = page.getDefaultTimeout(); | ||
const timeAdd = 50; | ||
let allTime = 0; | ||
let parseWaitForProp = null; | ||
while (true) { | ||
while (true) { | ||
parseWaitForProp = await page.$$(\"a\"); | ||
if (parseWaitForProp.length !== 0) { | ||
parseWaitForProp = parseWaitForProp[0]; | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
throw new Error(\"The CSS selector \\\"a\\\" was not found\"); | ||
} | ||
} | ||
const nonMatchingProps = await checkPropForElem(parseWaitForProp); | ||
if (nonMatchingProps.length !== 0) { | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
const props = nonMatchingProps.join(\", \"); | ||
throw new Error(\"All properties still match\"); | ||
} | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] | ||
checkResult = true |
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, 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, 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 = """expected a selector, found `1` (a number) (first element of the tuple)""" |
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 selector, found `1` (a number) (first element of the tuple)""" |
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 JSON dict, found `2` (a number) (second element of the tuple)""" |
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 = """type \"json\" (`{\"a\": 2}`) is not allowed as value in this JSON dict, allowed types are: [`ident`, `number`, `string`] (second element of the tuple)""" |
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 `a` (third element of the tuple). Allowed idents are: [`ALL`, `CONTAINS`, `ENDS_WITH`, `NEAR`, `STARTS_WITH`]""" |
Oops, something went wrong.