Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI test cleanup #1075

Merged
merged 52 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
aab56c1
Bump git-forensics from 1.1.0 to 1.2.1
dependabot[bot] Sep 20, 2021
a1ac552
Bump analysis-pom from 5.9.0 to 5.10.0
dependabot[bot] Sep 27, 2021
f78f9ff
Bump echarts-api from 5.1.2-11 to 5.2.1-2
dependabot[bot] Oct 5, 2021
e315314
Bump data-tables-api from 1.11.2-1 to 1.11.3-1
dependabot[bot] Oct 8, 2021
b888907
Bump analysis-model-api from 10.3.0 to 10.5.1
dependabot[bot] Oct 11, 2021
bf69a1a
Bump codingstyle-pom from 2.9.0 to 2.11.0
dependabot[bot] Oct 11, 2021
57caaee
Bump forensics-api from 1.2.1 to 1.5.0
dependabot[bot] Oct 12, 2021
6cd8680
Merge remote-tracking branch 'origin/dependabot/maven/io.jenkins.plug…
uhafner Oct 13, 2021
dffc62c
Merge remote-tracking branch 'origin/dependabot/maven/edu.hm.hafner-c…
uhafner Oct 13, 2021
2bbf715
Merge remote-tracking branch 'origin/dependabot/maven/io.jenkins.plug…
uhafner Oct 13, 2021
2333ee4
Merge remote-tracking branch 'origin/dependabot/maven/io.jenkins.plug…
uhafner Oct 13, 2021
85fc340
Merge remote-tracking branch 'origin/dependabot/maven/io.jenkins.plug…
uhafner Oct 13, 2021
9dc19ea
Merge remote-tracking branch 'origin/dependabot/maven/io.jenkins.plug…
uhafner Oct 13, 2021
5f58267
Merge remote-tracking branch 'origin/master' into dependabot/maven/or…
uhafner Oct 13, 2021
cd50846
Set version of commons-net to 3.8.0.
uhafner Oct 13, 2021
85ce442
Fix API changes in HTML unit.
uhafner Oct 15, 2021
bc0e803
Improve JavaDoc.
uhafner Oct 15, 2021
e5cea2c
Update test with new URL of static analysis tool.
uhafner Oct 15, 2021
17776e1
Update test with new capitalization of logging messages.
uhafner Oct 15, 2021
7aff44e
Fix JavaDoc and some warnings.
uhafner Oct 15, 2021
7418bc8
Fixed all tests.
uhafner Oct 15, 2021
969715b
Add profile to run all UI tests.
uhafner Oct 15, 2021
f85e751
Fix and ignore some warnings.
uhafner Oct 15, 2021
f6424f8
Fix some warnings.
uhafner Oct 16, 2021
132fd6d
Add a test suite.
uhafner Oct 16, 2021
bb0fa08
Merge remote-tracking branch 'origin/dependabot/maven/org.jvnet.hudso…
uhafner Oct 16, 2021
d3b1f9b
Fix some warnings.
uhafner Oct 16, 2021
1252cf8
Bump version of Jenkins baseline to 2.277.1.
uhafner Oct 16, 2021
9433343
Bump version of Jenkins baseline to 2.277.4 since workflow-multibranc…
uhafner Oct 16, 2021
0e7cd22
Remove broken test.
uhafner Oct 16, 2021
ad284a6
Bump version of token macro to 266.v44a80cf277fd.
uhafner Oct 16, 2021
7304fa5
Extract tool names as constants.
uhafner Oct 16, 2021
e7e79dd
Deactivate RevAPI.
uhafner Oct 16, 2021
9e37950
Remove assertion that does nothing.
uhafner Oct 16, 2021
954833b
Fix PMD warning.
uhafner Oct 16, 2021
3c9e952
Create an inheritance hierarchy for issues tables.
uhafner Oct 16, 2021
98fb434
Refactoring of table and row structure.
uhafner Oct 17, 2021
ae52d0a
Exclude AbstractIssuesTable from assertions generator.
uhafner Oct 17, 2021
6853cda
Fix and suppress some warnings.
uhafner Oct 17, 2021
93aa098
Fix and suppress some warnings.
uhafner Oct 18, 2021
609c4e7
Cleanup.
uhafner Oct 18, 2021
5123eb0
Fix compile error.
uhafner Oct 18, 2021
dfa6c0f
Fix typo.
uhafner Oct 18, 2021
fdb75a1
Enable 2 more UI tests in action.
uhafner Oct 18, 2021
4791556
Use super class constants.
uhafner Oct 18, 2021
5b2d003
Refactor table rows.
uhafner Oct 19, 2021
c884f0a
Fix warnings.
uhafner Oct 19, 2021
75d57ae
Fix row refactoring: handle details row.
uhafner Oct 19, 2021
90bd62d
Fix test case.
uhafner Oct 20, 2021
4d10178
Suppress some warnings.
uhafner Oct 20, 2021
61e7141
Ignore some Git tests to speed up workflow.
uhafner Oct 20, 2021
8c7c080
Remove Git tests from CI, they are too slow.
uhafner Oct 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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