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

Separated E2E tests for awesome #95

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"author": "Qameta Software",
"type": "module",
"scripts": {
"test": "playwright test"
"test": "run-s 'test:*'",
"test:single-file": "ALLURE_SINGLE_FILE=1 playwright test",
"test:multi-file": "playwright test"
},
"devDependencies": {
"@allurereport/core": "workspace:*",
Expand All @@ -29,6 +31,7 @@
"eslint-plugin-n": "^17.10.1",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"npm-run-all2": "^7.0.2",
"prettier": "^3.3.3",
"rimraf": "^6.0.1"
},
Expand Down
75 changes: 75 additions & 0 deletions packages/e2e/test/allure-awesome/reportModes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { expect, test } from "@playwright/test";
import { Stage, Status } from "allure-js-commons";
import { readdir } from "node:fs/promises";
import { type ReportBootstrap, boostrapReport } from "../utils/index.js";

let bootstrap: ReportBootstrap;

const now = Date.now();
const fixtures = {
testResults: [
{
name: "0 sample passed test",
fullName: "sample.js#0 sample passed test",
status: Status.PASSED,
stage: Stage.FINISHED,
start: now,
stop: now + 1000,
},
],
};

test.afterAll(async () => {
await bootstrap?.shutdown?.();
});

test.describe("single file mode", () => {
test("should generate a single file report", async ({ page }) => {
bootstrap = await boostrapReport({
reportConfig: {
name: "Sample allure report",
appendHistory: false,
history: undefined,
historyPath: undefined,
knownIssuesPath: undefined,
},
pluginConfig: {
singleFile: true,
},
testResults: fixtures.testResults,
});

await page.goto(bootstrap.url);

const files = await readdir(bootstrap.servePath);

expect(files).toHaveLength(1);
expect(files).toContain("index.html");
await expect(page.getByTestId("report-title")).toHaveText("Sample allure report");
});
});

test.describe("multi file mode", () => {
test("should generate a multi file report", async ({ page }) => {
bootstrap = await boostrapReport({
reportConfig: {
name: "Sample allure report",
appendHistory: false,
history: undefined,
historyPath: undefined,
knownIssuesPath: undefined,
},
pluginConfig: {
singleFile: false,
},
testResults: fixtures.testResults,
});

await page.goto(bootstrap.url);

const files = await readdir(bootstrap.servePath);

expect(files.length > 1).toBe(true);
await expect(page.getByTestId("report-title")).toHaveText("Sample allure report");
});
});
5 changes: 2 additions & 3 deletions packages/e2e/test/allure-awesome/reportOptions.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, test } from "@playwright/test";
import { layer } from "allure-js-commons";
import { Stage, Status } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport } from "../utils/index.js";
import { type ReportBootstrap, boostrapReport, setEnvParameters } from "../utils/index.js";

let bootstrap: ReportBootstrap;

Expand All @@ -24,7 +23,7 @@ test.afterAll(async () => {
});

test.beforeEach(async () => {
await layer("e2e");
await setEnvParameters();
});

test.describe("allure-awesome", () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/test/allure-awesome/testResult.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, test } from "@playwright/test";
import { layer } from "allure-js-commons";
import { Stage, Status } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport, randomNumber } from "../utils/index.js";
import { type ReportBootstrap, boostrapReport, randomNumber, setEnvParameters } from "../utils/index.js";

let bootstrap: ReportBootstrap;

Expand Down Expand Up @@ -72,7 +71,7 @@ test.afterAll(async () => {
});

test.beforeEach(async ({ page }) => {
await layer("e2e");
await setEnvParameters();
await page.goto(bootstrap.url);
});

Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/test/allure-awesome/tree/commons.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { expect, test } from "@playwright/test";
import { layer } from "allure-js-commons";
import { Stage, Status } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport } from "../../utils/index.js";
import { type ReportBootstrap, boostrapReport, setEnvParameters } from "../../utils/index.js";

let bootstrap: ReportBootstrap;

test.beforeEach(async ({ page }) => {
await layer("e2e");
await setEnvParameters();

if (bootstrap) {
await page.goto(bootstrap.url);
Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/test/allure-awesome/tree/features.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, test } from "@playwright/test";
import { Stage, Status } from "allure-js-commons";
import { layer } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport } from "../../utils/index.js";
import { type ReportBootstrap, boostrapReport, setEnvParameters } from "../../utils/index.js";

let bootstrap: ReportBootstrap;

Expand Down Expand Up @@ -43,7 +42,7 @@ test.describe("stories", () => {
});

test.beforeEach(async ({ page }) => {
await layer("e2e");
await setEnvParameters();
await page.goto(bootstrap.url);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/e2e/test/allure-awesome/tree/search.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from "@playwright/test";
import { Stage, Status, layer } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport } from "../../utils/index.js";
import { Stage, Status } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport, setEnvParameters } from "../../utils/index.js";

let bootstrap: ReportBootstrap;

Expand Down Expand Up @@ -41,7 +41,7 @@ test.beforeAll(async () => {
});

test.beforeEach(async ({ page }) => {
await layer("e2e");
await setEnvParameters();
await page.goto(bootstrap.url);
});

Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/test/allure-awesome/tree/stories.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, test } from "@playwright/test";
import { Stage, Status } from "allure-js-commons";
import { layer } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport } from "../../utils/index.js";
import { type ReportBootstrap, boostrapReport, setEnvParameters } from "../../utils/index.js";

let bootstrap: ReportBootstrap;

Expand Down Expand Up @@ -43,7 +42,7 @@ test.describe("stories", () => {
});

test.beforeEach(async ({ page }) => {
await layer("e2e");
await setEnvParameters();
await page.goto(bootstrap.url);
});

Expand Down
10 changes: 5 additions & 5 deletions packages/e2e/test/allure-awesome/tree/suites.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { expect, test } from "@playwright/test";
import { Stage, Status } from "allure-js-commons";
import { layer } from "allure-js-commons";
import { type ReportBootstrap, boostrapReport } from "../../utils/index.js";
import { type ReportBootstrap, boostrapReport, setEnvParameters } from "../../utils/index.js";

let bootstrap: ReportBootstrap;

test.describe("suites", () => {
test.beforeEach(async () => {
await setEnvParameters();
});

test.afterEach(async () => {
await bootstrap?.shutdown?.();
});
Expand Down Expand Up @@ -52,7 +55,6 @@ test.describe("suites", () => {
],
});

await layer("e2e");
await page.goto(bootstrap.url);

const treeLeaves = page.getByTestId("tree-leaf");
Expand Down Expand Up @@ -118,7 +120,6 @@ test.describe("suites", () => {
],
});

await layer("e2e");
await page.goto(bootstrap.url);

const treeLeaves = page.getByTestId("tree-leaf");
Expand Down Expand Up @@ -182,7 +183,6 @@ test.describe("suites", () => {
],
});

await layer("e2e");
await page.goto(bootstrap.url);

const treeLeaves = page.getByTestId("tree-leaf");
Expand Down
21 changes: 16 additions & 5 deletions packages/e2e/test/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { AllureReport, FileSystemReportFiles, type FullConfig } from "@allurereport/core";
import AllureAwesomePlugin from "@allurereport/plugin-awesome";
import { serve } from "@allurereport/static-server";
import { type TestResult } from "allure-js-commons";
import { type TestResult, parameter } from "allure-js-commons";
import { FileSystemWriter, ReporterRuntime } from "allure-js-commons/sdk/reporter";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { resolve } from "node:path";
import { env } from "node:process";

const { ALLURE_SINGLE_FILE } = env;

export type GeneratorParams = {
reportDir: string;
Expand All @@ -17,9 +20,14 @@ export type GeneratorParams = {

export interface ReportBootstrap {
url: string;
servePath: string;
shutdown: () => Promise<void>;
}

export const setEnvParameters = async () => {
await parameter("singleFile", String(Boolean(ALLURE_SINGLE_FILE)));
};

export const randomNumber = (min: number, max: number) => {
if (min > max) {
[min, max] = [max, min];
Expand All @@ -35,10 +43,11 @@ export const generateTestResults = async (payload: GeneratorParams) => {
{
id: "awesome",
enabled: true,
plugin: new AllureAwesomePlugin(pluginConfig),
options: {
plugin: new AllureAwesomePlugin({
singleFile: Boolean(ALLURE_SINGLE_FILE),
...pluginConfig,
},
}),
options: {},
},
],
...reportConfig,
Expand Down Expand Up @@ -75,12 +84,14 @@ export const boostrapReport = async (
reportDir: allureReportDir,
});

const servePath = resolve(allureReportDir, "./awesome");
const server = await serve({
servePath: resolve(allureReportDir, "./awesome"),
servePath,
});

return {
url: `http://localhost:${server.port}`,
servePath,
shutdown: async () => {
await server?.stop();

Expand Down
1 change: 0 additions & 1 deletion packages/web-classic/src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,4 @@
"suites": "Suiten",
"timeline": "Zeitleiste"
}

}
13 changes: 0 additions & 13 deletions packages/web-components/src/components/Button/Button.test.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions packages/web-components/src/components/Link/Link.test.tsx

This file was deleted.

Loading
Loading