forked from jenkinsci/pipeline-graph-view-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipelineGraphViewTest.java
More file actions
205 lines (184 loc) · 8.56 KB
/
PipelineGraphViewTest.java
File metadata and controls
205 lines (184 loc) · 8.56 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
202
203
204
205
package io.jenkins.plugins.pipelinegraphview;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.junit.UsePlaywright;
import hudson.model.Result;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import io.jenkins.plugins.casc.misc.junit.jupiter.WithJenkinsConfiguredWithCode;
import io.jenkins.plugins.pipelinegraphview.playwright.ManageAppearancePage;
import io.jenkins.plugins.pipelinegraphview.playwright.PipelineJobPage;
import io.jenkins.plugins.pipelinegraphview.playwright.PlaywrightConfig;
import io.jenkins.plugins.pipelinegraphview.utils.PipelineState;
import io.jenkins.plugins.pipelinegraphview.utils.TestUtils;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.Issue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@WithJenkinsConfiguredWithCode
@UsePlaywright(PlaywrightConfig.class)
class PipelineGraphViewTest {
private static final Logger log = LoggerFactory.getLogger(PipelineGraphViewTest.class);
// Code generation can be generated against local using to give an idea of what commands to use
// mvn exec:java -e -D exec.mainClass="com.microsoft.playwright.CLI" -Dexec.classpathScope=test -Dexec.args="codegen
// http://localhost:8080/jenkins
@Test
void smokeTest(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "Integration Tests";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "smokeTest.jenkinsfile", Result.FAILURE);
new ManageAppearancePage(p, j.jenkins.getRootUrl())
.goTo()
.displayPipelineOnBuildPage()
.displayPipelineOnJobPage()
.setPipelineGraphAsConsoleProvider()
.displayNamesOnStageViewByDefault()
.displayDurationsOnStageViewByDefault()
.save();
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.hasStages(7, "Checkout", "Test", "A1", "A2", "Build", "B1", "B2")
.goToBuild()
.hasStagesInGraph(4, /*A*/ "Checkout", "Test", /*B*/ "Build", "Parallel")
.goToPipelineOverview()
.hasStagesInGraph(4, /*A*/ "Checkout", "Test", /*B*/ "Build", "Parallel")
.selectStageInGraph("Test")
.stageIsSelected("Test")
.searchForStage("B1")
.selectStageInTree("B1")
.stageIsSelectedInLogs("B1")
.stageHasSteps("Test B1", "Sleep", "Determine current directory")
.stepContainsText("Sleep", "Sleeping for 1 ms")
.stageHasState("Checkout", PipelineState.SUCCESS)
.clearSearch()
.filterBy(PipelineState.UNSTABLE)
.stageIsVisibleInTree("B2")
.filterBy(PipelineState.FAILURE)
.stageIsVisibleInTree("B2")
.stageIsVisibleInTree("A2")
.resetFilter()
.stageIsVisibleInTree("Checkout")
.stageIsVisibleInTree("A2")
.stageIsVisibleInTree("B2");
}
@Issue("GH#797")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void runningStageSelected(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "gh797";
WorkflowRun run = TestUtils.createAndRunJobNoWait(j, name, "gh797_errorAndContinueWithWait.jenkinsfile")
.waitForStart();
SemaphoreStep.waitForStart("wait/1", run);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(2, "Caught1", "Runs1")
.stageIsVisibleInTree("Parallel1")
.stageIsVisibleInTree("Runs1")
.stageIsSelected("Runs1");
SemaphoreStep.success("wait/1", run);
j.assertBuildStatus(Result.SUCCESS, j.waitForCompletion(run));
}
@Test
@ConfiguredWithCode("configure-appearance.yml")
void failedStageSelected(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "Pipeline Success Error Caught";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh797_errorAndContinue.jenkinsfile", Result.SUCCESS);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(2, "Caught1", "Runs1")
.stageIsVisibleInTree("Parallel1")
.stageIsVisibleInTree("Caught1")
.stageIsVisibleInTree("Runs1")
.stageIsSelected("Caught1");
}
@Issue("GH#815")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void nestedStage(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "Nested Stage";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh815_nestedStage.jenkinsfile", Result.SUCCESS);
new PipelineJobPage(p, run.getParent()).goTo().hasBuilds(1).nthBuild(0).hasStages(2, "Parent", "Child");
}
@Issue("GH#817")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void unicodePlainTextLogs(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "Stage with Emoji";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh817_unicodePlainTextLogs.jenkinsfile", Result.SUCCESS);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(1, "echo")
.selectStageInGraph("echo")
.stageHasSteps("\uD83D\uDE00")
.stepContainsText("\uD83D\uDE00", "\uD83D\uDE00");
}
@Issue("GH#744")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void searchOffScreen(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "gh744";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh744_searchOffScreen.jenkinsfile", Result.SUCCESS);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(1, "Stage")
.selectStageInGraph("Stage")
.stageHasSteps("Print Message")
.stepContainsText("Print Message", "Hello, world 1!")
.stepContainsText("Print Message", "Hello, world 1000!")
.scrollToText("Hello, world 1!")
.scrollToText("Hello, world 1000!")
.scrollToText("Hello, world 1!");
}
@Test
@ConfiguredWithCode("configure-appearance.yml")
void errorWithMessage(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "gh1169";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh1169_errorWithMessage.jenkinsfile", Result.FAILURE);
// Note that the locator used in stageHasSteps accumulates the error step's message text content into the found
// step name so we just check that instead of also calling stepContainText
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(1, "Stage")
.selectStageInGraph("Stage")
.stageHasSteps("Error signalError");
}
@Issue("GH#1169")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void errorWithNoMessage(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "gh1169";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh1169_errorWithNoMessage.jenkinsfile", Result.FAILURE);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(1, "Stage")
.selectStageInGraph("Stage")
.stageHasSteps("Error signal")
.stepDoesNotContainText("Error signal", "null");
}
}