Skip to content

Commit f0c27bd

Browse files
Add UI tests for NEAR checks
1 parent e5af72a commit f0c27bd

File tree

5 files changed

+81
-20
lines changed

5 files changed

+81
-20
lines changed

tests/html_files/elements.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</head>
4242
<body>
4343
<header>Another page!</header>
44-
<div class="content">
44+
<div class="content" nb-value="12">
4545
<div class="right" data-whatever="a">
4646
<p style="margin:2px;">Some text</p>
4747
<div>Some text2</div>

tests/ui-tests/assert-variable.goml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Checking variables values
2+
store-value: (variable_name, "hello")
3+
assert-variable: (variable_name, "he", STARTS_WITH)
4+
assert-variable: (variable_name, "o", ENDS_WITH)
5+
assert-variable: (variable_name, 10, NEAR) // should fail
6+
store-value: (variable_name, 10)
7+
assert-variable: (variable_name, 10, NEAR)
8+
assert-variable: (variable_name, 9, NEAR)
9+
assert-variable-false: (variable_name, 9, NEAR) // should fail
10+
assert-variable: (variable_name, 11, NEAR)
11+
assert-variable-false: (variable_name, 8, NEAR)
12+
assert-variable: (variable_name, 8, NEAR) // Should fail
13+
assert-variable-false: (variable_name, 12, NEAR)

tests/ui-tests/assert-variable.output

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=> Starting doc-ui tests...
2+
3+
assert-variable... FAILED
4+
[ERROR] (line 9) The following errors happened: [`10` is within 1 of `9` (for NEAR check)]: for command `assert-variable-false: (variable_name, 9, NEAR) // should fail`
5+
[ERROR] (line 12) The following errors happened: [`10` is not within 1 of `8` (for NEAR check)]: for command `assert-variable: (variable_name, 8, NEAR) // Should fail`
6+
7+
8+
<= doc-ui tests done: 0 succeeded, 1 failed

tests/ui-tests/asserts.goml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ assert-text-false: ("header", "Another", STARTS_WITH)
99
assert-property: (".content", {"className": "con"}, [ENDS_WITH, STARTS_WITH])
1010
assert-property: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])
1111
assert-property: (".content", {"className": "con"}, STARTS_WITH)
12+
// text check (for near)
13+
assert-property: (".content", {"className": "wowo"}, [CONTAINS, NEAR])
14+
// number check (for near)
15+
assert-property: (".content", {"clientWidth": "999"}, [CONTAINS, NEAR])
1216
assert-property-false: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])
1317
assert-property-false: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])
1418
assert-property-false: (".content", {"className": "con"}, ENDS_WITH)
19+
// text check (for near)
20+
assert-property-false: (".content", {"className": "wowo"}, [CONTAINS, NEAR])
21+
// number check (for near)
22+
assert-property-false: (".content", {"clientWidth": "999"}, [CONTAINS, NEAR])
1523
// We also check that the command fails if the attribute doesn't exist:
1624
assert-property: (".content", {"does-not-exist": ".con"})
1725
// Check that the "false" command succeeds if the attribute doesn't exist.
@@ -21,10 +29,19 @@ assert-property-false: (".content", {"does-not-exist": ".con"})
2129
assert-attribute: (".content", {"class": ".con"}, [ENDS_WITH, STARTS_WITH])
2230
assert-attribute: (".content", {"class": ".con"}, [STARTS_WITH, ENDS_WITH])
2331
assert-attribute: (".content", {"class": ".con"}, STARTS_WITH)
32+
assert-attribute: (".content", {"class": ".con"}, CONTAINS)
33+
// text check (for near)
34+
assert-attribute: (".content", {"class": ".con"}, NEAR)
35+
// number check (for near)
36+
assert-attribute: (".content", {"nb-value": 999}, NEAR)
2437
assert-attribute: (".content", {"\"class": ".con"})
2538
assert-attribute-false: (".content", {"class": ".con"}, [STARTS_WITH, ENDS_WITH])
2639
assert-attribute-false: (".content", {"class": ".con"}, [STARTS_WITH, ENDS_WITH])
2740
assert-attribute-false: (".content", {"class": ".con"}, ENDS_WITH)
41+
// text check (for near)
42+
assert-attribute-false: (".content", {"class": ".con"}, NEAR)
43+
// number check (for near)
44+
assert-attribute-false: (".content", {"nb-value": 999}, NEAR)
2845
// We also check that the command fails if the attribute doesn't exist:
2946
assert-attribute: (".content", {"does-not-exist": ".con"})
3047
// Check that the "false" command succeeds if the attribute doesn't exist.
@@ -37,13 +54,29 @@ assert-text: ("header", "Another", ENDS_WITH)
3754
// Same check on assert-document-property.
3855
assert-document-property-false: ({"title": "Other", "bgColor": ""}, [ENDS_WITH, STARTS_WITH])
3956
assert-document-property-false: ({"title": "Other"}, STARTS_WITH)
57+
// text check (for near)
58+
assert-document-property-false: ({"nodeName": ".con"}, NEAR)
59+
// number check (for near)
60+
assert-document-property-false: ({"nodeType": 999}, NEAR)
4061
assert-document-property: ({"title": "Other", "bgColor": "a"}, [STARTS_WITH, ENDS_WITH])
4162
assert-document-property: ({"title": "Other"}, ENDS_WITH)
63+
// text check (for near)
64+
assert-document-property: ({"nodeName": ".con"}, NEAR)
65+
// number check (for near)
66+
assert-document-property: ({"nodeType": 999}, NEAR)
4267
// Same check on assert-document-property.
4368
assert-window-property-false: ({"pageYOffset": "0", "pageXOffset": "0"}, [ENDS_WITH, STARTS_WITH])
4469
assert-window-property-false: ({"pageYOffset": "0"}, STARTS_WITH)
70+
// text check (for near)
71+
assert-window-property-false: ({"name": ".con"}, NEAR)
72+
// number check (for near)
73+
assert-window-property-false: ({"length": 999}, NEAR)
4574
assert-window-property: ({"pageYOffset": "www", "pageXOffset": "www"}, [STARTS_WITH, ENDS_WITH])
4675
assert-window-property: ({"pageYOffset": "www"}, ENDS_WITH)
76+
// text check (for near)
77+
assert-window-property: ({"name": ".con"}, NEAR)
78+
// number check (for near)
79+
assert-window-property: ({"length": 999}, NEAR)
4780
// Ensures that a "fatal error" stops the script as expected.
4881
click: "#non-existent"
4982
assert-document-property: ({"title": "Other"}, ENDS_WITH)

tests/ui-tests/asserts.output

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@ asserts... FAILED
55
[ERROR] (line 6) Error: Evaluation failed: The following errors happened: [`Another page!` starts with `Another` (for STARTS_WITH check)]: for command `assert-text-false: ("header", "Another", STARTS_WITH)`
66
[ERROR] (line 9) Error: Evaluation failed: The following errors happened (for selector `.content`): [Property `className` (`content`) does not end with `con`]: for command `assert-property: (".content", {"className": "con"}, [ENDS_WITH, STARTS_WITH])`
77
[ERROR] (line 10) Error: Evaluation failed: The following errors happened (for selector `.content`): [Property `className` (`content`) does not end with `con`]: for command `assert-property: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])`
8-
[ERROR] (line 12) Error: Evaluation failed: The following errors happened (for selector `.content`): [assert didn't fail for property `className` (for STARTS_WITH check)]: for command `assert-property-false: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])`
9-
[ERROR] (line 13) Error: Evaluation failed: The following errors happened (for selector `.content`): [assert didn't fail for property `className` (for STARTS_WITH check)]: for command `assert-property-false: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])`
10-
[ERROR] (line 16) Error: Evaluation failed: The following errors happened (for selector `.content`): [Unknown property `does-not-exist`]: for command `assert-property: (".content", {"does-not-exist": ".con"})`
11-
[ERROR] (line 21) Error: Evaluation failed: The following errors happened (for selector `.content`): [attribute `class` (`content`) doesn't start with `.con` (for STARTS_WITH check), attribute `class` (`content`) doesn't end with `.con`]: for command `assert-attribute: (".content", {"class": ".con"}, [ENDS_WITH, STARTS_WITH])`
12-
[ERROR] (line 22) Error: Evaluation failed: The following errors happened (for selector `.content`): [attribute `class` (`content`) doesn't start with `.con` (for STARTS_WITH check), attribute `class` (`content`) doesn't end with `.con`]: for command `assert-attribute: (".content", {"class": ".con"}, [STARTS_WITH, ENDS_WITH])`
13-
[ERROR] (line 23) Error: Evaluation failed: The following errors happened (for selector `.content`): [attribute `class` (`content`) doesn't start with `.con` (for STARTS_WITH check)]: for command `assert-attribute: (".content", {"class": ".con"}, STARTS_WITH)`
14-
[ERROR] (line 24) Error: Evaluation failed: The following errors happened (for selector `.content`): [No attribute named `"class`]: for command `assert-attribute: (".content", {"\"class": ".con"})`
15-
[ERROR] (line 29) Error: Evaluation failed: The following errors happened (for selector `.content`): [No attribute named `does-not-exist`]: for command `assert-attribute: (".content", {"does-not-exist": ".con"})`
16-
[ERROR] (line 35) Error: Evaluation failed: The following errors happened: [`Another page!` doesn't end with `Another` (for ENDS_WITH check)]: for command `assert-text: ("header", "Another", [STARTS_WITH, ENDS_WITH])`
17-
[ERROR] (line 36) Error: Evaluation failed: The following errors happened: [`Another page!` doesn't end with `Another` (for ENDS_WITH check)]: for command `assert-text: ("header", "Another", ENDS_WITH)`
18-
[ERROR] (line 38) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `title` (for STARTS_WITH check), assert didn't fail for property `bgColor` (for STARTS_WITH check), assert didn't fail for property `bgColor` (for ENDS_WITH check)]: for command `assert-document-property-false: ({"title": "Other", "bgColor": ""}, [ENDS_WITH, STARTS_WITH])`
19-
[ERROR] (line 39) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `title` (for STARTS_WITH check)]: for command `assert-document-property-false: ({"title": "Other"}, STARTS_WITH)`
20-
[ERROR] (line 40) Error: Evaluation failed: The following errors happened: [Property `title` (`Other page`) does not end with `Other`, Property `bgColor` (``) does not start with `a`, Property `bgColor` (``) does not end with `a`]: for command `assert-document-property: ({"title": "Other", "bgColor": "a"}, [STARTS_WITH, ENDS_WITH])`
21-
[ERROR] (line 41) Error: Evaluation failed: The following errors happened: [Property `title` (`Other page`) does not end with `Other`]: for command `assert-document-property: ({"title": "Other"}, ENDS_WITH)`
22-
[ERROR] (line 43) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `pageYOffset` (for STARTS_WITH check), assert didn't fail for property `pageYOffset` (for ENDS_WITH check), assert didn't fail for property `pageXOffset` (for STARTS_WITH check), assert didn't fail for property `pageXOffset` (for ENDS_WITH check)]: for command `assert-window-property-false: ({"pageYOffset": "0", "pageXOffset": "0"}, [ENDS_WITH, STARTS_WITH])`
23-
[ERROR] (line 44) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `pageYOffset` (for STARTS_WITH check)]: for command `assert-window-property-false: ({"pageYOffset": "0"}, STARTS_WITH)`
24-
[ERROR] (line 45) Error: Evaluation failed: The following errors happened: [Property `pageYOffset` (`0`) does not start with `www`, Property `pageYOffset` (`0`) does not end with `www`, Property `pageXOffset` (`0`) does not start with `www`, Property `pageXOffset` (`0`) does not end with `www`]: for command `assert-window-property: ({"pageYOffset": "www", "pageXOffset": "www"}, [STARTS_WITH, ENDS_WITH])`
25-
[ERROR] (line 46) Error: Evaluation failed: The following errors happened: [Property `pageYOffset` (`0`) does not end with `www`]: for command `assert-window-property: ({"pageYOffset": "www"}, ENDS_WITH)`
26-
[ERROR] (line 48) "#non-existent" not found: for command `click: "#non-existent"`
8+
[ERROR] (line 13) Error: Evaluation failed: The following errors happened (for selector `.content`): [Property `className` (`content`) does not contain `wowo`]: for command `assert-property: (".content", {"className": "wowo"}, [CONTAINS, NEAR])`
9+
[ERROR] (line 15) Error: Evaluation failed: The following errors happened (for selector `.content`): [Property `clientWidth` (`800`) does not contain `999`, Property `clientWidth` (`800`) is not within 1 of `999` (for NEAR check)]: for command `assert-property: (".content", {"clientWidth": "999"}, [CONTAINS, NEAR])`
10+
[ERROR] (line 16) Error: Evaluation failed: The following errors happened (for selector `.content`): [assert didn't fail for property `className` (for STARTS_WITH check)]: for command `assert-property-false: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])`
11+
[ERROR] (line 17) Error: Evaluation failed: The following errors happened (for selector `.content`): [assert didn't fail for property `className` (for STARTS_WITH check)]: for command `assert-property-false: (".content", {"className": "con"}, [STARTS_WITH, ENDS_WITH])`
12+
[ERROR] (line 24) Error: Evaluation failed: The following errors happened (for selector `.content`): [Unknown property `does-not-exist`]: for command `assert-property: (".content", {"does-not-exist": ".con"})`
13+
[ERROR] (line 29) Error: Evaluation failed: The following errors happened (for selector `.content`): [attribute `class` (`content`) doesn't start with `.con` (for STARTS_WITH check), attribute `class` (`content`) doesn't end with `.con`]: for command `assert-attribute: (".content", {"class": ".con"}, [ENDS_WITH, STARTS_WITH])`
14+
[ERROR] (line 30) Error: Evaluation failed: The following errors happened (for selector `.content`): [attribute `class` (`content`) doesn't start with `.con` (for STARTS_WITH check), attribute `class` (`content`) doesn't end with `.con`]: for command `assert-attribute: (".content", {"class": ".con"}, [STARTS_WITH, ENDS_WITH])`
15+
[ERROR] (line 31) Error: Evaluation failed: The following errors happened (for selector `.content`): [attribute `class` (`content`) doesn't start with `.con` (for STARTS_WITH check)]: for command `assert-attribute: (".content", {"class": ".con"}, STARTS_WITH)`
16+
[ERROR] (line 32) Error: Evaluation failed: The following errors happened (for selector `.content`): [attribute `class` (`content`) doesn't contain `.con` (for CONTAINS check)]: for command `assert-attribute: (".content", {"class": ".con"}, CONTAINS)`
17+
[ERROR] (line 36) Error: Evaluation failed: ReferenceError: nonMatchingProps is not defined
18+
at pptr://__puppeteer_evaluation_script__:13:13: for command `assert-attribute: (".content", {"nb-value": 999}, NEAR)`
19+
[ERROR] (line 37) Error: Evaluation failed: The following errors happened (for selector `.content`): [No attribute named `"class`]: for command `assert-attribute: (".content", {"\"class": ".con"})`
20+
[ERROR] (line 46) Error: Evaluation failed: The following errors happened (for selector `.content`): [No attribute named `does-not-exist`]: for command `assert-attribute: (".content", {"does-not-exist": ".con"})`
21+
[ERROR] (line 52) Error: Evaluation failed: The following errors happened: [`Another page!` doesn't end with `Another` (for ENDS_WITH check)]: for command `assert-text: ("header", "Another", [STARTS_WITH, ENDS_WITH])`
22+
[ERROR] (line 53) Error: Evaluation failed: The following errors happened: [`Another page!` doesn't end with `Another` (for ENDS_WITH check)]: for command `assert-text: ("header", "Another", ENDS_WITH)`
23+
[ERROR] (line 55) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `title` (for STARTS_WITH check), assert didn't fail for property `bgColor` (for STARTS_WITH check), assert didn't fail for property `bgColor` (for ENDS_WITH check)]: for command `assert-document-property-false: ({"title": "Other", "bgColor": ""}, [ENDS_WITH, STARTS_WITH])`
24+
[ERROR] (line 56) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `title` (for STARTS_WITH check)]: for command `assert-document-property-false: ({"title": "Other"}, STARTS_WITH)`
25+
[ERROR] (line 61) Error: Evaluation failed: The following errors happened: [Property `title` (`Other page`) does not end with `Other`, Property `bgColor` (``) does not start with `a`, Property `bgColor` (``) does not end with `a`]: for command `assert-document-property: ({"title": "Other", "bgColor": "a"}, [STARTS_WITH, ENDS_WITH])`
26+
[ERROR] (line 62) Error: Evaluation failed: The following errors happened: [Property `title` (`Other page`) does not end with `Other`]: for command `assert-document-property: ({"title": "Other"}, ENDS_WITH)`
27+
[ERROR] (line 66) Error: Evaluation failed: The following errors happened: [Property `nodeType` (`9`) is not within 1 of `999` (for NEAR check)]: for command `assert-document-property: ({"nodeType": 999}, NEAR)`
28+
[ERROR] (line 68) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `pageYOffset` (for STARTS_WITH check), assert didn't fail for property `pageYOffset` (for ENDS_WITH check), assert didn't fail for property `pageXOffset` (for STARTS_WITH check), assert didn't fail for property `pageXOffset` (for ENDS_WITH check)]: for command `assert-window-property-false: ({"pageYOffset": "0", "pageXOffset": "0"}, [ENDS_WITH, STARTS_WITH])`
29+
[ERROR] (line 69) Error: Evaluation failed: The following errors happened: [assert didn't fail for property `pageYOffset` (for STARTS_WITH check)]: for command `assert-window-property-false: ({"pageYOffset": "0"}, STARTS_WITH)`
30+
[ERROR] (line 74) Error: Evaluation failed: The following errors happened: [Property `pageYOffset` (`0`) does not start with `www`, Property `pageYOffset` (`0`) does not end with `www`, Property `pageXOffset` (`0`) does not start with `www`, Property `pageXOffset` (`0`) does not end with `www`]: for command `assert-window-property: ({"pageYOffset": "www", "pageXOffset": "www"}, [STARTS_WITH, ENDS_WITH])`
31+
[ERROR] (line 75) Error: Evaluation failed: The following errors happened: [Property `pageYOffset` (`0`) does not end with `www`]: for command `assert-window-property: ({"pageYOffset": "www"}, ENDS_WITH)`
32+
[ERROR] (line 79) Error: Evaluation failed: The following errors happened: [Property `length` (`0`) is not within 1 of `999` (for NEAR check)]: for command `assert-window-property: ({"length": 999}, NEAR)`
33+
[ERROR] (line 81) "#non-existent" not found: for command `click: "#non-existent"`
2734

2835

2936
<= doc-ui tests done: 0 succeeded, 1 failed

0 commit comments

Comments
 (0)