forked from jenkinsci/pipeline-graph-view-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipelineOverviewPage.java
More file actions
201 lines (165 loc) · 6.24 KB
/
PipelineOverviewPage.java
File metadata and controls
201 lines (165 loc) · 6.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
package io.jenkins.plugins.pipelinegraphview.playwright;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.options.AriaRole;
import io.jenkins.plugins.pipelinegraphview.utils.PipelineState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PipelineOverviewPage extends JenkinsPage<PipelineOverviewPage> {
private static final Logger log = LoggerFactory.getLogger(PipelineOverviewPage.class);
private final String buildName;
private final PipelineGraph graph;
private final OverviewTree tree;
private final PipelineConsole logs;
private final String jobUrl;
public PipelineOverviewPage(Page page, String jobUrl, String buildName) {
super(page, jobUrl + "stages/");
this.buildName = buildName;
this.jobUrl = jobUrl;
graph = new PipelineGraph(page.locator(".PWGx-PipelineGraph-container"));
tree = new OverviewTree(page.locator("#tree-view-pane"));
logs = new PipelineConsole(page.locator("#stage-view-pane"));
}
@Override
PipelineOverviewPage waitForLoaded() {
super.waitForLoaded();
Locator heading = page.getByRole(
AriaRole.HEADING, new Page.GetByRoleOptions().setLevel(1).setName(buildName));
assertThat(heading).isVisible();
assertThat(page.locator("#console-pipeline-root")).isVisible();
graph.isVisible();
tree.isVisible();
logs.isVisible();
return this;
}
public PipelineOverviewPage hasStagesInGraph(int count, String... stages) {
graph.hasStages(count, stages);
return this;
}
public PipelineOverviewPage stageIsSelected(String stage) {
return stageIsSelectedInGraph(stage).stageIsSelectedInTree(stage).stageIsSelectedInLogs(stage);
}
public PipelineOverviewPage stageIsSelectedInGraph(String stage) {
graph.stageIsSelected(stage);
return this;
}
public PipelineOverviewPage stageIsSelectedInTree(String stage) {
tree.stageIsSelected(stage);
return this;
}
public PipelineOverviewPage stageIsSelectedInLogs(String stage) {
logs.stageIsSelected(stage);
return this;
}
public PipelineOverviewPage selectStageInGraph(String stage) {
graph.selectStage(stage);
return this;
}
public PipelineOverviewPage selectStageInTree(String stage) {
tree.selectStage(stage);
return this;
}
public PipelineOverviewPage searchForStage(String stage) {
tree.searchForStage(stage);
return this;
}
public PipelineOverviewPage stepContainsText(String stepName, String textToFind) {
logs.stepContainsText(stepName, textToFind);
return this;
}
public PipelineOverviewPage stepDoesNotContainText(String stepName, String textToNotFind) {
logs.stepDoesNotContainText(stepName, textToNotFind);
return this;
}
public PipelineOverviewPage stageHasSteps(String step, String... additional) {
logs.stageHasSteps(step, additional);
return this;
}
public PipelineOverviewPage stageHasState(String stage, PipelineState state) {
return stageHasStateInGraph(stage, state)
.stageHasStateInTree(stage, state)
.stageHasStateInLogs(stage, state);
}
public PipelineOverviewPage stageHasStateInGraph(String stage, PipelineState state) {
graph.stageHasState(stage, state);
return this;
}
public PipelineOverviewPage stageHasStateInTree(String stage, PipelineState state) {
tree.searchForStage(stage);
tree.stageHasState(stage, state);
return this;
}
public PipelineOverviewPage stageHasStateInLogs(String stage, PipelineState state) {
// ensure that it is selected
tree.searchForStage(stage);
tree.selectStage(stage);
logs.stageHasState(stage, state);
return this;
}
public InputPage clickInputWithParameters() {
tree.clickInputWithParameters();
return new InputPage(page, jobUrl).waitForLoaded();
}
public PipelineOverviewPage clickProceed() {
tree.clickProceed();
return this;
}
public PipelineOverviewPage clearSearch() {
tree.clearSearch();
return this;
}
public PipelineOverviewPage filterBy(PipelineState filter) {
tree.filterBy(filter);
return this;
}
public PipelineOverviewPage resetFilter() {
tree.resetFilter();
return this;
}
public PipelineOverviewPage stageIsVisibleInTree(String stage) {
tree.stageIsVisible(stage);
return this;
}
public PipelineOverviewPage configure() {
page.click("#console-pipeline-overflow-root");
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Configure"))
.click();
return this;
}
public PipelineOverviewPage cancel() {
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"))
.click();
Locator dialog = page.getByRole(AriaRole.DIALOG);
dialog.getByText("Yes").click();
assertThat(dialog).isHidden();
return this;
}
public PipelineOverviewPage rerun() {
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Rerun"))
.click();
return this;
}
public PipelineOverviewPage replay() {
page.click("#pgv-rerun-overflow");
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Replay"))
.click();
return this;
}
public PipelineOverviewPage rebuild() {
page.click("#pgv-rerun-overflow");
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Rebuild"))
.click();
return this;
}
public PipelineOverviewPage restartFromStage() {
page.click("#pgv-rerun-overflow");
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Restart from Stage"))
.click();
return this;
}
public PipelineOverviewPage scrollToText(String text) {
logs.scrollToText(text);
return this;
}
}