Skip to content

Commit

Permalink
Merge pull request #1075 from jenkinsci/ui-test-cleanup
Browse files Browse the repository at this point in the history
UI test cleanup
  • Loading branch information
uhafner authored Oct 20, 2021
2 parents 9ab8d16 + 8c7c080 commit c739437
Show file tree
Hide file tree
Showing 50 changed files with 1,396 additions and 1,892 deletions.
145 changes: 145 additions & 0 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: 'Run UI tests'

on:
push:
branches:
- master
pull_request:

jobs:
details-tab:
runs-on: [ubuntu-latest]
name: Details tab UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run UI tests for the details tabs
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=DetailsTabUiTest -Dgpg.skip

dashboard-view:
runs-on: [ubuntu-latest]
name: Dashboard view UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run UI tests for the dashboard view
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=DashboardViewPortletUiTest -Dgpg.skip

freestyle-configuration:
runs-on: [ubuntu-latest]
name: Freestyle configuration UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run UI tests for the freestyle configuration
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=FreeStyleConfigurationUiTest -Dgpg.skip

pipeline-snippet-generator:
runs-on: [ubuntu-latest]
name: Pipeline snippet configurator UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run UI tests for the pipeline snippet configurator
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=SnippetGeneratorUiTest -Dgpg.skip

global-configuration:
runs-on: [ubuntu-latest]
name: Global configuration UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run UI tests for Jenkins' global configuration
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=GlobalConfigurationUiTest -Dgpg.skip

issues-column:
runs-on: [ubuntu-latest]
name: Issues column UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run UI tests for the issues column
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=IssuesColumnUiTest -Dgpg.skip

trend-charts:
runs-on: [ubuntu-latest]
name: Trend charts UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run UI tests for the trend charts
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=TrendChartsUiTest -Dgpg.skip

miscenaleous:
runs-on: [ubuntu-latest]
name: Miscellaneous UI tests

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build warnings plugin and download dependencies
run: mvn -V -ntp verify -Pskip --file plugin/pom.xml -Dgpg.skip
- name: Run miscellaneous UI tests of the warnings plugin
env:
BROWSER: firefox-container
run: mvn -V -ntp test --file ui-tests/pom.xml -Dtest=TrendChartsUiTest -Dgpg.skip

2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def configurations = [
[ platform: "linux", jdk: "11" ],
[ platform: "docker", jdk: "11" ],
[ platform: "windows", jdk: "11" ]
]

Expand Down
22 changes: 14 additions & 8 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>5.9.0</version>
<version>5.12.0</version>
<relativePath />
</parent>

Expand All @@ -25,15 +25,15 @@
<changelist>-SNAPSHOT</changelist>
<module.name>${project.groupId}.warnings.ng</module.name>

<analysis-model-api.version>10.3.0</analysis-model-api.version>
<analysis-model-tests.version>10.3.0</analysis-model-tests.version>
<analysis-model-api.version>10.5.1</analysis-model-api.version>
<analysis-model-tests.version>10.5.1</analysis-model-tests.version>

<forensics-api-plugin.version>1.2.1</forensics-api-plugin.version>
<forensics-api-plugin.version>1.5.0</forensics-api-plugin.version>
<plugin-util-api.version>2.5.0</plugin-util-api.version>

<data-tables-api.version>1.11.2-1</data-tables-api.version>
<data-tables-api.version>1.11.3-1</data-tables-api.version>
<font-awesome-api.version>5.15.4-1</font-awesome-api.version>
<echarts-api.version>5.1.2-11</echarts-api.version>
<echarts-api.version>5.2.1-2</echarts-api.version>
<jquery3-api.version>3.6.0-2</jquery3-api.version>
<bootstrap5-api.version>5.1.1-1</bootstrap5-api.version>
<popper-api.version>1.16.1-2</popper-api.version>
Expand All @@ -53,8 +53,8 @@

<!-- Jenkins Plug-in Dependencies Versions -->
<autograding.version>3.3.1</autograding.version>
<git-forensics.version>1.1.0</git-forensics.version>
<token-macro.version>2.13</token-macro.version>
<git-forensics.version>1.2.1</git-forensics.version>
<token-macro.version>266.v44a80cf277fd</token-macro.version>
<jenkins-maven-plugin.version>3.8</jenkins-maven-plugin.version>
<matrix-project.version>1.18</matrix-project.version>
<junit-plugin.version>1.35</junit-plugin.version>
Expand Down Expand Up @@ -122,6 +122,11 @@
<artifactId>jquery3-api</artifactId>
<version>${jquery3-api.version}</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.8.0</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -640,6 +645,7 @@
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<configuration>
<skip>true</skip> <!-- FIXME: find a better workaround for https://github.com/revapi/revapi/issues/253 -->
<failBuildOnProblemsFound>true</failBuildOnProblemsFound>
<!-- Including provided-scope dependencies like Jenkins core results in too many false positives -->
<checkDependencies>false</checkDependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.junit.jupiter.api.Test;

import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.SerializableTest;

import hudson.model.Run;

Expand All @@ -19,22 +18,17 @@
*
* @author Ullrich Hafner
*/
class ResultActionTest extends SerializableTest<ResultAction> {
class ResultActionTest {
@Test
void shouldRestoreRun() {
ResultAction action = createSerializable();
ResultAction action = new ResultAction(null, mock(AnalysisResult.class),
new HealthDescriptor(0, 0, Severity.WARNING_HIGH),
"ID", "Name", StandardCharsets.UTF_8);

assertThat(action.getOwner()).isNull();

Run<?, ?> run = mock(Run.class);
action.onAttached(run);
assertThat(action.getOwner()).isSameAs(run);
}

@Override
protected ResultAction createSerializable() {
return new ResultAction(null, mock(AnalysisResult.class),
new HealthDescriptor(0, 0, Severity.WARNING_HIGH),
"ID", "Name", StandardCharsets.UTF_8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void shouldParseHtmlMessage() {
.containsOnly(new ChecksAnnotationBuilder()
.withMessage("ERROR:\n"
+ "Some diagnostic messages may contain incorrect line number.\n"
+ "V002:https://www.viva64.com/en/w/v002/")
+ "V002:https://pvs-studio.com/en/docs/warnings/v002/")
.build());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package io.jenkins.plugins.analysis.core.util;

import java.lang.reflect.Field;
import java.util.concurrent.CopyOnWriteArrayList;

import org.junit.jupiter.api.Test;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import org.jenkinsci.plugins.workflow.actions.WarningAction;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import hudson.model.Result;
Expand All @@ -22,24 +17,17 @@ class StageResultHandlerTest {

@Test
void defaultHandlerShouldSetBuildResult() {
Run run = mock(Run.class);
Run<?, ?> run = mock(Run.class);
StageResultHandler defaultHandler = new RunResultHandler(run);
defaultHandler.setResult(Result.UNSTABLE, "something");
verify(run).setResult(Result.UNSTABLE);
}

@Test
@SuppressWarnings("ConstantConditions")
@SuppressFBWarnings(value = "DP_DO_INSIDE_DO_PRIVILEGED",
justification = "Needed to keep `FlowNode.getPersistentAction` from failing. "
+ "We can't mock the method directly because it's final.")
void pipelineHandlerShouldSetBuildResultAndAddWarningAction()
throws IllegalAccessException, IllegalArgumentException, NoSuchFieldException {
Run run = mock(Run.class);
void pipelineHandlerShouldSetBuildResultAndAddWarningAction() {
Run<?, ?> run = mock(Run.class);
FlowNode flowNode = mock(FlowNode.class);
Field actions = FlowNode.class.getDeclaredField("actions");
actions.setAccessible(true);
actions.set(flowNode, new CopyOnWriteArrayList<>());
StageResultHandler pipelineHandler = new PipelineResultHandler(run, flowNode);
pipelineHandler.setResult(Result.UNSTABLE, MESSAGE);
verify(run).setResult(Result.UNSTABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
import org.jvnet.hudson.test.JenkinsRule.WebClient;
import org.xml.sax.SAXException;

import com.gargoylesoftware.htmlunit.WebResponse;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNodeList;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.parser.neko.HtmlUnitNekoHtmlParser;

import edu.hm.hafner.analysis.Issue;

Expand Down Expand Up @@ -386,8 +384,7 @@ private Map<String, Long> collectPackageNames(final AnalysisResult result) {

private void checkWebPageForExpectedEmptyResult(final AnalysisResult result) {
try (WebClient webClient = createWebClient()) {
WebResponse webResponse = webClient.getPage(result.getOwner(), DEFAULT_ENTRY_PATH).getWebResponse();
HtmlPage htmlPage = new HtmlUnitNekoHtmlParser().parseHtml(webResponse, webClient.getCurrentWindow());
HtmlPage htmlPage = webClient.getPage(result.getOwner(), DEFAULT_ENTRY_PATH).getPage();
assertThat(getLinksWithGivenTargetName(htmlPage, DEFAULT_TAB_TO_INVESTIGATE)).isEmpty();
}
catch (IOException | SAXException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void shouldUseOtherJobAsReference() {
"[ReferenceFinder] Configured reference job: 'reference'",
"[ReferenceFinder] Found reference build '#1' for target branch",
"Obtaining reference build from reference recorder",
"-> found 'reference #1'");
"-> Found 'reference #1'");
}

/**
Expand All @@ -129,7 +129,7 @@ public void shouldHandleMissingJobBuildAsReference() {
assertThat(result.getOutstandingIssues()).hasSize(2);
assertThat(getConsoleLog(result)).contains(
"Obtaining reference build from reference recorder",
"-> no reference build recorded",
"-> No reference build recorded",
"Obtaining reference build from same job",
"No valid reference build found that meets the criteria (NO_JOB_FAILURE - SUCCESSFUL_QUALITY_GATE)",
"All reported issues will be considered outstanding");
Expand Down
8 changes: 6 additions & 2 deletions ui-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle-pom</artifactId>
<version>2.9.0</version>
<version>2.11.0</version>
<relativePath/>
</parent>

Expand All @@ -16,7 +16,7 @@
<name>UI Tests of Warnings Plugin</name>

<properties>
<jenkins.version>2.263.3</jenkins.version>
<jenkins.version>2.303.2</jenkins.version>
<json-smart.version>2.3</json-smart.version>
<json-unit-assertj.version>2.28.0</json-unit-assertj.version>
</properties>
Expand Down Expand Up @@ -132,6 +132,10 @@
<packages combine.children="append">
<package>io.jenkins.plugins.analysis.warnings</package>
</packages>
<excludes>
<exclude>.*Test</exclude>
<exclude>.*Table</exclude>
</excludes>
<entryPointClassPackage>io.jenkins.plugins.analysis.warnings</entryPointClassPackage>
</configuration>
</plugin>
Expand Down
Loading

0 comments on commit c739437

Please sign in to comment.