Skip to content

The Unified and Autonomous Development Platform

feat: Able to render playwright json test report

Robin Shen030f1549c183
diff --git a/e2e-test/README.md b/e2e-test/README.md
index 992e21b8c0..deba02030a 100644
--- a/e2e-test/README.md
+++ b/e2e-test/README.md
@@ -23,6 +23,13 @@ By default Playwright starts `./dev.sh run` from the repository root and waits
up to ten minutes for `http://127.0.0.1:6610`. If a server is already listening
there, Playwright reuses it.
+When Playwright starts the server, it passes OneDev
+[unattended setup](https://docs.onedev.io/installation-guide/run-as-docker-container)
+environment variables so the first-run wizard is skipped: admin user/password
+`admin`/`admin`, email `[email protected]`, and `initial_server_url` set to
+`http://<host-ip>:6610` (SSH root URL left unset). These only apply on a fresh
+data directory.
+
To test a server started separately, or a server at another URL, use:
```bash
diff --git a/e2e-test/playwright.config.js b/e2e-test/playwright.config.js
index cdcbc39bb8..5d0879ff6e 100644
--- a/e2e-test/playwright.config.js
+++ b/e2e-test/playwright.config.js
@@ -1,3 +1,4 @@
+import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig, devices } from '@playwright/test';
@@ -6,6 +7,18 @@ const projectDir = path.dirname(fileURLToPath(import.meta.url));
const serverDir = path.resolve(projectDir, '..');
const baseURL = process.env.E2E_BASE_URL ?? 'http://127.0.0.1:6610';
+function getHostIp() {
+ for (const addresses of Object.values(os.networkInterfaces())) {
+ for (const address of addresses ?? []) {
+ const family = address.family;
+ if ((family === 'IPv4' || family === 4) && !address.internal) {
+ return address.address;
+ }
+ }
+ }
+ return '127.0.0.1';
+}
+
export default defineConfig({
testDir: './tests',
outputDir: './test-results',
@@ -13,6 +26,8 @@ export default defineConfig({
forbidOnly: Boolean(process.env.CI),
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? 'github' : 'html',
+ // OneDev's Wicket UI is sensitive to concurrent logins against a single server.
+ workers: 1,
use: {
baseURL,
trace: 'on-first-retry',
@@ -34,5 +49,12 @@ export default defineConfig({
timeout: 10 * 60 * 1000,
stdout: 'pipe',
stderr: 'pipe',
+ // Unattended first-run setup; see https://docs.onedev.io/installation-guide/run-as-docker-container
+ env: {
+ initial_user: 'admin',
+ initial_password: 'admin',
+ initial_email: '[email protected]',
+ initial_server_url: `http://${getHostIp()}:6610`,
+ },
},
});
diff --git a/e2e-test/tests/authorize-user.spec.js b/e2e-test/tests/authorize-user.spec.js
new file mode 100644
index 0000000000..6f3b629a93
--- /dev/null
+++ b/e2e-test/tests/authorize-user.spec.js
@@ -0,0 +1,23 @@
+import { expect, test } from '@playwright/test';
+import { authorizeUser, createProject, createUser, login } from './helpers.js';
+
+test('admin can authorize a user to a project with Issue Reporter role', async ({ page }) => {
+ test.setTimeout(90_000);
+
+ const suffix = Date.now();
+
+ await login(page, 'admin', 'admin');
+ const { userName } = await createUser(page, {
+ userName: `reporter${suffix}`,
+ password: 'reporter1',
+ });
+ const projectName = await createProject(page, `authorize-user-${suffix}`);
+
+ await authorizeUser(page, projectName, userName, 'Issue Reporter');
+
+ await page.goto(`${projectName}/~settings/user-authorizations`);
+ const authRow = page
+ .locator('.user-authorizations .bean-list tbody tr')
+ .filter({ hasText: userName });
+ await expect(authRow).toContainText('Issue Reporter');
+});
diff --git a/e2e-test/tests/confidential-issue.spec.js b/e2e-test/tests/confidential-issue.spec.js
new file mode 100644
index 0000000000..d812698b59
--- /dev/null
+++ b/e2e-test/tests/confidential-issue.spec.js
@@ -0,0 +1,84 @@
+import { expect, test } from '@playwright/test';
+import {
+ authorizeIssueUser,
+ authorizeUser,
+ createProject,
+ createUser,
+ login,
+ logout,
+ openIssue,
+} from './helpers.js';
+
+test.describe('confidential issue access', () => {
+ test.describe.configure({ mode: 'serial' });
+
+ /** @type {string} */
+ let projectName;
+ /** @type {{ userName: string, password: string }} */
+ let creator;
+ /** @type {{ userName: string, password: string }} */
+ let other;
+ /** @type {{ userName: string, password: string }} */
+ let granted;
+ /** @type {string} */
+ let issueUrl;
+ /** @type {string} */
+ let issueTitle;
+
+ test('normal user can access confidential issue created by himself', async ({ page }) => {
+ test.setTimeout(180_000);
+
+ const suffix = Date.now();
+
+ await login(page, 'admin', 'admin');
+ creator = await createUser(page, { userName: `creator${suffix}`, password: 'userpass1' });
+ other = await createUser(page, { userName: `other${suffix}`, password: 'userpass1' });
+ granted = await createUser(page, { userName: `granted${suffix}`, password: 'userpass1' });
+ projectName = await createProject(page, `confidential-${suffix}`);
+ await authorizeUser(page, projectName, creator.userName, 'Issue Reporter');
+ await authorizeUser(page, projectName, other.userName, 'Issue Reporter');
+ await authorizeUser(page, projectName, granted.userName, 'Issue Reporter');
+
+ await logout(page);
+ await login(page, creator.userName, creator.password);
+ ({ title: issueTitle, url: issueUrl } = await openIssue(page, projectName, {
+ title: `Confidential ${suffix}`,
+ confidential: true,
+ }));
+
+ await expect(
+ page.locator('.issue-editable-title [data-tippy-content="Confidential"]'),
+ ).toBeVisible();
+ await expect(page.locator('.issue-editable-title')).toContainText(issueTitle);
+ });
+
+ test('normal user cannot access confidential issue created by others', async ({ page }) => {
+ test.setTimeout(60_000);
+
+ await login(page, other.userName, other.password);
+ const response = await page.goto(issueUrl);
+
+ expect(response?.status()).toBe(403);
+ await expect(page.locator('.title h3')).toContainText('OOPS! There Is An Error');
+ await expect(page.locator('.sub-title')).toContainText('You are not allowed to perform this operation');
+ await expect(page.locator('.issue-editable-title')).toHaveCount(0);
+ });
+
+ test('normal user authorized to a confidential issue created by others can access it', async ({
+ page,
+ }) => {
+ test.setTimeout(90_000);
+
+ await login(page, creator.userName, creator.password);
+ await authorizeIssueUser(page, issueUrl, granted.userName);
+
+ await logout(page);
+ await login(page, granted.userName, granted.password);
+ await page.goto(issueUrl);
+
+ await expect(page.locator('.issue-editable-title')).toContainText(issueTitle);
+ await expect(
+ page.locator('.issue-editable-title [data-tippy-content="Confidential"]'),
+ ).toBeVisible();
+ });
+});
diff --git a/e2e-test/tests/create-project.spec.js b/e2e-test/tests/create-project.spec.js
new file mode 100644
index 0000000000..745a883c75
--- /dev/null
+++ b/e2e-test/tests/create-project.spec.js
@@ -0,0 +1,13 @@
+import { expect, test } from '@playwright/test';
+import { createProject, login } from './helpers.js';
+
+test('admin can create a project', async ({ page }) => {
+ test.setTimeout(60_000);
+
+ await login(page, 'admin', 'admin');
+ const projectName = await createProject(page);
+
+ await page.goto(projectName);
+ await expect(page).toHaveURL(new RegExp(`/${projectName}(/|$)`));
+ await expect(page.locator('.sidebar')).toContainText(projectName);
+});
diff --git a/e2e-test/tests/create-user.spec.js b/e2e-test/tests/create-user.spec.js
new file mode 100644
index 0000000000..ebfb127e54
--- /dev/null
+++ b/e2e-test/tests/create-user.spec.js
@@ -0,0 +1,13 @@
+import { expect, test } from '@playwright/test';
+import { createUser, login, logout } from './helpers.js';
+
+test('admin can create a user', async ({ page }) => {
+ test.setTimeout(60_000);
+
+ await login(page, 'admin', 'admin');
+ const { userName, password } = await createUser(page);
+
+ await logout(page);
+ await login(page, userName, password);
+ await expect(page).not.toHaveURL(/~login/);
+});
diff --git a/e2e-test/tests/helpers.js b/e2e-test/tests/helpers.js
new file mode 100644
index 0000000000..8bfe06a2f8
--- /dev/null
+++ b/e2e-test/tests/helpers.js
@@ -0,0 +1,182 @@
+import { expect } from '@playwright/test';
+
+/**
+ * @param {import('@playwright/test').Page} page
+ * @param {string} userName
+ * @param {string} password
+ */
+export async function login(page, userName, password) {
+ await page.goto('~login');
+ await page.getByPlaceholder('Login name or email address', { exact: true }).fill(userName);
+ await page.locator('form input[type="password"]').fill(password);
+ await page.getByRole('button', { name: 'Sign in' }).click();
+ await page.waitForURL((url) => !url.pathname.includes('~login'));
+}
+
+/**
+ * @param {import('@playwright/test').Page} page
+ */
+export async function logout(page) {
+ await page.goto('~logout');
+ await page.waitForURL(/~login/);
+}
+
+/**
+ * Locate a BeanEditor form-group by its visible label text.
+ * @param {import('@playwright/test').Page | import('@playwright/test').Locator} root
+ * @param {string} label
+ */
+export function formGroup(root, label) {
+ return root.locator('.form-group').filter({
+ has: root.locator('label.name > span').getByText(label, { exact: true }),
+ });
+}
+
+/**
+ * @param {import('@playwright/test').Page | import('@playwright/test').Locator} root
+ * @param {string} label
+ * @param {string} value
+ */
+export async function fillLabeledInput(root, label, value) {
+ await formGroup(root, label).locator('input.form-control, textarea.form-control').first().fill(value);
+}
+
+/**
+ * Fill a confirmative password editor (password + confirm).
+ * @param {import('@playwright/test').Page | import('@playwright/test').Locator} root
+ * @param {string} password
+ */
+export async function fillConfirmativePassword(root, password) {
+ const group = formGroup(root, 'Password');
+ await group.getByPlaceholder('Type password here').fill(password);
+ await group.getByPlaceholder('Confirm password here').fill(password);
+}
+
+/**
+ * Create a user via the admin UI. Caller must be logged in as an administrator.
+ * @param {import('@playwright/test').Page} page
+ * @param {{ userName?: string, password?: string, email?: string }} [options]
+ * @returns {Promise<{ userName: string, password: string, email: string }>}
+ */
+export async function createUser(page, options = {}) {
+ const suffix = Date.now();
+ const userName = options.userName ?? `user${suffix}`;
+ const password = options.password ?? 'userpass1';
+ const email = options.email ?? `${userName}@example.com`;
+
+ await page.goto('~administration/users/new');
+ await fillLabeledInput(page, 'Login Name', userName);
+ await fillConfirmativePassword(page, password);
+ await fillLabeledInput(page, 'Email Address', email);
+ await page.getByRole('button', { name: 'Create' }).click();
+ await expect(page.locator('#session-feedback')).toContainText('New user created');
+
+ return { userName, password, email };
+}
+
+/**
+ * Create a project via the UI. Caller must be logged in with permission to create projects.
+ * @param {import('@playwright/test').Page} page
+ * @param {string} [projectName]
+ * @returns {Promise<string>}
+ */
+export async function createProject(page, projectName) {
+ const name = projectName ?? `project${Date.now()}`;
+
+ await page.goto('~projects/new');
+ await fillLabeledInput(page, 'Name', name);
+ await page.getByRole('button', { name: 'Create' }).click();
+ await expect(page.locator('#session-feedback')).toContainText('New project created');
+ await expect(page).toHaveURL(new RegExp(`/${name}(/|$)`));
+
+ return name;
+}
+
+/**
+ * Authorize a user on a project with the given role.
+ * @param {import('@playwright/test').Page} page
+ * @param {string} projectName
+ * @param {string} userName
+ * @param {string} roleName
+ */
+export async function authorizeUser(page, projectName, userName, roleName) {
+ await page.goto(`${projectName}/~settings/user-authorizations`);
+ const authRows = page.locator('.user-authorizations .bean-list tbody tr');
+ const countBefore = await authRows.count();
+ await page.locator('.user-authorizations a.add-element').click();
+ await expect(authRows).toHaveCount(countBefore + 1);
+ const authRow = authRows.last();
+ await select2Choose(page, authRow.locator('td').nth(1), userName);
+ await select2Choose(page, authRow.locator('td').nth(2), roleName);
+ await page.getByRole('button', { name: 'Save' }).click();
+ await expect(page.locator('#session-feedback')).toContainText('User authorizations updated');
+}
+
+/**
+ * Open (create) an issue in a project. Caller must be logged in with permission to create issues.
+ * @param {import('@playwright/test').Page} page
+ * @param {string} projectName
+ * @param {{ title?: string, confidential?: boolean }} [options]
+ * @returns {Promise<{ title: string, url: string }>}
+ */
+export async function openIssue(page, projectName, options = {}) {
+ const title = options.title ?? `Issue ${Date.now()}`;
+ const confidential = options.confidential ?? false;
+
+ await page.goto(`${projectName}/~issues/new`);
+ await page.getByPlaceholder('Input title here').fill(title);
+ if (confidential) {
+ const confidentialSwitch = page.locator('.form-group.confidential .switch');
+ await confidentialSwitch.scrollIntoViewIfNeeded();
+ await confidentialSwitch.locator('label').click();
+ }
+ await page.getByRole('button', { name: 'Save' }).click();
+
+ await expect(page).toHaveURL(new RegExp(`/${projectName}/~issues/\\d+`));
+ await expect(page.locator('.issue-editable-title')).toContainText(title);
+
+ return { title, url: page.url() };
+}
+
+/**
+ * Authorize an additional user on a confidential issue. Caller must be able to modify the issue.
+ * @param {import('@playwright/test').Page} page
+ * @param {string} issueUrl Absolute or relative issue detail URL
+ * @param {string} userName
+ */
+export async function authorizeIssueUser(page, issueUrl, userName) {
+ const authorizationsUrl = issueUrl.replace(/\/?$/, '') + '/authorizations';
+ await page.goto(authorizationsUrl);
+ await select2Choose(page, page.locator('.issue-authorization-list'), userName);
+ await expect(page.locator('#session-feedback')).toContainText('User authorized');
+ await expect(page.locator('.issue-authorization-list .authorizations')).toContainText(userName);
+}
+
+/**
+ * Select an option in a Select2 single or multi choice.
+ * @param {import('@playwright/test').Page} page
+ * @param {import('@playwright/test').Locator} container
+ * @param {string} optionText
+ */
+export async function select2Choose(page, container, optionText) {
+ const select2 = container.locator('.select2-container').first();
+ const isMulti = await select2.evaluate((el) => el.classList.contains('select2-container-multi'));
+ if (isMulti) {
+ const multiInput = select2.locator('input.select2-input');
+ await multiInput.click();
+ await multiInput.fill(optionText);
+ } else {
+ await select2.locator('.select2-choice').click();
+ await page.locator('#select2-drop input.select2-input').fill(optionText);
+ }
+ await page
+ .locator('#select2-drop .select2-result-selectable')
+ .filter({ hasText: optionText })
+ .first()
+ .click();
+ await page.locator('#select2-drop').waitFor({ state: 'hidden' }).catch(() => {});
+ if (isMulti && (await page.locator('#select2-drop').isVisible().catch(() => false))) {
+ await page.keyboard.press('Escape');
+ await page.locator('#select2-drop').waitFor({ state: 'hidden' }).catch(() => {});
+ }
+}
diff --git a/e2e-test/tests/open-issue.spec.js b/e2e-test/tests/open-issue.spec.js
new file mode 100644
index 0000000000..805d261e7c
--- /dev/null
+++ b/e2e-test/tests/open-issue.spec.js
@@ -0,0 +1,12 @@
+import { expect, test } from '@playwright/test';
+import { createProject, login, openIssue } from './helpers.js';
+
+test('admin can open an issue', async ({ page }) => {
+ test.setTimeout(60_000);
+
+ await login(page, 'admin', 'admin');
+ const projectName = await createProject(page);
+
+ const { title } = await openIssue(page, projectName);
+ await expect(page.locator('.issue-editable-title')).toContainText(title);
+});
diff --git a/server-core/src/main/java/io/onedev/server/util/HtmlUtils.java b/server-core/src/main/java/io/onedev/server/util/HtmlUtils.java
index 10e6b7cd95..d1a7700f0d 100644
--- a/server-core/src/main/java/io/onedev/server/util/HtmlUtils.java
+++ b/server-core/src/main/java/io/onedev/server/util/HtmlUtils.java
@@ -1,13 +1,18 @@
package io.onedev.server.util;
-import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.regex.Matcher;
+
import org.jsoup.Jsoup;
-import org.jsoup.nodes.*;
+import org.jsoup.nodes.Attribute;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.nodes.Node;
+import org.jsoup.nodes.TextNode;
import org.jsoup.safety.Cleaner;
import org.jsoup.safety.Safelist;
-import java.util.Collection;
-import java.util.regex.Matcher;
+import com.google.common.collect.Lists;
public class HtmlUtils {
@@ -110,5 +115,5 @@ public class HtmlUtils {
public static String getText(String html) {
return Jsoup.parse(html).text();
}
-
+
}
diff --git a/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.css b/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.css
index 9d839b7e07..093de6b17f 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.css
+++ b/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.css
@@ -43,6 +43,11 @@ a.side-info {
/* Stretch the pane so its border spans the full content height, while keeping
its content pinned under the top chrome in the shared page scroller. */
@media(min-width: 1199px) {
+ /* Hide the ellipsis until JS applies side-info-visible. Otherwise a refresh
+ paints the trigger, then onDomReady opens the pinned pane and hides it. */
+ html:not(.hide-side-info):not(.side-info-ready) a.side-info {
+ display: none;
+ }
div.side-info>.content {
position: sticky;
top: 0;
diff --git a/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.js b/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.js
index 754fd4b4fe..7c5e8a0148 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.js
+++ b/server-core/src/main/java/io/onedev/server/web/component/sideinfo/side-info.js
@@ -54,9 +54,12 @@ onedev.server.sideInfo = {
var mql = window.matchMedia("(max-width: 1198px)");
// Wide pinned layouts restore from cookie (default open); overlay stays closed until opened
- if (!overlayMode && Cookies.get(onedev.server.sideInfo.cookieKey) != "false")
- $container.removeClass("closed");
+ if (!overlayMode && Cookies.get(onedev.server.sideInfo.cookieKey) != "false") {
+ $container.addClass("no-animation").removeClass("closed");
+ requestAnimationFrame(function(){$container.removeClass("no-animation");});
+ }
onedev.server.sideInfo.syncTrigger($container);
+ $("html").addClass("side-info-ready");
function onBreakpointChange() {
var nextOverlayMode = onedev.server.sideInfo.isOverlayMode($container);
diff --git a/server-core/src/main/java/io/onedev/server/web/page/base/base.css b/server-core/src/main/java/io/onedev/server/web/page/base/base.css
index 079064f41a..fc35ce8c5b 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/base/base.css
+++ b/server-core/src/main/java/io/onedev/server/web/page/base/base.css
@@ -584,6 +584,10 @@ pre>.actions>a {
background: var(--dark-mode-dark);
}
+.whitespace-pre-wrap {
+ white-space: pre-wrap;
+}
+
.spin {
animation-name: spin;
animation-duration: 2000ms;
diff --git a/server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/build-detail.css b/server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/build-detail.css
index d63eddab57..7be36e0fba 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/build-detail.css
+++ b/server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/build-detail.css
@@ -8,6 +8,10 @@
.build-detail>.card-body>.main>.error-message {
max-height: 100px;
}
+/* Let the main flex column shrink without pushing side info out of the card. */
+.build-detail>.card-body>.main {
+ min-width: 0;
+}
.build-detail>.card-body>.main>.description {
border-width: 2px !important;
}
diff --git a/server-core/src/main/java/io/onedev/server/web/util/MimeUtils.java b/server-core/src/main/java/io/onedev/server/web/util/MimeUtils.java
index 4f108ee91e..baa82a3a67 100644
--- a/server-core/src/main/java/io/onedev/server/web/util/MimeUtils.java
+++ b/server-core/src/main/java/io/onedev/server/web/util/MimeUtils.java
@@ -1,16 +1,20 @@
package io.onedev.server.web.util;
import org.apache.tika.mime.MimeTypes;
+import org.jspecify.annotations.Nullable;
public class MimeUtils {
- public static String sanitize(String mediaType) {
- if (mediaType.startsWith("image/") || mediaType.startsWith("video/")
- || mediaType.equals("application/json") || mediaType.equals("application/xml")) {
+ public static String sanitize(@Nullable String mediaType) {
+ if (mediaType == null || mediaType.startsWith("image/svg")
+ || mediaType.equals("application/xml")) {
+ return MimeTypes.OCTET_STREAM;
+ } else if (mediaType.startsWith("image/") || mediaType.startsWith("video/")
+ || mediaType.equals("application/json")) {
return mediaType;
} else if (mediaType.startsWith("text/")) {
return MimeTypes.PLAIN_TEXT;
- } else {
+ } else {
return MimeTypes.OCTET_STREAM;
}
}
diff --git a/server-plugin/pom.xml b/server-plugin/pom.xml
index dcb8067311..8ebaf8d504 100644
--- a/server-plugin/pom.xml
+++ b/server-plugin/pom.xml
@@ -59,6 +59,7 @@
<module>server-plugin-report-cpd</module>
<module>server-plugin-report-markdown</module>
<module>server-plugin-report-jest</module>
+ <module>server-plugin-report-playwright</module>
<module>server-plugin-report-clover</module>
<module>server-plugin-report-cobertura</module>
<module>server-plugin-report-checkstyle</module>
diff --git a/server-plugin/server-plugin-report-gtest/src/main/java/io/onedev/server/plugin/report/gtest/GTestReportParser.java b/server-plugin/server-plugin-report-gtest/src/main/java/io/onedev/server/plugin/report/gtest/GTestReportParser.java
index 717b17f432..12093f93cd 100644
--- a/server-plugin/server-plugin-report-gtest/src/main/java/io/onedev/server/plugin/report/gtest/GTestReportParser.java
+++ b/server-plugin/server-plugin-report-gtest/src/main/java/io/onedev/server/plugin/report/gtest/GTestReportParser.java
@@ -75,7 +75,7 @@ public class GTestReportParser {
@Nullable
@Override
- protected Component renderDetail(String componentId, Build build) {
+ protected Component renderDetail(String componentId, Build build, String reportName) {
return renderMessage(componentId, build, blobLocation, message);
}
});
@@ -100,7 +100,7 @@ public class GTestReportParser {
@Nullable
@Override
- protected Component renderDetail(String componentId, Build build) {
+ protected Component renderDetail(String componentId, Build build, String reportName) {
return renderMessage(componentId, build, blobLocation, message);
}
});
diff --git a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestReportParser.java b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestReportParser.java
index de838cdec0..30a9f7ff72 100644
--- a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestReportParser.java
+++ b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestReportParser.java
@@ -1,6 +1,21 @@
package io.onedev.server.plugin.report.jest;
+import static org.unbescape.html.HtmlEscape.escapeHtml5;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.jspecify.annotations.Nullable;
+
import com.fasterxml.jackson.databind.JsonNode;
+
import io.onedev.commons.utils.PlanarRange;
import io.onedev.server.git.BlobIdent;
import io.onedev.server.model.Build;
@@ -11,19 +26,6 @@ import io.onedev.server.security.SecurityUtils;
import io.onedev.server.util.StringTransformer;
import io.onedev.server.web.page.project.blob.ProjectBlobPage;
import io.onedev.server.web.page.project.blob.render.BlobRenderer;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.wicket.Component;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import org.jspecify.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import static org.unbescape.html.HtmlEscape.escapeHtml5;
public class JestReportParser {
@@ -85,7 +87,7 @@ public class JestReportParser {
private static final long serialVersionUID = 1L;
@Override
- protected Component renderDetail(String componentId, Build build) {
+ protected Component renderDetail(String componentId, Build build, String reportName) {
return JestReportParser.renderMessage(componentId, build, testCaseMessage);
}
diff --git a/server-plugin/server-plugin-report-junit/src/main/java/io/onedev/server/plugin/report/junit/JUnitReportParser.java b/server-plugin/server-plugin-report-junit/src/main/java/io/onedev/server/plugin/report/junit/JUnitReportParser.java
index cc2a99a4f4..0d5bf1ee97 100644
--- a/server-plugin/server-plugin-report-junit/src/main/java/io/onedev/server/plugin/report/junit/JUnitReportParser.java
+++ b/server-plugin/server-plugin-report-junit/src/main/java/io/onedev/server/plugin/report/junit/JUnitReportParser.java
@@ -1,19 +1,20 @@
package io.onedev.server.plugin.report.junit;
-import io.onedev.commons.utils.StringUtils;
-import io.onedev.server.model.Build;
-import io.onedev.server.plugin.report.unittest.UnitTestReport.Status;
-import io.onedev.server.plugin.report.unittest.UnitTestReport.TestCase;
-import io.onedev.server.plugin.report.unittest.UnitTestReport.TestSuite;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.dom4j.Document;
import org.dom4j.Element;
-
import org.jspecify.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+
+import io.onedev.commons.utils.StringUtils;
+import io.onedev.server.model.Build;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.Status;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.TestCase;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.TestSuite;
public class JUnitReportParser {
@@ -69,9 +70,8 @@ public class JUnitReportParser {
if (testCaseElement.element("skipped") != null) {
testCases.add(new TestCase(testSuite, name, Status.NOT_RUN, "skipped", 0) {
- @Nullable
@Override
- protected Component renderDetail(String componentId, Build build) {
+ protected Component renderDetail(String componentId, Build build, String reportName) {
return null;
}
});
@@ -92,9 +92,8 @@ public class JUnitReportParser {
}
testCases.add(new TestCase(testSuite, name, status, null, duration) {
- @Nullable
@Override
- protected Component renderDetail(String componentId, Build build) {
+ protected Component renderDetail(String componentId, Build build, String reportName) {
if (message != null)
return new Label(componentId, message);
else
diff --git a/server-plugin/server-plugin-report-playwright/pom.xml b/server-plugin/server-plugin-report-playwright/pom.xml
new file mode 100644
index 0000000000..02788b00bf
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/pom.xml
@@ -0,0 +1,20 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>server-plugin-report-playwright</artifactId>
+ <parent>
+ <groupId>io.onedev</groupId>
+ <artifactId>server-plugin</artifactId>
+ <version>16.5.6</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>io.onedev</groupId>
+ <artifactId>server-plugin-report-unittest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <moduleClass>io.onedev.server.plugin.report.playwright.PlaywrightModule</moduleClass>
+ </properties>
+</project>
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightModule.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightModule.java
new file mode 100644
index 0000000000..bd03757dcd
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightModule.java
@@ -0,0 +1,39 @@
+package io.onedev.server.plugin.report.playwright;
+
+import java.util.Collection;
+
+import com.google.common.collect.Sets;
+
+import io.onedev.commons.loader.AbstractPluginModule;
+import io.onedev.commons.loader.ImplementationProvider;
+import io.onedev.server.buildspec.step.PublishReportStep;
+import io.onedev.server.web.WebApplicationConfigurator;
+import io.onedev.server.web.mapper.BaseResourceMapper;
+
+public class PlaywrightModule extends AbstractPluginModule {
+
+ @Override
+ protected void configure() {
+ super.configure();
+
+ contribute(ImplementationProvider.class, new ImplementationProvider() {
+
+ @Override
+ public Class<?> getAbstractClass() {
+ return PublishReportStep.class;
+ }
+
+ @Override
+ public Collection<Class<?>> getImplementations() {
+ return Sets.newHashSet(PublishPlaywrightReportStep.class);
+ }
+
+ });
+
+ contribute(WebApplicationConfigurator.class, application -> application.mount(
+ new BaseResourceMapper(
+ "~downloads/projects/${project}/builds/${build}/playwright/${report}",
+ new PlaywrightReportDownloadResourceReference())));
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportCssResourceReference.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportCssResourceReference.java
new file mode 100644
index 0000000000..7392d2d30f
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportCssResourceReference.java
@@ -0,0 +1,13 @@
+package io.onedev.server.plugin.report.playwright;
+
+import io.onedev.server.web.page.base.BaseDependentCssResourceReference;
+
+public class PlaywrightReportCssResourceReference extends BaseDependentCssResourceReference {
+
+ private static final long serialVersionUID = 1L;
+
+ public PlaywrightReportCssResourceReference() {
+ super(PlaywrightReportCssResourceReference.class, "playwright-report.css");
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportDownloadResource.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportDownloadResource.java
new file mode 100644
index 0000000000..8d6ba49636
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportDownloadResource.java
@@ -0,0 +1,108 @@
+package io.onedev.server.plugin.report.playwright;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityNotFoundException;
+
+import org.apache.shiro.authz.UnauthorizedException;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.request.resource.AbstractResource;
+import org.apache.wicket.request.resource.ContentDisposition;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+
+import io.onedev.commons.utils.ExplicitException;
+import io.onedev.commons.utils.StringUtils;
+import io.onedev.server.OneDev;
+import io.onedev.server.model.Build;
+import io.onedev.server.security.SecurityUtils;
+import io.onedev.server.service.BuildService;
+import io.onedev.server.service.ProjectService;
+import io.onedev.server.web.util.MimeUtils;
+
+public class PlaywrightReportDownloadResource extends AbstractResource {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String PARAM_PROJECT = "project";
+
+ private static final String PARAM_BUILD = "build";
+
+ private static final String PARAM_REPORT = "report";
+
+ @Override
+ protected ResourceResponse newResourceResponse(Attributes attributes) {
+ var params = attributes.getParameters();
+ var projectId = params.get(PARAM_PROJECT).toLong();
+ var project = OneDev.getInstance(ProjectService.class).load(projectId);
+ var buildNumber = params.get(PARAM_BUILD).toLong();
+ var build = OneDev.getInstance(BuildService.class).find(project, buildNumber);
+ if (build == null) {
+ throw new EntityNotFoundException(String.format(
+ "Unable to find build (project: %s, build number: %d)",
+ project.getPath(), buildNumber));
+ }
+
+ String reportName = params.get(PARAM_REPORT).toString();
+ if (reportName.contains(".."))
+ throw new ExplicitException("Invalid request path");
+ if (!SecurityUtils.canAccessReport(build, reportName))
+ throw new UnauthorizedException();
+
+ List<String> pathSegments = new ArrayList<>();
+ for (int i = 0; i < params.getIndexedCount(); i++) {
+ String pathSegment = params.get(i).toString();
+ if (pathSegment.contains(".."))
+ throw new ExplicitException("Invalid request path");
+ if (pathSegment.length() != 0)
+ pathSegments.add(pathSegment);
+ }
+ String filePath = Joiner.on("/").join(pathSegments);
+ if (!filePath.startsWith(PlaywrightReportParser.FILES + "/"))
+ throw new ExplicitException("Invalid request path");
+
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
+ ResourceResponse response = new ResourceResponse();
+ response.getHeaders().addHeader("X-Content-Type-Options", "nosniff");
+ response.setContentDisposition(ContentDisposition.ATTACHMENT);
+ try {
+ response.setContentType(MimeUtils.sanitize(Files.probeContentType(Paths.get(filePath))));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ response.disableCaching();
+ response.setFileName(URLEncoder.encode(fileName, UTF_8));
+ response.setWriteCallback(new WriteCallback() {
+
+ @Override
+ public void writeData(Attributes attributes) throws IOException {
+ byte[] content = OneDev.getInstance(ProjectService.class).runOnActiveServer(
+ projectId,
+ new ReadPublishedFile(projectId, buildNumber, reportName, filePath));
+ attributes.getResponse().write(content);
+ }
+
+ });
+ return response;
+ }
+
+ public static PageParameters paramsOf(Build build, String reportName, String path) {
+ PageParameters params = new PageParameters();
+ params.add(PARAM_PROJECT, build.getProject().getId());
+ params.add(PARAM_BUILD, build.getNumber());
+ params.add(PARAM_REPORT, reportName);
+ int index = 0;
+ for (String segment: Splitter.on("/").split(path))
+ params.set(index++, segment);
+ return params;
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportDownloadResourceReference.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportDownloadResourceReference.java
new file mode 100644
index 0000000000..b5b954d968
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportDownloadResourceReference.java
@@ -0,0 +1,19 @@
+package io.onedev.server.plugin.report.playwright;
+
+import org.apache.wicket.request.resource.IResource;
+import org.apache.wicket.request.resource.ResourceReference;
+
+public class PlaywrightReportDownloadResourceReference extends ResourceReference {
+
+ private static final long serialVersionUID = 1L;
+
+ public PlaywrightReportDownloadResourceReference() {
+ super("playwright-report");
+ }
+
+ @Override
+ public IResource getResource() {
+ return new PlaywrightReportDownloadResource();
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportParser.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportParser.java
new file mode 100644
index 0000000000..65066d508f
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightReportParser.java
@@ -0,0 +1,499 @@
+package io.onedev.server.plugin.report.playwright;
+
+import static io.onedev.server.plugin.report.unittest.UnitTestReport.Status.getOverallStatus;
+import static org.unbescape.html.HtmlEscape.escapeHtml5;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.jspecify.annotations.Nullable;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import io.onedev.commons.utils.FileUtils;
+import io.onedev.commons.utils.PlanarRange;
+import io.onedev.commons.utils.TaskLogger;
+import io.onedev.server.git.BlobIdent;
+import io.onedev.server.model.Build;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.Status;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.TestCase;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.TestSuite;
+import io.onedev.server.security.SecurityUtils;
+import io.onedev.server.util.StringTransformer;
+import io.onedev.server.web.page.project.blob.ProjectBlobPage;
+import io.onedev.server.web.page.project.blob.render.BlobRenderer;
+
+public class PlaywrightReportParser {
+
+ static final String FILES = "files";
+
+ private static final Pattern PATTERN_LOCATION = Pattern.compile("([^\\s()]+):(\\d+):(\\d+)");
+
+ private static final Pattern PATTERN_ANSI_ESCAPE = Pattern.compile(
+ "\u001B(?:\\[[0-?]*[ -/]*[@-~]|\\][^\u0007]*(?:\u0007|\u001B\\\\)|[@-_])");
+
+ public static List<TestCase> parse(Build build, JsonNode rootNode) {
+ return parse(build, rootNode, null, null, null);
+ }
+
+ public static List<TestCase> parse(Build build, JsonNode rootNode, @Nullable File inputDir,
+ @Nullable File reportDir, @Nullable TaskLogger logger) {
+ Map<String, TestSuiteData> testSuiteDatum = new LinkedHashMap<>();
+ for (JsonNode testSuiteNode: rootNode.path("suites"))
+ parseTestSuite(build, testSuiteNode, new ArrayList<>(), true, testSuiteDatum,
+ inputDir, reportDir, logger);
+
+ List<TestCase> testCases = new ArrayList<>();
+ for (TestSuiteData testSuiteData: testSuiteDatum.values()) {
+ Status status = getOverallStatus(testSuiteData.testCaseDatum.stream()
+ .map(it -> it.status).collect(Collectors.toSet()));
+ long duration = testSuiteData.testCaseDatum.stream().mapToLong(it -> it.duration).sum();
+ TestSuite testSuite = new TestSuite(testSuiteData.name, status, duration,
+ testSuiteData.blobPath, testSuiteData.position) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Nullable
+ @Override
+ protected Component renderDetail(String componentId, Build build) {
+ return null;
+ }
+
+ };
+
+ for (TestCaseData testCaseData: testSuiteData.testCaseDatum) {
+ var detail = testCaseData.detail;
+ var results = testCaseData.results;
+ testCases.add(new TestCase(testSuite, testCaseData.name, testCaseData.status,
+ testCaseData.statusText, testCaseData.duration) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Nullable
+ @Override
+ protected Component renderDetail(String componentId, Build build, String reportName) {
+ if (shouldRenderResults(results)) {
+ return new PlaywrightTestCaseDetailPanel(
+ componentId, build, reportName, results);
+ } else {
+ return PlaywrightReportParser.renderDetail(componentId, build, detail);
+ }
+ }
+
+ });
+ }
+ }
+ return testCases;
+ }
+
+ private static void parseTestSuite(Build build, JsonNode testSuiteNode, List<String> ancestorTitles,
+ boolean rootSuite, Map<String, TestSuiteData> testSuiteDatum, @Nullable File inputDir,
+ @Nullable File reportDir, @Nullable TaskLogger logger) {
+ List<String> titles = new ArrayList<>(ancestorTitles);
+ String title = testSuiteNode.path("title").asText();
+ String file = testSuiteNode.path("file").asText();
+ if (StringUtils.isNotBlank(title) && (!rootSuite || StringUtils.isBlank(file)))
+ titles.add(title);
+
+ for (JsonNode specNode: testSuiteNode.path("specs"))
+ parseSpec(build, specNode, file, titles, testSuiteDatum, inputDir, reportDir, logger);
+ for (JsonNode childSuiteNode: testSuiteNode.path("suites"))
+ parseTestSuite(build, childSuiteNode, titles, false, testSuiteDatum,
+ inputDir, reportDir, logger);
+ }
+
+ private static void parseSpec(Build build, JsonNode specNode, String suiteFile, List<String> titles,
+ Map<String, TestSuiteData> testSuiteDatum, @Nullable File inputDir,
+ @Nullable File reportDir, @Nullable TaskLogger logger) {
+ String file = specNode.path("file").asText(suiteFile);
+ String blobPath = StringUtils.isNotBlank(file)? build.getBlobPath(file): null;
+ String suiteName;
+ if (blobPath != null) {
+ suiteName = blobPath;
+ } else if (StringUtils.isNotBlank(file)) {
+ suiteName = file;
+ } else if (!titles.isEmpty()) {
+ suiteName = StringUtils.join(titles, "/");
+ } else {
+ suiteName = "Playwright";
+ }
+
+ TestSuiteData testSuiteData = testSuiteDatum.computeIfAbsent(suiteName, it -> {
+ var data = new TestSuiteData();
+ data.name = suiteName;
+ data.blobPath = blobPath;
+ int line = specNode.path("line").asInt();
+ int column = specNode.path("column").asInt();
+ if (line > 0)
+ data.position = new PlanarRange(line - 1, Math.max(column - 1, -1), line - 1,
+ Math.max(column - 1, -1));
+ return data;
+ });
+
+ List<String> nameParts = new ArrayList<>(titles);
+ nameParts.add(specNode.path("title").asText());
+ String baseName = StringUtils.join(nameParts, "/");
+ JsonNode testsNode = specNode.path("tests");
+ boolean includeProject = testsNode.size() > 1;
+ for (JsonNode testNode: testsNode) {
+ TestCaseData testCaseData = new TestCaseData();
+ String projectName = testNode.path("projectName").asText();
+ if (includeProject && StringUtils.isNotBlank(projectName))
+ testCaseData.name = baseName + " [" + projectName + "]";
+ else
+ testCaseData.name = baseName;
+ testCaseData.duration = getDuration(testNode);
+ testCaseData.detail = getDetail(testNode);
+ testCaseData.results = getResults(build, testNode, inputDir, reportDir, logger);
+ setStatus(testCaseData, testNode);
+ testSuiteData.testCaseDatum.add(testCaseData);
+ }
+ }
+
+ private static long getDuration(JsonNode testNode) {
+ long duration = 0;
+ for (JsonNode resultNode: testNode.path("results"))
+ duration += resultNode.path("duration").asLong();
+ return duration;
+ }
+
+ private static List<ResultData> getResults(Build build, JsonNode testNode,
+ @Nullable File inputDir, @Nullable File reportDir, @Nullable TaskLogger logger) {
+ List<ResultData> results = new ArrayList<>();
+ for (JsonNode resultNode: testNode.path("results")) {
+ ResultData result = new ResultData();
+ result.retry = resultNode.path("retry").asInt();
+ result.status = resultNode.path("status").asText();
+ result.duration = resultNode.path("duration").asLong();
+ result.errors = getErrors(resultNode);
+ result.stdout = getOutput(resultNode.path("stdout"));
+ result.stderr = getOutput(resultNode.path("stderr"));
+ for (JsonNode attachmentNode: resultNode.path("attachments")) {
+ String path = attachmentNode.path("path").asText();
+ if (StringUtils.isNotBlank(path)) {
+ String artifactPath = getArtifactPath(build, path, logger);
+ if (artifactPath != null
+ && copyArtifact(inputDir, reportDir, artifactPath, logger)) {
+ AttachmentData attachment = new AttachmentData();
+ attachment.name = attachmentNode.path("name").asText();
+ attachment.contentType = attachmentNode.path("contentType").asText();
+ attachment.path = FILES + "/" + artifactPath;
+ result.attachments.add(attachment);
+ }
+ }
+ }
+ results.add(result);
+ }
+ return results;
+ }
+
+ private static List<String> getErrors(JsonNode resultNode) {
+ List<String> errors = new ArrayList<>();
+ for (JsonNode errorNode: resultNode.path("errors")) {
+ String error = getErrorText(errorNode);
+ if (error != null)
+ errors.add(error);
+ }
+ if (errors.isEmpty()) {
+ String error = getErrorText(resultNode.path("error"));
+ if (error != null)
+ errors.add(error);
+ }
+ return errors;
+ }
+
+ private static String getOutput(JsonNode outputNode) {
+ List<String> output = new ArrayList<>();
+ for (JsonNode entryNode: outputNode) {
+ String text;
+ if (entryNode.isTextual())
+ text = entryNode.asText();
+ else
+ text = entryNode.path("text").asText();
+ if (StringUtils.isNotEmpty(text))
+ output.add(text);
+ }
+ return StringUtils.join(output, "");
+ }
+
+ @Nullable
+ private static String getArtifactPath(Build build, String path, @Nullable TaskLogger logger) {
+ String normalizedPath = normalizePath(path);
+ if (normalizedPath == null) {
+ warn(logger, "Ignoring Playwright artifact with invalid path: " + path);
+ return null;
+ }
+
+ if (FilenameUtils.getPrefixLength(normalizedPath) != 0) {
+ String workDirPath = normalizePath(build.getWorkDirPath());
+ String workDirPrefix = workDirPath != null? StringUtils.stripEnd(workDirPath, "/") + "/": null;
+ if (workDirPrefix != null && normalizedPath.startsWith(workDirPrefix)) {
+ normalizedPath = normalizedPath.substring(workDirPrefix.length());
+ } else {
+ warn(logger, "Ignoring Playwright artifact outside build work directory: " + path);
+ return null;
+ }
+ }
+
+ normalizedPath = normalizePath(normalizedPath);
+ if (normalizedPath == null || FilenameUtils.getPrefixLength(normalizedPath) != 0) {
+ warn(logger, "Ignoring Playwright artifact with unsafe path: " + path);
+ return null;
+ }
+ return normalizedPath;
+ }
+
+ @Nullable
+ private static String normalizePath(@Nullable String path) {
+ if (StringUtils.isBlank(path))
+ return null;
+ return FilenameUtils.normalize(path.replace('\\', '/'), true);
+ }
+
+ private static boolean copyArtifact(@Nullable File inputDir, @Nullable File reportDir,
+ String artifactPath, @Nullable TaskLogger logger) {
+ if (inputDir == null || reportDir == null)
+ return true;
+ File artifactFile = new File(inputDir, artifactPath);
+ if (!artifactFile.isFile()) {
+ warn(logger, "Playwright artifact not found: " + artifactPath);
+ return false;
+ }
+ File targetFile = new File(reportDir, FILES + "/" + artifactPath);
+ FileUtils.createDir(targetFile.getParentFile());
+ try {
+ FileUtils.copyFile(artifactFile, targetFile);
+ return true;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static void warn(@Nullable TaskLogger logger, String message) {
+ if (logger != null)
+ logger.warning(message);
+ }
+
+ @Nullable
+ private static String getDetail(JsonNode testNode) {
+ StringBuilder builder = new StringBuilder();
+ for (JsonNode resultNode: testNode.path("results")) {
+ List<String> errors = getErrors(resultNode);
+ if (!errors.isEmpty()) {
+ if (builder.length() != 0)
+ builder.append("\n\n");
+ int retry = resultNode.path("retry").asInt();
+ builder.append(retry != 0? "Retry " + retry: "Initial attempt");
+ String resultStatus = resultNode.path("status").asText();
+ if (StringUtils.isNotBlank(resultStatus))
+ builder.append(" (").append(resultStatus).append(")");
+ builder.append(":\n").append(StringUtils.join(errors, "\n\n"));
+ }
+ }
+ return StringUtils.trimToNull(builder.toString());
+ }
+
+ @Nullable
+ private static String getErrorText(JsonNode errorNode) {
+ if (errorNode.isMissingNode() || errorNode.isNull())
+ return null;
+ String text = errorNode.path("stack").asText();
+ if (StringUtils.isBlank(text))
+ text = errorNode.path("message").asText();
+ if (StringUtils.isBlank(text))
+ return null;
+
+ JsonNode locationNode = errorNode.path("location");
+ String file = locationNode.path("file").asText();
+ int line = locationNode.path("line").asInt();
+ int column = locationNode.path("column").asInt();
+ if (StringUtils.isNotBlank(file) && line > 0 && !text.contains(file + ":" + line)) {
+ StringBuilder builder = new StringBuilder(file).append(":").append(line);
+ if (column > 0)
+ builder.append(":").append(column);
+ return builder.append("\n").append(text).toString();
+ }
+ return text;
+ }
+
+ private static void setStatus(TestCaseData testCaseData, JsonNode testNode) {
+ switch (testNode.path("status").asText()) {
+ case "expected":
+ testCaseData.status = Status.PASSED;
+ if (!"passed".equals(testNode.path("expectedStatus").asText()))
+ testCaseData.statusText = "expected";
+ break;
+ case "unexpected":
+ testCaseData.status = Status.NOT_PASSED;
+ testCaseData.statusText = getLastResultStatus(testNode, "unexpected");
+ break;
+ case "skipped":
+ testCaseData.status = Status.NOT_RUN;
+ testCaseData.statusText = "skipped";
+ break;
+ case "flaky":
+ testCaseData.status = Status.OTHER;
+ testCaseData.statusText = "flaky";
+ break;
+ default:
+ testCaseData.status = Status.OTHER;
+ testCaseData.statusText = testNode.path("status").asText("unknown");
+ }
+ }
+
+ private static String getLastResultStatus(JsonNode testNode, String defaultStatus) {
+ JsonNode resultsNode = testNode.path("results");
+ if (!resultsNode.isEmpty()) {
+ String status = resultsNode.get(resultsNode.size() - 1).path("status").asText();
+ if (StringUtils.isNotBlank(status))
+ return status;
+ }
+ return defaultStatus;
+ }
+
+ static boolean shouldRenderResults(List<ResultData> results) {
+ return results.size() > 1 || results.stream().anyMatch(ResultData::hasContent);
+ }
+
+ @Nullable
+ private static Component renderDetail(String componentId, Build build, @Nullable String detail) {
+ if (detail == null)
+ return null;
+ return new Label(componentId, formatDetail(build, detail)).setEscapeModelStrings(false);
+ }
+
+ static String formatDetail(Build build, String detail) {
+ detail = sanitizeText(detail);
+ if (SecurityUtils.canReadCode(build.getProject())) {
+ return new StringTransformer(PATTERN_LOCATION) {
+
+ @Override
+ protected String transformUnmatched(String string) {
+ return escapeHtml5(string);
+ }
+
+ @Override
+ protected String transformMatched(Matcher matcher) {
+ String file = matcher.group(1);
+ int line = Integer.parseInt(matcher.group(2));
+ int column = Integer.parseInt(matcher.group(3));
+ String blobPath = build.getBlobPath(file);
+ if (blobPath != null) {
+ ProjectBlobPage.State state = new ProjectBlobPage.State();
+ state.blobIdent = new BlobIdent(build.getCommitHash(), blobPath);
+ PlanarRange range = new PlanarRange(line - 1, column - 1, line - 1, column);
+ state.position = BlobRenderer.getSourcePosition(range);
+ PageParameters params = ProjectBlobPage.paramsOf(build.getProject(), state);
+ String url = RequestCycle.get().urlFor(ProjectBlobPage.class, params).toString();
+ return String.format("<a href='%s'>%s:%d:%d</a>", escapeHtml5(url),
+ escapeHtml5(blobPath), line, column);
+ } else {
+ return escapeHtml5(matcher.group());
+ }
+ }
+ }.transform(detail);
+ } else {
+ return escapeHtml5(detail);
+ }
+ }
+
+ static String sanitizeText(String text) {
+ if (text == null)
+ return "";
+ text = PATTERN_ANSI_ESCAPE.matcher(text).replaceAll("");
+ StringBuilder builder = new StringBuilder(text.length());
+ for (int index = 0; index < text.length();) {
+ int codePoint = text.codePointAt(index);
+ if (codePoint == 0x9 || codePoint == 0xA || codePoint == 0xD
+ || codePoint >= 0x20 && codePoint <= 0xD7FF
+ || codePoint >= 0xE000 && codePoint <= 0xFFFD
+ || codePoint >= 0x10000 && codePoint <= 0x10FFFF) {
+ builder.appendCodePoint(codePoint);
+ }
+ index += Character.charCount(codePoint);
+ }
+ return builder.toString();
+ }
+
+ private static class TestSuiteData {
+
+ String name;
+
+ String blobPath;
+
+ PlanarRange position;
+
+ List<TestCaseData> testCaseDatum = new ArrayList<>();
+
+ }
+
+ private static class TestCaseData {
+
+ String name;
+
+ Status status;
+
+ String statusText;
+
+ long duration;
+
+ String detail;
+
+ List<ResultData> results = new ArrayList<>();
+
+ }
+
+ static class ResultData implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ int retry;
+
+ String status;
+
+ long duration;
+
+ List<String> errors = new ArrayList<>();
+
+ String stdout;
+
+ String stderr;
+
+ List<AttachmentData> attachments = new ArrayList<>();
+
+ boolean hasContent() {
+ return !errors.isEmpty()
+ || StringUtils.isNotEmpty(stdout)
+ || StringUtils.isNotEmpty(stderr)
+ || !attachments.isEmpty();
+ }
+
+ }
+
+ static class AttachmentData implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ String name;
+
+ String contentType;
+
+ String path;
+
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightTestCaseDetailPanel.html b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightTestCaseDetailPanel.html
new file mode 100644
index 0000000000..6751e1130e
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightTestCaseDetailPanel.html
@@ -0,0 +1,35 @@
+<wicket:panel>
+ <div class="playwright-test-detail">
+ <div wicket:id="results" class="playwright-attempt">
+ <div wicket:id="header" class="d-flex align-items-center mb-2">
+ <span wicket:id="attempt" class="font-weight-bold"></span>
+ <span wicket:id="status" class="badge badge-light ml-2"></span>
+ <span wicket:id="duration" class="text-muted ml-auto"></span>
+ </div>
+ <div wicket:id="errorsSection" class="playwright-section">
+ <div class="playwright-section-title">Errors</div>
+ <div wicket:id="errors">
+ <div wicket:id="error" class="playwright-output text-danger"></div>
+ </div>
+ </div>
+ <div wicket:id="stdoutSection" class="playwright-section">
+ <div class="playwright-section-title">Standard output</div>
+ <div wicket:id="stdout" class="playwright-output"></div>
+ </div>
+ <div wicket:id="stderrSection" class="playwright-section">
+ <div class="playwright-section-title">Standard error</div>
+ <div wicket:id="stderr" class="playwright-output"></div>
+ </div>
+ <div wicket:id="attachmentsSection" class="playwright-section">
+ <div class="playwright-section-title">Attachments</div>
+ <div wicket:id="attachments" class="playwright-attachment">
+ <a wicket:id="link" target="_blank" rel="noopener">
+ <img wicket:id="image" class="playwright-image" alt="Playwright attachment">
+ <span wicket:id="name" class="font-weight-bold"></span>
+ </a>
+ <span wicket:id="contentType" class="text-muted ml-2"></span>
+ </div>
+ </div>
+ </div>
+ </div>
+</wicket:panel>
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightTestCaseDetailPanel.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightTestCaseDetailPanel.java
new file mode 100644
index 0000000000..b9460d3330
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PlaywrightTestCaseDetailPanel.java
@@ -0,0 +1,115 @@
+package io.onedev.server.plugin.report.playwright;
+
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DurationFormatUtils;
+import org.apache.wicket.markup.head.CssHeaderItem;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.image.ExternalImage;
+import org.apache.wicket.markup.html.link.ExternalLink;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.request.cycle.RequestCycle;
+
+import io.onedev.server.model.Build;
+import io.onedev.server.plugin.report.playwright.PlaywrightReportParser.AttachmentData;
+import io.onedev.server.plugin.report.playwright.PlaywrightReportParser.ResultData;
+
+public class PlaywrightTestCaseDetailPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public PlaywrightTestCaseDetailPanel(String id, Build build, String reportName,
+ List<ResultData> results) {
+ super(id);
+ add(new ListView<ResultData>("results", results) {
+
+ @Override
+ protected void populateItem(ListItem<ResultData> item) {
+ ResultData result = item.getModelObject();
+ WebMarkupContainer header = new WebMarkupContainer("header");
+ header.setVisible(getList().size() > 1);
+ header.add(new Label("attempt",
+ result.retry != 0? "Retry " + result.retry: "Initial attempt"));
+ header.add(new Label("status", result.status));
+ header.add(new Label("duration",
+ DurationFormatUtils.formatDuration(result.duration, "s.SSS 's'")));
+ item.add(header);
+
+ WebMarkupContainer errorsSection = new WebMarkupContainer("errorsSection");
+ errorsSection.setVisible(!result.errors.isEmpty());
+ errorsSection.add(new ListView<String>("errors", result.errors) {
+
+ @Override
+ protected void populateItem(ListItem<String> item) {
+ item.add(new Label("error",
+ PlaywrightReportParser.formatDetail(build, item.getModelObject()))
+ .setEscapeModelStrings(false));
+ }
+
+ });
+ item.add(errorsSection);
+
+ WebMarkupContainer stdoutSection = new WebMarkupContainer("stdoutSection");
+ stdoutSection.setVisible(StringUtils.isNotEmpty(result.stdout));
+ stdoutSection.add(new Label("stdout", PlaywrightReportParser.sanitizeText(
+ StringUtils.defaultString(result.stdout))));
+ item.add(stdoutSection);
+
+ WebMarkupContainer stderrSection = new WebMarkupContainer("stderrSection");
+ stderrSection.setVisible(StringUtils.isNotEmpty(result.stderr));
+ stderrSection.add(new Label("stderr", PlaywrightReportParser.sanitizeText(
+ StringUtils.defaultString(result.stderr))));
+ item.add(stderrSection);
+
+ WebMarkupContainer attachmentsSection = new WebMarkupContainer("attachmentsSection");
+ attachmentsSection.setVisible(!result.attachments.isEmpty());
+ attachmentsSection.add(new ListView<AttachmentData>("attachments", result.attachments) {
+
+ @Override
+ protected void populateItem(ListItem<AttachmentData> item) {
+ AttachmentData attachment = item.getModelObject();
+ String url = RequestCycle.get().urlFor(
+ new PlaywrightReportDownloadResourceReference(),
+ PlaywrightReportDownloadResource.paramsOf(
+ build, reportName, attachment.path)).toString();
+ ExternalLink link = new ExternalLink("link", url);
+ link.add(new ExternalImage("image", url).setVisible(
+ isSafeInlineImage(attachment.contentType)));
+ String name = StringUtils.defaultIfBlank(attachment.name, attachment.path);
+ link.add(new Label("name", name));
+ item.add(link);
+ item.add(new Label("contentType",
+ StringUtils.defaultString(attachment.contentType)));
+ }
+
+ });
+ item.add(attachmentsSection);
+ }
+
+ });
+ }
+
+ private static boolean isSafeInlineImage(String contentType) {
+ if (contentType == null)
+ return false;
+ String mediaType = StringUtils.substringBefore(contentType, ";").trim().toLowerCase();
+ return mediaType.equals("image/png")
+ || mediaType.equals("image/jpeg")
+ || mediaType.equals("image/jpg")
+ || mediaType.equals("image/gif")
+ || mediaType.equals("image/webp")
+ || mediaType.equals("image/bmp");
+ }
+
+ @Override
+ public void renderHead(IHeaderResponse response) {
+ super.renderHead(response);
+ response.render(CssHeaderItem.forReference(new PlaywrightReportCssResourceReference()));
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PublishPlaywrightReportStep.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PublishPlaywrightReportStep.java
new file mode 100644
index 0000000000..2e7687da2c
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/PublishPlaywrightReportStep.java
@@ -0,0 +1,83 @@
+package io.onedev.server.plugin.report.playwright;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.validation.constraints.NotEmpty;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+
+import io.onedev.commons.codeassist.InputSuggestion;
+import io.onedev.commons.utils.ExceptionUtils;
+import io.onedev.commons.utils.FileUtils;
+import io.onedev.commons.utils.TaskLogger;
+import io.onedev.server.OneDev;
+import io.onedev.server.annotation.Editable;
+import io.onedev.server.annotation.Interpolative;
+import io.onedev.server.annotation.Patterns;
+import io.onedev.server.buildspec.BuildSpec;
+import io.onedev.server.buildspec.step.StepGroup;
+import io.onedev.server.model.Build;
+import io.onedev.server.plugin.report.unittest.PublishUnitTestReportStep;
+import io.onedev.server.plugin.report.unittest.UnitTestReport;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.TestCase;
+
+@Editable(order=10000, group=StepGroup.PUBLISH, name="Playwright Test Report")
+public class PublishPlaywrightReportStep extends PublishUnitTestReportStep {
+
+ private static final long serialVersionUID = 1L;
+
+ @Editable(order=100, description="Specify Playwright test result files in JSON format relative to "
+ + "<a href='https://docs.onedev.io/concepts#job-workdir'>job working directory</a>. "
+ + "Configure Playwright reporter as <tt>[['json', { outputFile: 'results.json' }]]</tt>. "
+ + "Make sure referenced artifacts such as screenshots and traces are also included. "
+ + "Use * or ? for pattern match")
+ @Interpolative(variableSuggester="suggestVariables")
+ @Patterns(path=true)
+ @NotEmpty
+ @Override
+ public String getFilePatterns() {
+ return super.getFilePatterns();
+ }
+
+ @Override
+ public void setFilePatterns(String filePatterns) {
+ super.setFilePatterns(filePatterns);
+ }
+
+ @SuppressWarnings("unused")
+ private static List<InputSuggestion> suggestVariables(String matchWith) {
+ return BuildSpec.suggestVariables(matchWith, true, true, false);
+ }
+
+ @Override
+ protected UnitTestReport process(Build build, File inputDir, TaskLogger logger) {
+ ObjectMapper mapper = OneDev.getInstance(ObjectMapper.class);
+ File reportDir = new File(build.getDir(), UnitTestReport.CATEGORY + "/" + getReportName());
+ FileUtils.deleteDir(reportDir);
+ FileUtils.createDir(reportDir);
+ try {
+ List<TestCase> testCases = new ArrayList<>();
+ int baseLen = inputDir.getAbsolutePath().length() + 1;
+ for (File file: FileUtils.listFiles(inputDir,
+ Lists.newArrayList("*.json", "**/*.json"), Lists.newArrayList())) {
+ logger.log("Processing Playwright test report: "
+ + file.getAbsolutePath().substring(baseLen));
+ testCases.addAll(PlaywrightReportParser.parse(
+ build, mapper.readTree(file), inputDir, reportDir, logger));
+ }
+ if (!testCases.isEmpty())
+ return new UnitTestReport(testCases, true);
+ else {
+ FileUtils.deleteDir(reportDir);
+ return null;
+ }
+ } catch (Exception e) {
+ FileUtils.deleteDir(reportDir);
+ throw ExceptionUtils.unchecked(e);
+ }
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/ReadPublishedFile.java b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/ReadPublishedFile.java
new file mode 100644
index 0000000000..7acfebd655
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/ReadPublishedFile.java
@@ -0,0 +1,52 @@
+package io.onedev.server.plugin.report.playwright;
+
+import static io.onedev.commons.utils.LockUtils.read;
+import static io.onedev.server.plugin.report.unittest.UnitTestReport.CATEGORY;
+import static io.onedev.server.plugin.report.unittest.UnitTestReport.getReportLockName;
+import static org.apache.commons.io.FileUtils.readFileToByteArray;
+
+import java.io.File;
+import java.io.IOException;
+
+import io.onedev.commons.utils.ExplicitException;
+import io.onedev.server.OneDev;
+import io.onedev.server.cluster.ClusterTask;
+import io.onedev.server.service.BuildService;
+
+class ReadPublishedFile implements ClusterTask<byte[]> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Long projectId;
+
+ private final Long buildNumber;
+
+ private final String reportName;
+
+ private final String filePath;
+
+ ReadPublishedFile(Long projectId, Long buildNumber, String reportName, String filePath) {
+ this.projectId = projectId;
+ this.buildNumber = buildNumber;
+ this.reportName = reportName;
+ this.filePath = filePath;
+ }
+
+ @Override
+ public byte[] call() {
+ return read(getReportLockName(projectId, buildNumber), () -> {
+ File reportDir = new File(
+ OneDev.getInstance(BuildService.class).getBuildDir(projectId, buildNumber),
+ CATEGORY + "/" + reportName);
+ try {
+ File file = new File(reportDir, filePath).getCanonicalFile();
+ if (!file.toPath().startsWith(reportDir.getCanonicalFile().toPath()) || !file.isFile())
+ throw new ExplicitException("Invalid request path");
+ return readFileToByteArray(file);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/playwright-report.css b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/playwright-report.css
new file mode 100644
index 0000000000..20fda438f3
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/main/java/io/onedev/server/plugin/report/playwright/playwright-report.css
@@ -0,0 +1,65 @@
+.unit-test-case-detail:has(.playwright-test-detail) {
+ margin-top: 0.5rem !important;
+ white-space: normal;
+}
+
+.playwright-test-detail {
+ white-space: normal;
+}
+
+.playwright-attempt {
+ border-left: 3px solid var(--secondary);
+ margin-top: 1rem;
+ padding-left: 1rem;
+}
+
+.playwright-attempt:first-child {
+ margin-top: 0;
+}
+
+.playwright-attempt > .playwright-section:first-child {
+ margin-top: 0;
+}
+
+.playwright-section {
+ margin-top: 1rem;
+}
+
+.playwright-section-title {
+ font-weight: 600;
+ margin-bottom: 0.5rem;
+}
+
+.playwright-output {
+ background: var(--light);
+ border-radius: 0.25rem;
+ box-sizing: border-box;
+ display: block;
+ margin: 0 0 0.5rem;
+ max-height: 30rem;
+ max-width: 100%;
+ min-width: 0;
+ overflow: auto;
+ overflow-wrap: anywhere;
+ padding: 0.75rem;
+ white-space: pre-wrap;
+ word-break: break-all;
+}
+
+.playwright-attachment {
+ margin-top: 0.75rem;
+}
+
+.playwright-attachment > a {
+ display: inline-flex;
+ flex-direction: column;
+}
+
+.playwright-image {
+ border: 1px solid var(--light);
+ border-radius: 0.25rem;
+ margin-bottom: 0.5rem;
+ max-height: 24rem;
+ max-width: min(100%, 48rem);
+ object-fit: contain;
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/PlaywrightReportParserTest.java b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/PlaywrightReportParserTest.java
new file mode 100644
index 0000000000..84601b0fe6
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/PlaywrightReportParserTest.java
@@ -0,0 +1,172 @@
+package io.onedev.server.plugin.report.playwright;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Sets;
+import com.google.common.io.Resources;
+
+import io.onedev.server.model.Build;
+import io.onedev.server.plugin.report.unittest.UnitTestReport;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.Status;
+import io.onedev.server.plugin.report.unittest.UnitTestReport.TestCase;
+import io.onedev.server.util.patternset.PatternSet;
+
+public class PlaywrightReportParserTest {
+
+ private static final String ARTIFACT_DIR =
+ "confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium";
+
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
+ @Test
+ public void shouldParseReport() {
+ try (InputStream is = Resources.getResource(
+ PlaywrightReportParserTest.class, "test-results.json").openStream()) {
+ JsonNode rootNode = new ObjectMapper().readTree(is);
+ Build build = new Build() {
+
+ @Override
+ public String getBlobPath(String filePath) {
+ return filePath;
+ }
+
+ @Override
+ public String getWorkDirPath() {
+ return "/onedev-build/work";
+ }
+
+ };
+
+ File inputDir = temp.newFolder("input");
+ File reportDir = temp.newFolder("report");
+ copyResource(ARTIFACT_DIR + "/test-failed-1.png", inputDir);
+ copyResource(ARTIFACT_DIR + "/error-context.md", inputDir);
+ UnitTestReport report = new UnitTestReport(
+ PlaywrightReportParser.parse(build, rootNode, inputDir, reportDir, null), true);
+ assertEquals(1, report.getTestCases(null, null, Sets.newHashSet(Status.PASSED)).size());
+ assertEquals(1, report.getTestCases(null, null, Sets.newHashSet(Status.NOT_PASSED)).size());
+ assertEquals(0, report.getTestCases(null, null, Sets.newHashSet(Status.NOT_RUN)).size());
+ assertEquals(0, report.getTestCases(null, null, Sets.newHashSet(Status.OTHER)).size());
+ assertEquals(2, report.getTestCases().size());
+
+ assertEquals(1, report.getTestSuites(null, Sets.newHashSet(Status.NOT_PASSED)).size());
+ assertEquals(1, report.getTestSuites(null, Sets.newHashSet(Status.PASSED)).size());
+ assertEquals(2, report.getTestSuites().size());
+ assertEquals(120057, report.getTestSuites().stream()
+ .filter(it -> it.getName().equals("confidential-issue.spec.js"))
+ .findFirst().orElseThrow().getDuration());
+
+ TestCase timedOut = report.getTestCases().stream()
+ .filter(it -> it.getName().equals(
+ "Issue Reporter can create and view a confidential issue"))
+ .findFirst().orElseThrow();
+ assertEquals(Status.NOT_PASSED, timedOut.getStatus());
+ assertEquals("timedOut", timedOut.getStatusText());
+ assertEquals(120057, timedOut.getDuration());
+
+ TestCase passed = report.getTestCases().stream()
+ .filter(it -> it.getName().equals("serves the OneDev web interface"))
+ .findFirst().orElseThrow();
+ assertEquals(Status.PASSED, passed.getStatus());
+ assertEquals(153, passed.getDuration());
+
+ assertEquals(1, report.getTestCases(
+ new PatternSet(Sets.newHashSet("confidential-issue.spec.js"), new HashSet<>()),
+ null, null).size());
+ assertEquals(1, report.getTestCases(
+ null,
+ new PatternSet(Sets.newHashSet("Issue Reporter*"), new HashSet<>()),
+ null).size());
+ assertTrue(report.hasTestCaseDuration());
+
+ File copiedScreenshot = new File(reportDir,
+ PlaywrightReportParser.FILES + "/" + ARTIFACT_DIR + "/test-failed-1.png");
+ assertTrue(copiedScreenshot.isFile());
+ assertArrayEquals(
+ Resources.toByteArray(Resources.getResource(
+ PlaywrightReportParserTest.class, ARTIFACT_DIR + "/test-failed-1.png")),
+ Files.readAllBytes(copiedScreenshot.toPath()));
+ report.writeTo(reportDir);
+ assertEquals(2, UnitTestReport.readFrom(reportDir).getTestCases().size());
+
+ JsonNode unsafeRootNode = rootNode.deepCopy();
+ ((com.fasterxml.jackson.databind.node.ObjectNode) unsafeRootNode.path("suites").get(0)
+ .path("specs").get(0).path("tests").get(0).path("results").get(0)
+ .path("attachments").get(0)).put("path", "/outside-workdir/screenshot.png");
+ File unsafeReportDir = temp.newFolder("unsafe-report");
+ PlaywrightReportParser.parse(build, unsafeRootNode, inputDir, unsafeReportDir, null);
+ assertFalse(new File(unsafeReportDir,
+ PlaywrightReportParser.FILES + "/" + ARTIFACT_DIR + "/test-failed-1.png").exists());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Test
+ public void shouldOmitPassedAttemptWithoutDetail() {
+ assertFalse(PlaywrightReportParser.shouldRenderResults(singlePassedResult()));
+ assertTrue(PlaywrightReportParser.shouldRenderResults(failedResultWithErrors()));
+ assertTrue(PlaywrightReportParser.shouldRenderResults(retriedResults()));
+ }
+
+ @Test
+ public void shouldSanitizeOutputForAjaxResponse() {
+ assertEquals("", PlaywrightReportParser.sanitizeText(null));
+ assertEquals("red\n\t😀", PlaywrightReportParser.sanitizeText(
+ "\u001B[31mred\u001B[0m\u0000\n\t😀"));
+ }
+
+ private void copyResource(String resourcePath, File inputDir) throws IOException {
+ File targetFile = new File(inputDir, resourcePath);
+ Files.createDirectories(targetFile.getParentFile().toPath());
+ try (InputStream is = Resources.getResource(
+ PlaywrightReportParserTest.class, resourcePath).openStream()) {
+ Files.copy(is, targetFile.toPath());
+ }
+ }
+
+ private static List<PlaywrightReportParser.ResultData> singlePassedResult() {
+ PlaywrightReportParser.ResultData result = new PlaywrightReportParser.ResultData();
+ result.status = "passed";
+ return List.of(result);
+ }
+
+ private static List<PlaywrightReportParser.ResultData> failedResultWithErrors() {
+ PlaywrightReportParser.ResultData result = new PlaywrightReportParser.ResultData();
+ result.status = "timedOut";
+ result.errors.add("Test timeout of 120000ms exceeded.");
+ return List.of(result);
+ }
+
+ private static List<PlaywrightReportParser.ResultData> retriedResults() {
+ PlaywrightReportParser.ResultData failed = new PlaywrightReportParser.ResultData();
+ failed.status = "failed";
+ failed.errors.add("expected true to be false");
+ PlaywrightReportParser.ResultData passed = new PlaywrightReportParser.ResultData();
+ passed.retry = 1;
+ passed.status = "passed";
+ List<PlaywrightReportParser.ResultData> results = new ArrayList<>();
+ results.add(failed);
+ results.add(passed);
+ return results;
+ }
+
+}
diff --git a/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/error-context.md b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/error-context.md
new file mode 100644
index 0000000000..33bfa00c8b
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/error-context.md
@@ -0,0 +1,111 @@
+# Instructions
+
+- Following Playwright test failed.
+- Explain why, be concise, respect Playwright best practices.
+- Provide a snippet of code with the fix, if possible.
+
+# Test info
+
+- Name: confidential-issue.spec.js >> Issue Reporter can create and view a confidential issue
+- Location: tests/confidential-issue.spec.js:4:1
+
+# Error details
+
+```
+Test timeout of 120000ms exceeded.
+```
+
+```
+Error: locator.fill: Test timeout of 120000ms exceeded.
+Call log:
+ - waiting for getByPlaceholder('Login name or email address')
+
+```
+
+# Page snapshot
+
+```yaml
+- generic [ref=e2]:
+ - generic [ref=e5]:
+ - heading "Page Not Found" [level=3] [ref=e6]
+ - generic [ref=e7]: I didn't eat it. I swear!
+ - link "Back To Home" [ref=e8] [cursor=pointer]:
+ - /url: /
+```
+
+# Test source
+
+```ts
+ 1 | /**
+ 2 | * @param {import('@playwright/test').Page} page
+ 3 | * @param {string} userName
+ 4 | * @param {string} password
+ 5 | */
+ 6 | export async function login(page, userName, password) {
+ 7 | await page.goto('~/login');
+> 8 | await page.getByPlaceholder('Login name or email address').fill(userName);
+ | ^ Error: locator.fill: Test timeout of 120000ms exceeded.
+ 9 | await page.getByPlaceholder('Password').fill(password);
+ 10 | await page.getByRole('button', { name: 'Sign in' }).click();
+ 11 | await page.waitForURL((url) => !url.pathname.includes('~/login'));
+ 12 | }
+ 13 |
+ 14 | /**
+ 15 | * @param {import('@playwright/test').Page} page
+ 16 | */
+ 17 | export async function logout(page) {
+ 18 | await page.goto('~/logout');
+ 19 | await page.waitForURL(/~login/);
+ 20 | }
+ 21 |
+ 22 | /**
+ 23 | * Locate a BeanEditor form-group by its visible label text.
+ 24 | * @param {import('@playwright/test').Page | import('@playwright/test').Locator} root
+ 25 | * @param {string} label
+ 26 | */
+ 27 | export function formGroup(root, label) {
+ 28 | return root.locator('.form-group').filter({
+ 29 | has: root.locator('label.name > span').getByText(label, { exact: true }),
+ 30 | });
+ 31 | }
+ 32 |
+ 33 | /**
+ 34 | * @param {import('@playwright/test').Page | import('@playwright/test').Locator} root
+ 35 | * @param {string} label
+ 36 | * @param {string} value
+ 37 | */
+ 38 | export async function fillLabeledInput(root, label, value) {
+ 39 | await formGroup(root, label).locator('input.form-control, textarea.form-control').first().fill(value);
+ 40 | }
+ 41 |
+ 42 | /**
+ 43 | * Select an option in a Select2 single or multi choice.
+ 44 | * @param {import('@playwright/test').Page} page
+ 45 | * @param {import('@playwright/test').Locator} container
+ 46 | * @param {string} optionText
+ 47 | */
+ 48 | export async function select2Choose(page, container, optionText) {
+ 49 | const select2 = container.locator('.select2-container').first();
+ 50 | const multiInput = select2.locator('input.select2-input');
+ 51 | if (await multiInput.count()) {
+ 52 | await multiInput.click();
+ 53 | await multiInput.fill(optionText);
+ 54 | } else {
+ 55 | await select2.locator('.select2-choice').click();
+ 56 | await page.locator('#select2-drop input.select2-input').fill(optionText);
+ 57 | }
+ 58 | await page
+ 59 | .locator('#select2-drop .select2-result-selectable .select2-result-label')
+ 60 | .filter({ hasText: new RegExp(`^${escapeRegExp(optionText)}$`) })
+ 61 | .click();
+ 62 | await page.locator('#select2-drop').waitFor({ state: 'hidden' }).catch(() => {});
+ 63 | }
+ 64 |
+ 65 | /**
+ 66 | * @param {string} value
+ 67 | */
+ 68 | function escapeRegExp(value) {
+ 69 | return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ 70 | }
+ 71 |
+```
\ No newline at end of file
diff --git a/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/test-failed-1.png b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/test-failed-1.png
new file mode 100644
index 0000000000..d811494771
Binary files /dev/null and b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/test-failed-1.png differ
diff --git a/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/test-results.json b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/test-results.json
new file mode 100644
index 0000000000..939f54fd3a
--- /dev/null
+++ b/server-plugin/server-plugin-report-playwright/src/test/java/io/onedev/server/plugin/report/playwright/test-results.json
@@ -0,0 +1,196 @@
+{
+ "config": {
+ "argv": [
+ "/Users/robin/.nvm/versions/node/v26.1.0/bin/node",
+ "/Users/robin/Projects/onedev/server/e2e-test/node_modules/.bin/playwright",
+ "test",
+ "--reporter=json"
+ ],
+ "configFile": "/Users/robin/Projects/onedev/server/e2e-test/playwright.config.js",
+ "rootDir": "/Users/robin/Projects/onedev/server/e2e-test/tests",
+ "failOnFlakyTests": false,
+ "forbidOnly": false,
+ "fullyParallel": true,
+ "globalSetup": null,
+ "globalTeardown": null,
+ "globalTimeout": 0,
+ "grep": {},
+ "grepInvert": null,
+ "maxFailures": 0,
+ "metadata": {
+ "actualWorkers": 2
+ },
+ "preserveOutput": "always",
+ "projects": [
+ {
+ "outputDir": "/Users/robin/Projects/onedev/server/e2e-test/test-results",
+ "repeatEach": 1,
+ "retries": 0,
+ "metadata": {
+ "actualWorkers": 2
+ },
+ "id": "chromium",
+ "name": "chromium",
+ "testDir": "/Users/robin/Projects/onedev/server/e2e-test/tests",
+ "testIgnore": [],
+ "testMatch": [
+ "**/*.@(spec|test).?(c|m)[jt]s?(x)"
+ ],
+ "timeout": 30000
+ }
+ ],
+ "quiet": false,
+ "reporter": [
+ [
+ "json"
+ ]
+ ],
+ "reportSlowTests": {
+ "max": 5,
+ "threshold": 300000
+ },
+ "shard": null,
+ "tags": [],
+ "updateSnapshots": "missing",
+ "updateSourceMethod": "patch",
+ "version": "1.62.1",
+ "workers": 7,
+ "webServer": {
+ "command": "./dev.sh run",
+ "cwd": "/Users/robin/Projects/onedev/server",
+ "url": "http://127.0.0.1:6610",
+ "reuseExistingServer": true,
+ "timeout": 600000,
+ "stdout": "pipe",
+ "stderr": "pipe",
+ "env": {
+ "initial_user": "admin",
+ "initial_password": "admin",
+ "initial_email": "[email protected]",
+ "initial_server_url": "http://192.168.7.1:6610"
+ }
+ }
+ },
+ "suites": [
+ {
+ "title": "confidential-issue.spec.js",
+ "file": "confidential-issue.spec.js",
+ "column": 0,
+ "line": 0,
+ "specs": [
+ {
+ "title": "Issue Reporter can create and view a confidential issue",
+ "ok": false,
+ "tags": [],
+ "tests": [
+ {
+ "timeout": 120000,
+ "annotations": [],
+ "expectedStatus": "passed",
+ "projectId": "chromium",
+ "projectName": "chromium",
+ "results": [
+ {
+ "workerIndex": 0,
+ "parallelIndex": 0,
+ "status": "timedOut",
+ "duration": 120057,
+ "error": {
+ "message": "\u001b[31mTest timeout of 120000ms exceeded.\u001b[39m",
+ "stack": "\u001b[31mTest timeout of 120000ms exceeded.\u001b[39m"
+ },
+ "errors": [
+ {
+ "message": "\u001b[31mTest timeout of 120000ms exceeded.\u001b[39m"
+ },
+ {
+ "location": {
+ "file": "/Users/robin/Projects/onedev/server/e2e-test/tests/helpers.js",
+ "column": 62,
+ "line": 8
+ },
+ "message": "Error: locator.fill: Test timeout of 120000ms exceeded.\nCall log:\n\u001b[2m - waiting for getByPlaceholder('Login name or email address')\u001b[22m\n\n\n\u001b[90m at \u001b[39mhelpers.js:8\n\n\u001b[0m \u001b[90m 6 |\u001b[39m \u001b[36mexport\u001b[39m \u001b[36masync\u001b[39m \u001b[36mfunction\u001b[39m login(page\u001b[33m,\u001b[39m userName\u001b[33m,\u001b[39m password) {\n \u001b[90m 7 |\u001b[39m \u001b[36mawait\u001b[39m page\u001b[33m.\u001b[39mgoto(\u001b[32m'~/login'\u001b[39m)\u001b[33m;\u001b[39m\n\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 8 |\u001b[39m \u001b[36mawait\u001b[39m page\u001b[33m.\u001b[39mgetByPlaceholder(\u001b[32m'Login name or email address'\u001b[39m)\u001b[33m.\u001b[39mfill(userName)\u001b[33m;\u001b[39m\n \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\n \u001b[90m 9 |\u001b[39m \u001b[36mawait\u001b[39m page\u001b[33m.\u001b[39mgetByPlaceholder(\u001b[32m'Password'\u001b[39m)\u001b[33m.\u001b[39mfill(password)\u001b[33m;\u001b[39m\n \u001b[90m 10 |\u001b[39m \u001b[36mawait\u001b[39m page\u001b[33m.\u001b[39mgetByRole(\u001b[32m'button'\u001b[39m\u001b[33m,\u001b[39m { name\u001b[33m:\u001b[39m \u001b[32m'Sign in'\u001b[39m })\u001b[33m.\u001b[39mclick()\u001b[33m;\u001b[39m\n \u001b[90m 11 |\u001b[39m \u001b[36mawait\u001b[39m page\u001b[33m.\u001b[39mwaitForURL((url) \u001b[33m=>\u001b[39m \u001b[33m!\u001b[39murl\u001b[33m.\u001b[39mpathname\u001b[33m.\u001b[39mincludes(\u001b[32m'~/login'\u001b[39m))\u001b[33m;\u001b[39m\u001b[0m\n\u001b[2m at login (/Users/robin/Projects/onedev/server/e2e-test/tests/helpers.js:8:62)\u001b[22m\n\u001b[2m at /Users/robin/Projects/onedev/server/e2e-test/tests/confidential-issue.spec.js:14:3\u001b[22m"
+ }
+ ],
+ "stdout": [],
+ "stderr": [],
+ "retry": 0,
+ "startTime": "2026-08-21T06:03:22.446Z",
+ "annotations": [],
+ "attachments": [
+ {
+ "name": "screenshot",
+ "contentType": "image/png",
+ "path": "/onedev-build/work/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/test-failed-1.png"
+ },
+ {
+ "name": "error-context",
+ "contentType": "text/markdown",
+ "path": "/onedev-build/work/confidential-issue-Issue-R-14762-d-view-a-confidential-issue-chromium/error-context.md"
+ }
+ ]
+ }
+ ],
+ "status": "unexpected"
+ }
+ ],
+ "id": "dbf125409f7f8c4b5e9c-dffa72cd6a057e70d37c",
+ "file": "confidential-issue.spec.js",
+ "line": 4,
+ "column": 1
+ }
+ ]
+ },
+ {
+ "title": "server.spec.js",
+ "file": "server.spec.js",
+ "column": 0,
+ "line": 0,
+ "specs": [
+ {
+ "title": "serves the OneDev web interface",
+ "ok": true,
+ "tags": [],
+ "tests": [
+ {
+ "timeout": 30000,
+ "annotations": [],
+ "expectedStatus": "passed",
+ "projectId": "chromium",
+ "projectName": "chromium",
+ "results": [
+ {
+ "workerIndex": 1,
+ "parallelIndex": 1,
+ "status": "passed",
+ "duration": 153,
+ "errors": [],
+ "stdout": [],
+ "stderr": [],
+ "retry": 0,
+ "startTime": "2026-08-21T06:03:22.447Z",
+ "annotations": [],
+ "attachments": []
+ }
+ ],
+ "status": "expected"
+ }
+ ],
+ "id": "7cfb09b9a132f1542744-e4b6ee58d336fd8035a4",
+ "file": "server.spec.js",
+ "line": 3,
+ "column": 1
+ }
+ ]
+ }
+ ],
+ "errors": [],
+ "stats": {
+ "startTime": "2026-08-21T06:03:22.285Z",
+ "duration": 120314.833,
+ "expected": 1,
+ "skipped": 0,
+ "unexpected": 1,
+ "flaky": 0
+ }
+}
diff --git a/server-plugin/server-plugin-report-trx/src/main/java/io/onedev/server/plugin/report/trx/TRXReportParser.java b/server-plugin/server-plugin-report-trx/src/main/java/io/onedev/server/plugin/report/trx/TRXReportParser.java
index 45a1fc6c68..04b78f94cd 100644
--- a/server-plugin/server-plugin-report-trx/src/main/java/io/onedev/server/plugin/report/trx/TRXReportParser.java
+++ b/server-plugin/server-plugin-report-trx/src/main/java/io/onedev/server/plugin/report/trx/TRXReportParser.java
@@ -115,7 +115,7 @@ public class TRXReportParser {
testCaseData.duration) {
@Override
- protected Component renderDetail(String componentId, Build build) {
+ protected Component renderDetail(String componentId, Build build, String reportName) {
if (detailInfo != null) {
if (SecurityUtils.canReadCode(build.getProject())) {
String transformed = new StringTransformer(PATTERN_LOCATION) {
diff --git a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.html b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.html
index e26165e905..847174158a 100644
--- a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.html
+++ b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.html
@@ -43,9 +43,9 @@
<div class="d-flex align-items-start">
<span wicket:id="status" class="mr-3"></span>
<span wicket:id="name" class="mr-4 text-break"></span>
- <span wicket:id="duration" class="ml-auto"></span>
+ <span wicket:id="duration" class="text-nowrap ml-auto"></span>
</div>
- <pre wicket:id="detail" class="text-gray font-size-sm text-break mt-3"></pre>
+ <div wicket:id="detail" class="unit-test-case-detail text-gray font-size-sm whitespace-pre-wrap text-break mt-3"></div>
</td>
</tr>
</tbody>
diff --git a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.java b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.java
index 923562b91b..08aecfd2d0 100644
--- a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.java
+++ b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestCasesPage.java
@@ -436,7 +436,7 @@ public class UnitTestCasesPage extends UnitTestReportPage {
else
item.add(new WebMarkupContainer("duration").setVisible(false));
- Component detailViewer = testCase.renderDetail("detail", getBuild());
+ Component detailViewer = testCase.renderDetail("detail", getBuild(), getReportName());
if (detailViewer != null)
item.add(detailViewer);
else
diff --git a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestReport.java b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestReport.java
index 0d1e9b63c9..98868a88ac 100644
--- a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestReport.java
+++ b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestReport.java
@@ -226,7 +226,7 @@ public class UnitTestReport implements Serializable {
}
@Nullable
- protected abstract Component renderDetail(String componentId, Build build);
+ protected abstract Component renderDetail(String componentId, Build build, String reportName);
}
diff --git a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestSuitesPage.html b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestSuitesPage.html
index 155c7f4a93..b11a8d02a2 100644
--- a/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestSuitesPage.html
+++ b/server-plugin/server-plugin-report-unittest/src/main/java/io/onedev/server/plugin/report/unittest/UnitTestSuitesPage.html
@@ -32,7 +32,7 @@
</span>
<span wicket:id="duration" class="ml-auto"></span>
</div>
- <pre wicket:id="detail" class="text-gray font-size-sm text-break mt-3"></pre>
+ <div wicket:id="detail" class="text-gray font-size-sm text-break mt-3 whitespace-pre-wrap"></div>
</td>
</tr>
</tbody>
diff --git a/server-product/pom.xml b/server-product/pom.xml
index 493f6f3935..a28f764307 100644
--- a/server-product/pom.xml
+++ b/server-product/pom.xml
@@ -25,6 +25,11 @@
<artifactId>server-plugin-report-jest</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>io.onedev</groupId>
+ <artifactId>server-plugin-report-playwright</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>io.onedev</groupId>
<artifactId>server-plugin-report-junit</artifactId>