Skip to content

Commit fb56156

Browse files
update znai src
1 parent d3da5d9 commit fb56156

14 files changed

Lines changed: 157 additions & 61 deletions

znaisrc/REST/documentation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Scenarios
22

3-
You provide `REST endpoints` so users can execute various scenarios.
4-
You need to test those scenarios and then document them.
3+
You document `REST endpoints` so users can use them to achieve various goals.
4+
You also need to make sure that documented scenarios work as advertised.
55

6-
To automate the process, let's capture executed scenarios and use them inside your documentation.
6+
To automate the process, capture executed scenarios and use them inside your documentation.
77

88
# Capturing Test Artifacts
99

10-
To capture artifacts use `http.doc.capture`:
10+
To capture `REST` artifacts use `http.doc.capture`:
1111

1212
:include-file: scenarios/rest/simplePost.groovy {title: "test.groovy", commentsType: "inline"}
1313

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
:include-markdown: installation-groovy-runner.md
2+
3+
# Minimal Groovy Setup
4+
5+
Generate webtau examples
6+
7+
:include-cli-command: webtau --example
8+
9+
Navigate into `todo` example
10+
11+
:include-cli-command: cd examples/todo
12+
13+
:include-file: examples/todo/todolist.groovy {title: "todolist.groovy"}
14+
15+
To run test
16+
17+
:include-cli-command: webtau todolist.groovy --url=https://jsonplaceholder.typicode.com {paramsToHighlight: "url"}
18+
19+
:include-markdown: common/note-package-import.md
20+
21+
## Groovy Config File
22+
23+
Url parameter can be moved to a `webtau.cfg` file.
24+
25+
:include-file: examples/todo/webtau.cfg {title: "webtau.cfg"}
26+
27+
[Specify multiple environments](configuration/environments) to streamline test execution.
28+
29+
# Minimal JUnit Setup
30+
31+
```tabs
32+
Groovy: :include-file: maven/groovy-dep.xml {title: "Maven Dependency"}
33+
Java: :include-file: maven/java-dep.xml {title: "Maven Dependency"}
34+
```
35+
36+
```tabs
37+
Groovy:
38+
:include-file: com/example/tests/junit4/TodoListGroovyIT.groovy {title: "JUnit 4 example"}
39+
40+
Java:
41+
:include-file: com/example/tests/junit4/TodoListJavaIT.java {title: "JUnit 4 example"}
42+
```
43+
44+
## Junit Config File
45+
46+
Add `webtau.properties` to test class path
47+
48+
:include-file: src/test/resources/webtau.properties {title: "webtau.properties"}

znaisrc/REST/getting-started.md

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1 @@
1-
:include-markdown: {firstAvailable: ["company-specific-installation-groovy-runner.md", "installation-groovy-runner.md"]}
2-
3-
# Minimal Groovy Setup
4-
5-
:include-markdown: {firstAvailable: ["company-specific-minimal-groovy-setup.md", "minimal-groovy-setup.md"]}
6-
7-
:include-markdown: common/note-package-import.md
8-
9-
## Groovy Config File
10-
11-
Url parameter can be moved to a `webtau.cfg` file.
12-
13-
:include-file: examples/todo/webtau.cfg {title: "webtau.cfg"}
14-
15-
[Specify multiple environments](configuration/environments) to streamline test execution.
16-
17-
# Minimal JUnit Setup
18-
19-
```tabs
20-
Groovy: :include-file: maven/groovy-dep.xml {title: "Maven Dependency"}
21-
Java: :include-file: maven/java-dep.xml {title: "Maven Dependency"}
22-
```
23-
24-
```tabs
25-
Groovy:
26-
:include-file: com/example/tests/junit4/TodoListGroovyIT.groovy {title: "JUnit 4 example"}
27-
28-
Java:
29-
:include-file: com/example/tests/junit4/TodoListJavaIT.java {title: "JUnit 4 example"}
30-
```
31-
32-
## Junit Config File
33-
34-
Add `webtau.properties` to test class path
35-
36-
:include-file: src/test/resources/webtau.properties {title: "webtau.properties"}
37-
1+
:include-markdown: {firstAvailable: ["company-specific-getting-started-rest.md", "getting-started-rest.md"]}

znaisrc/UI/documentation.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Scenarios
2+
3+
To document how to use a User Interface we often take screenshots and annotate them.
4+
At the same time we need to make sure that documented scenario works as advertised.
5+
6+
With UI testing we can validate scenarios and at the same time capture screenshots with automatically placed annotations.
7+
8+
# Capturing Screenshots With Annotations
9+
10+
To capture screenshots use `browser.doc[.withAnnotations].capture`:
11+
12+
:include-file: doc-artifacts/snippets/doc-capture/captureBadges.groovy {title: "screenshot capture with badge annotations"}
13+
14+
The result of the `capture` command is two files: actual screenshot and `annotations.json`.
15+
16+
:include-file: doc-artifacts/ui/search.json {title: "search.json"}
17+
18+
[Webtau](https://github.com/twosigma/webtau) documentation site is generated using [Znai](https://github.com/twosigma/znai).
19+
[Znai](https://github.com/twosigma/znai) has `include-image` plugin that supports annotations format generated by `capture` command.
20+
21+
:include-image: doc-artifacts/ui/search.png {fit: true, annotationsPath: "doc-artifacts/ui/search.json"}
22+
23+
:include-image: doc-artifacts/ui/search.png {annotationsPath: "doc-artifacts/ui/search.json"}
24+
25+
# Annotation Types
26+
27+
:include-file: doc-artifacts/snippets/doc-capture/captureBadges.groovy {title: "badges"}
28+
:include-image: doc-artifacts/ui/search.png {annotationsPath: "doc-artifacts/ui/search.json"}
29+
30+
:include-file: doc-artifacts/snippets/doc-capture/captureHighlightCover.groovy {title: "cover and highlight"}
31+
:include-image: doc-artifacts/ui/search-highlight-cover.png {annotationsPath: "doc-artifacts/ui/search-highlight-cover.json"}

znaisrc/UI/getting-started-ui.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
:include-markdown: {firstAvailable: ["installation-company-specific-groovy-runner.md", "installation-groovy-runner.md"]}
2+
3+
# Bare Minimum
4+
5+
:include-file: examples/scenarios/ui/basic.groovy {title: "examples/scenarios/ui/basic.groovy"}
6+
7+
To run test, navigate to `examples` dir and
8+
9+
:include-cli-command: webtau scenarios/ui/basic.groovy --url=https://my-server {paramsToHighlight: "url"}
10+
11+
:include-markdown: common/note-package-import.md
12+
13+
# Config File
14+
15+
Url parameter can be moved to a `webtau.cfg` file.
16+
17+
:include-file: examples/scenarios/ui/webtau.cfg {title: "examples/scenarios/ui/webtau.cfg"}
18+
19+
[Specify multiple environments](configuration/environments) to streamline test execution.

znaisrc/UI/getting-started.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
:include-markdown: {firstAvailable: ["installation-company-specific-groovy-runner.md", "installation-groovy-runner.md"]}
2-
3-
# Bare Minimum
4-
5-
:include-file: examples/scenarios/ui/basic.groovy {title: "examples/scenarios/ui/basic.groovy"}
6-
7-
To run test, navigate to `examples` dir and
8-
9-
:include-cli-command: webtau scenarios/ui/basic.groovy --url=https://my-server {paramsToHighlight: "url"}
10-
11-
:include-markdown: common/note-package-import.md
12-
13-
# Config File
14-
15-
Url parameter can be moved to a `webtau.cfg` file.
16-
17-
:include-file: examples/scenarios/ui/webtau.cfg {title: "examples/scenarios/ui/webtau.cfg"}
18-
19-
[Specify multiple environments](configuration/environments) to streamline test execution.
1+
:include-markdown: {firstAvailable: ["company-specific-getting-started-ui.md", "getting-started-ui.md"]}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
search.submit("search this")
2+
3+
browser.doc.withAnnotations(
4+
browser.doc.badge(search.box),
5+
browser.doc.badge(search.results)).capture('search')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
browser.doc.withAnnotations(
2+
browser.doc.highlight(search.box),
3+
browser.doc.cover(search.results, "covering text")).capture('search-highlight-cover')
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"shapes" : [ {
3+
"id" : "highlight3",
4+
"type" : "highlight",
5+
"text" : "",
6+
"color" : "a",
7+
"x" : 24,
8+
"y" : 24,
9+
"width" : 131,
10+
"height" : 19
11+
}, {
12+
"id" : "rectangle4",
13+
"type" : "rectangle",
14+
"text" : "covering text",
15+
"color" : "a",
16+
"x" : 28,
17+
"y" : 99,
18+
"width" : 944,
19+
"height" : 36
20+
} ],
21+
"pixelRatio" : 2
22+
}
25.1 KB
Loading

0 commit comments

Comments
 (0)