Skip to content

Commit f48e031

Browse files
committed
test: added plan tests using playwright
1 parent 6243c36 commit f48e031

File tree

9 files changed

+421
-0
lines changed

9 files changed

+421
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# guidebook store mirror
2+
/store
3+
14
# electron builds
25
/dist
36

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import doPlan from "../plan"
18+
import Input, { Tree } from "../Input"
19+
20+
const importa: (name?: string) => Tree = (name = "importa.md") => ({ name, children: [{ name: "echo AAA" }] })
21+
22+
const importc: Tree = { name: "importc.md", children: [{ name: "echo CCC" }] }
23+
24+
// const option2Tab2: Tree = { name: 'Option 2: Tab2', children: [importc] }
25+
26+
const importe: Tree = { name: "EEE", children: [{ name: "Option 1: TabE1", children: [{ name: "echo EEE" }] }] }
27+
28+
const importd: Tree = {
29+
name: "DDD",
30+
children: [
31+
{ name: "Option 1: SubTab1", children: [{ name: "echo AAA" }, { name: "echo AAA" }, { name: "echo AAA" }] },
32+
{ name: "Option 2: SubTab2", children: [{ name: "echo BBB" }] },
33+
],
34+
}
35+
36+
const prerequisites = {
37+
name: "Prerequisites",
38+
children: [importe, importd],
39+
}
40+
41+
const IN1: Input = {
42+
input: "guidebook-tree-model1.md",
43+
tree: () => [prerequisites],
44+
}
45+
46+
export { importa, importc, importe, importd }
47+
48+
doPlan(IN1)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import doPlan from "../plan"
18+
import Input, { Tree } from "../Input"
19+
import { importe, importd } from "./1.spec"
20+
21+
const snippetsInTab4: Tree = {
22+
name: "snippets-in-tab4.md",
23+
children: [
24+
{ name: "Option 1: Tab1", children: [importd] },
25+
{ name: "Option 2: Tab2", children: [{ name: "echo XXX" }] },
26+
],
27+
}
28+
29+
const prerequisites = {
30+
name: "Prerequisites",
31+
children: [importe],
32+
}
33+
34+
const mainTasks = {
35+
name: "Main Tasks",
36+
children: snippetsInTab4.children,
37+
}
38+
39+
const IN2: Input = {
40+
input: "guidebook-tree-model2.md",
41+
tree: () => [
42+
{
43+
name: "AAA",
44+
children: [prerequisites, mainTasks],
45+
},
46+
],
47+
}
48+
49+
doPlan(IN2)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import doPlan from "../plan"
18+
import Input, { Tree } from "../Input"
19+
import { importe, importd } from "./1.spec"
20+
21+
const snippetsInTab5: Tree = {
22+
name: "snippets-in-tab5.md",
23+
children: [
24+
{ name: "Option 1: Tab1", children: [importd] },
25+
{ name: "Option 2: Tab2", children: [{ name: "echo XXX" }] },
26+
{ name: "Option 3: Tab3", children: [importd] },
27+
],
28+
}
29+
30+
const prerequisites = {
31+
name: "Prerequisites",
32+
children: [importe],
33+
}
34+
35+
const mainTasks = {
36+
name: "Main Tasks",
37+
children: snippetsInTab5.children,
38+
}
39+
40+
const IN3: Input = {
41+
input: "guidebook-tree-model3.md",
42+
tree: () => [
43+
{
44+
name: "AAA",
45+
children: [prerequisites, mainTasks],
46+
},
47+
],
48+
}
49+
50+
doPlan(IN3)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import doPlan from "../plan"
18+
import Input, { Tree } from "../Input"
19+
import { importe, importd } from "./1.spec"
20+
21+
const snippetsInTab5: Tree = {
22+
name: "AAA",
23+
children: [{ name: "Option 2: Tab2", children: [{ name: "echo XXX" }] }],
24+
}
25+
26+
const filename = "guidebook-tree-model4.md"
27+
28+
const IN4: Input = {
29+
input: filename,
30+
tree: () => [
31+
{
32+
name: "Sequence",
33+
children: [importd, importe, snippetsInTab5],
34+
},
35+
],
36+
}
37+
38+
doPlan(IN4)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import doPlan from "../plan"
18+
import Input from "../Input"
19+
import { importd } from "./1.spec"
20+
21+
const IN5: Input = {
22+
input: "guidebook-tree-model5.md",
23+
tree: () => [
24+
{
25+
name: "Prerequisites",
26+
children: [importd],
27+
},
28+
],
29+
}
30+
31+
doPlan(IN5)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import doPlan from "../plan"
18+
import Input, { Tree } from "../Input"
19+
import { importd } from "./1.spec"
20+
21+
const filename = "guidebook-tree-model6.md"
22+
23+
const messageForMacOS = "echo MMM"
24+
const messageForLinux = "echo LLL"
25+
const messageForWindows = "echo WWW"
26+
27+
const messageForElectron =
28+
process.platform === "linux" ? messageForLinux : process.platform === "darwin" ? messageForMacOS : messageForWindows
29+
30+
// here, we will squash away the choice
31+
const importgForElectron: (name: string) => Tree = (name: string) => ({
32+
name,
33+
children: [{ name: messageForElectron }],
34+
})
35+
36+
// here, we won't squash away the choice
37+
const importgForBrowser: (name: string) => Tree = (name: string) => ({
38+
name,
39+
children: [
40+
{ name: "Option 1: MacOS", children: [{ name: messageForMacOS }] },
41+
{ name: "Option 2: Linux", children: [{ name: messageForLinux }] },
42+
{ name: "Option 3: Windows", children: [{ name: messageForWindows }] },
43+
],
44+
})
45+
46+
export const importg: (name?: string) => Tree = (name = "importg.md") =>
47+
(process.env.MOCHA_RUN_TARGET || "electron") === "electron" ? importgForElectron(name) : importgForBrowser(name)
48+
49+
const tree: Input["tree"] = () => [
50+
{
51+
name: "Sequence",
52+
children: [importg(), importd],
53+
},
54+
]
55+
56+
const IN6: Input = {
57+
input: filename,
58+
tree,
59+
}
60+
61+
doPlan(IN6)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import doPlan from "../plan"
18+
import Input from "../Input"
19+
import { importg } from "./6.spec"
20+
import { importd } from "./1.spec"
21+
22+
const filename = "guidebook-tree-model7.md"
23+
24+
export const tree: Input["tree"] = () => [
25+
{
26+
name: "Sequence",
27+
children: [importg("importgg.md"), importd],
28+
},
29+
]
30+
31+
const IN7: Input = {
32+
input: filename,
33+
tree,
34+
}
35+
36+
doPlan(IN7)

0 commit comments

Comments
 (0)