Skip to content

Commit 8ade4d5

Browse files
GuillaumeGomezsyphar
authored andcommitted
Add regression test for #3135
1 parent 1b314fe commit 8ade4d5

3 files changed

Lines changed: 89 additions & 23 deletions

File tree

gui-tests/crate-pages.goml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
// Checks that the "crate pages" have all the same style (ie: not centered).
2+
include: "utils.goml"
23
go-to: |DOC_PATH| + "/crate/sysinfo"
4+
// Big enough to have "margin: auto" to kick in.
5+
set-window-size: (1300, 800)
36

47
store-value: (tabs_menu_selector, ".description-container .pure-menu-horizontal ul.pure-menu-list")
58
store-value: (current_tab, 1)
6-
7-
define-function: (
8-
"check-tab",
9-
[tab_name, click_next],
10-
block {
11-
// We check the tab's name is the one expected.
12-
assert-text: (|tabs_menu_selector| + " > li a.pure-menu-active .title", |tab_name|)
13-
// We check it also matches the one we clicked.
14-
assert: |tabs_menu_selector| + " > li:nth-of-type(" + |current_tab| + ") a.pure-menu-active"
15-
// We ensure that the content of the page is not centered.
16-
assert: "body:not(.centered)"
17-
assert-css: ("div.container", {"margin": "0px"})
18-
if: (|click_next|, block {
19-
store-value: (current_tab, |current_tab| + 1)
20-
click: |tabs_menu_selector| + " > li:nth-of-type(" + |current_tab| + ")"
21-
})
22-
}
23-
)
9+
store-value: (nb_tabs, 4)
2410

2511
// If this assert fails, it means we added new entries for this menu so this test needs to be
2612
// updated.
27-
assert-count: (|tabs_menu_selector| + " > li", 4)
13+
assert-count: (|tabs_menu_selector| + " > li", |nb_tabs|)
14+
15+
call-function: ("check-tab-not-centered", {"tab_name": " Crate", "click_next": true})
16+
call-function: ("check-tab-not-centered", {"tab_name": " Source", "click_next": true})
17+
call-function: ("check-tab-not-centered", {"tab_name": " Builds", "click_next": true})
18+
call-function: ("check-tab-not-centered", {"tab_name": "Feature flags", "click_next": false})
2819

29-
call-function: ("check-tab", {"tab_name": " Crate", "click_next": true})
30-
call-function: ("check-tab", {"tab_name": " Source", "click_next": true})
31-
call-function: ("check-tab", {"tab_name": " Builds", "click_next": true})
32-
call-function: ("check-tab", {"tab_name": "Feature flags", "click_next": false})
20+
assert: |nb_tabs| == |current_tab|

gui-tests/release-pages.goml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Checks that the "release pages" have all the same style (ie: centered).
2+
include: "utils.goml"
3+
go-to: |DOC_PATH| + "/releases"
4+
// Big enough to have "margin: auto" to kick in.
5+
set-window-size: (1300, 800)
6+
7+
store-value: (tabs_menu_selector, ".description-container .pure-menu-horizontal ul.pure-menu-list")
8+
store-value: (current_tab, 1)
9+
store-value: (nb_tabs, 6)
10+
11+
// If this assert fails, it means we added new entries for this menu so this test needs to be
12+
// updated.
13+
assert-count: (|tabs_menu_selector| + " > li", |nb_tabs|)
14+
15+
call-function: ("check-tab-centered", {"tab_name": "Recent", "click_next": true})
16+
call-function: ("check-tab-centered", {"tab_name": "Stars", "click_next": true})
17+
call-function: ("check-tab-centered", {"tab_name": "Recent Failures", "click_next": true})
18+
call-function: ("check-tab-centered", {"tab_name": "Failures By Stars", "click_next": true})
19+
call-function: ("check-tab-centered", {"tab_name": "Activity", "click_next": true})
20+
call-function: ("check-tab-centered", {"tab_name": "Queue", "click_next": false})
21+
22+
assert: |nb_tabs| == |current_tab|

gui-tests/utils.goml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
define-function: (
2+
"check-tab",
3+
[tab_name, centered, click_next],
4+
block {
5+
// We check the tab's name is the one expected.
6+
assert-text: (|tabs_menu_selector| + " > li a.pure-menu-active .title", |tab_name|)
7+
// We check it also matches the one we clicked.
8+
assert: |tabs_menu_selector| + " > li:nth-of-type(" + |current_tab| + ") a.pure-menu-active"
9+
10+
// We ensure that the content of the page is (not?) centered.
11+
if: (|centered|, block {
12+
assert: "body.centered"
13+
assert-css: ("div.container", {
14+
"margin-top": "0px",
15+
"margin-bottom": "0px",
16+
"margin-left": "70px",
17+
"margin-right": "70px",
18+
})
19+
})
20+
else: block {
21+
assert: "body:not(.centered)"
22+
assert-css: ("div.container", {
23+
"margin-top": "0px",
24+
"margin-bottom": "0px",
25+
"margin-left": "0px",
26+
"margin-right": "0px",
27+
})
28+
}
29+
if: (|click_next|, block {
30+
store-value: (current_tab, |current_tab| + 1)
31+
click: |tabs_menu_selector| + " > li:nth-of-type(" + |current_tab| + ")"
32+
})
33+
}
34+
)
35+
36+
define-function: (
37+
"check-tab-centered",
38+
[tab_name, click_next],
39+
block {
40+
call-function: (
41+
"check-tab",
42+
{"tab_name": |tab_name|, "centered": true, "click_next": |click_next|},
43+
)
44+
}
45+
)
46+
47+
define-function: (
48+
"check-tab-not-centered",
49+
[tab_name, click_next],
50+
block {
51+
call-function: (
52+
"check-tab",
53+
{"tab_name": |tab_name|, "centered": false, "click_next": |click_next|},
54+
)
55+
}
56+
)

0 commit comments

Comments
 (0)