Skip to content

Commit

Permalink
Classic updates (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
todti authored Feb 7, 2025
1 parent 50e9690 commit f955e7b
Show file tree
Hide file tree
Showing 641 changed files with 21,510 additions and 5,530 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ module.exports = {
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-imports": ["error", {
fixStyle: 'separate-type-imports',
prefer: 'type-imports',
}],
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/explicit-member-accessibility": [
"off",
Expand Down
3,720 changes: 2,228 additions & 1,492 deletions .pnp.cjs

Large diffs are not rendered by default.

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.
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.
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.
7 changes: 7 additions & 0 deletions allurerc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export default defineConfig({
groupBy: ["module", "parentSuite", "suite", "subSuite"],
},
},
allure2: {
options: {
singleFile: true,
reportLanguage: "en",
groupBy: ["module", "parentSuite", "suite", "subSuite"],
},
},
log: {
options: {
groupBy: "none",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
"@allurereport/core": "workspace:*",
"@allurereport/core-api": "workspace:*",
"@allurereport/directory-watcher": "workspace:*",
"@allurereport/plugin-allure2": "workspace:*",
"@allurereport/plugin-api": "workspace:*",
"@allurereport/plugin-awesome": "workspace:*",
"@allurereport/plugin-classic": "workspace:*",
"@allurereport/plugin-progress": "workspace:*",
"@allurereport/plugin-server-reload": "workspace:*",
"@allurereport/plugin-slack": "workspace:*",
Expand Down
84 changes: 84 additions & 0 deletions packages/cli/src/commands/allure2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { AllureReport, resolveConfig } from "@allurereport/core";
import * as console from "node:console";
import { createCommand } from "../utils/commands.js";

type ClassicCommandOptions = {
output?: string;
reportName?: string;
reportLanguage?: string;
singleFile?: boolean;
historyPath?: string;
knownIssues?: string;
};

export const ClassicLegacyCommandAction = async (resultsDir: string, options: ClassicCommandOptions) => {
const before = new Date().getTime();
const { output, reportName: name, historyPath, knownIssues: knownIssuesPath, ...rest } = options;
const config = await resolveConfig({
output,
name,
historyPath,
knownIssuesPath,
plugins: {
"@allurereport/plugin-allure2": {
options: rest,
},
},
});
const allureReport = new AllureReport(config);

await allureReport.start();
await allureReport.readDirectory(resultsDir);
await allureReport.done();

const after = new Date().getTime();

console.log(`the report successfully generated (${after - before}ms)`);
};

export const ClassicLegacyCommand = createCommand({
name: "allure2 <resultsDir>",
description: "Generates Allure Classic report based on provided Allure Results",
options: [
[
"--output, -o <file>",
{
description: "The output directory name. Absolute paths are accepted as well",
default: "allure-report",
},
],
[
"--report-name, --name <string>",
{
description: "The report name",
default: "Allure Report",
},
],
[
"--report-language, --lang <string>",
{
description: "Default language of the report (default: OS language)",
},
],
[
"--single-file",
{
description: "Generate single file report",
default: false,
},
],
[
"--history-path, -h <file>",
{
description: "The path to history file",
},
],
[
"--known-issues <file>",
{
description: "Path to the known issues file. Updates the file and quarantines failed tests when specified",
},
],
],
action: ClassicLegacyCommandAction,
});
1 change: 1 addition & 0 deletions packages/cli/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from "./history.js";
export * from "./testplan.js";
export * from "./classic.js";
export * from "./allure2.js";
export * from "./awesome.js";
export * from "./csv.js";
export * from "./history.js";
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { cwd } from "node:process";
import {
AwesomeCommand,
ClassicCommand,
ClassicLegacyCommand,
CsvCommand,
GenerateCommand,
HistoryCommand,
Expand All @@ -25,6 +26,7 @@ const pkg: { name: string; description: string; version: string } = JSON.parse(
const cli = cac(pkg.name).usage(pkg.description).help().version(pkg.version);
const commands = [
ClassicCommand,
ClassicLegacyCommand,
AwesomeCommand,
CsvCommand,
GenerateCommand,
Expand Down
1 change: 1 addition & 0 deletions packages/core-api/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface TestResult {
runSelector?: string;

retries?: TestResult[];
categories?: any;
}

export interface TestFixtureResult {
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"@allurereport/core-api": "workspace:*",
"@allurereport/plugin-allure2": "workspace:*",
"@allurereport/plugin-api": "workspace:*",
"@allurereport/plugin-awesome": "workspace:*",
"@allurereport/plugin-classic": "workspace:*",
Expand Down
13 changes: 13 additions & 0 deletions packages/plugin-allure2/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
env: { browser: true, es2020: true },
extends: ["../../.eslintrc.cjs"],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
},

],
};
54 changes: 54 additions & 0 deletions packages/plugin-allure2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Classic Plugin

[<img src="https://allurereport.org/public/img/allure-report.svg" height="85px" alt="Allure Report logo" align="right" />](https://allurereport.org "Allure Report")

- Learn more about Allure Report at https://allurereport.org
- 📚 [Documentation](https://allurereport.org/docs/) – discover official documentation for Allure Report
-[Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) – get help from the team and community
- 📢 [Official announcements](https://github.com/orgs/allure-framework/discussions/categories/announcements) – be in touch with the latest updates
- 💬 [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) – engage in casual conversations, share insights and ideas with the community

---

## Overview

The plugin generates a classic Allure Report.

## Install

Use your favorite package manager to install the package:

```shell
npm add @allurereport/plugin-classic
yarn add @allurereport/plugin-classic
pnpm add @allurereport/plugin-classic
```

Then, add the plugin to the Allure configuration file:

```diff
import { defineConfig } from "allure";

export default defineConfig({
name: "Allure Report",
output: "./allure-report",
historyPath: "./history.jsonl",
plugins: {
+ classic: {
+ options: {
+ reportName: "HelloWorld",
+ },
+ },
},
});
```

## Options

The plugin accepts the following options:

| Option | Description | Type | Default |
|------------------|-------------------------------------------------|--------------------------------------------------------------|-----------------|
| `reportName` | Name of the report | `string` | `Allure Report` |
| `singleFile` | Writes the report as a single `index.html` file | `boolean` | `false` |
| `reportLanguage` | Default language of the report | `string` | OS language |
58 changes: 58 additions & 0 deletions packages/plugin-allure2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "@allurereport/plugin-allure2",
"version": "3.0.0-beta.7",
"description": "The classic version of Allure HTML report",
"keywords": [
"allure",
"testing",
"report",
"plugin",
"html"
],
"repository": "https://github.com/allure-framework/allure3",
"license": "Apache-2.0",
"author": "Qameta Software",
"type": "module",
"exports": {
".": "./dist/index.js"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"./dist"
],
"scripts": {
"build": "run clean && tsc --project ./tsconfig.json",
"clean": "rimraf ./dist",
"eslint": "eslint ./src/**/*.{js,jsx,ts,tsx}",
"eslint:format": "eslint --fix ./src/**/*.{js,jsx,ts,tsx}",
"test": "rimraf ./out && vitest run"
},
"dependencies": {
"@allurereport/core-api": "workspace:*",
"@allurereport/plugin-api": "workspace:*",
"@allurereport/web-allure2": "workspace:*",
"@allurereport/web-commons": "workspace:*",
"handlebars": "^4.7.8"
},
"devDependencies": {
"@stylistic/eslint-plugin": "^2.6.1",
"@types/eslint": "^8.56.11",
"@types/node": "^20.17.9",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@vitest/runner": "^2.1.8",
"allure-vitest": "^3.0.9",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^50.0.0",
"eslint-plugin-n": "^17.10.1",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"rimraf": "^6.0.1",
"typescript": "^5.6.3",
"vitest": "^2.1.8"
}
}
54 changes: 54 additions & 0 deletions packages/plugin-allure2/src/categories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { Allure2Category, Allure2Status } from "./model.js";

const productDefects: Allure2Category = {
name: "Product defects",
matchedStatuses: ["failed"],
};

const testDefects: Allure2Category = {
name: "Test defects",
matchedStatuses: ["broken"],
};

export const matchCategories = (
categories: Allure2Category[],
result: { statusMessage?: string; statusTrace?: string; status: Allure2Status; flaky: boolean },
) => {
const matched = categories.filter((category) => categoryMatch(category, result));

if (matched.length === 0 && categoryMatch(productDefects, result)) {
matched.push(productDefects);
}
if (matched.length === 0 && categoryMatch(testDefects, result)) {
matched.push(testDefects);
}
return matched;
};

const categoryMatch = (
category: Allure2Category,
result: { statusMessage?: string; statusTrace?: string; status: Allure2Status; flaky: boolean },
): boolean => {
const { status, statusMessage, statusTrace, flaky } = result;
const matchesStatus =
!category.matchedStatuses || category.matchedStatuses.length === 0 || category.matchedStatuses.includes(status);
const matchesMessage = match(category.messageRegex, statusMessage);
const matchesTrace = match(category.traceRegex, statusTrace);
const matchesFlaky = (category.flaky ?? flaky) === flaky;
return matchesStatus && matchesMessage && matchesTrace && matchesFlaky;
};

const match = (regex?: string, value?: string): boolean => {
if (!regex) {
return true;
}
if (!value) {
return false;
}
try {
const b = new RegExp(regex, "s").test(value);
return b;
} catch (ignored) {
return false;
}
};
Loading

0 comments on commit f955e7b

Please sign in to comment.