Skip to content

Commit

Permalink
Merge branch 'master' into fix-diff-images-saving
Browse files Browse the repository at this point in the history
  • Loading branch information
shtyr-maxim authored Jul 4, 2024
2 parents b77dcf2 + 0cef1cd commit 412d940
Show file tree
Hide file tree
Showing 83 changed files with 2,350 additions and 1,109 deletions.
24 changes: 3 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,22 @@ jobs:
build:
working_directory: ~/html-reporter
docker:
- image: cimg/node:16.20-browsers
- image: yinfra/html-reporter-browsers
environment:
CHROME_VERSION: 116
SERVER_HOST: localhost

steps:

- checkout

- run: npm ci
- run:
name: Build html-reporter

command: npm run build
- run:
name: Download Chromium
command: >-
cd test/func/docker/browser-utils &&
npm ci &&
npm run install-chromium

- run:
name: Install Chromium for Playwright
command: npx playwright install chromium

- run:
name: Download Selenium
command: npm install [email protected] -g
- run:
name: Start Selenium
command: >-
selenium-standalone install --drivers.chrome.version=$CHROME_VERSION &&
selenium-standalone start --drivers.chrome.version=$CHROME_VERSION
background: true

- run:
name: Functional tests
command: npm run e2e
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: NPM publish
on:
workflow_dispatch:
inputs:
versionType:
type: choice
description: Version Type
required: true
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
publish:
name: Publishing to NPM
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Setup Node JS
uses: actions/setup-node@v2
with:
node-version: 18
registry-url: https://registry.npmjs.org
- run: npm ci
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "y-infra"
- run: npm run release -- --release-as ${{ github.event.inputs.versionType }}
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git push --follow-tags
87 changes: 87 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,93 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="10.3.2"></a>
## [10.3.2](https://github.com/gemini-testing/html-reporter/compare/v10.3.1...v10.3.2) (2024-07-02)


### Bug Fixes

* fix copy button text ([#563](https://github.com/gemini-testing/html-reporter/issues/563)) ([e197d22](https://github.com/gemini-testing/html-reporter/commit/e197d22))



<a name="10.3.1"></a>
## [10.3.1](https://github.com/gemini-testing/html-reporter/compare/v10.3.0...v10.3.1) (2024-06-26)


### Bug Fixes

* result state after screenshot-accepter image accept ([fa18026](https://github.com/gemini-testing/html-reporter/commit/fa18026))



<a name="10.3.0"></a>
# [10.3.0](https://github.com/gemini-testing/html-reporter/compare/v10.0.0...v10.3.0) (2024-06-21)


### Bug Fixes

* escape regexp chars when copying a test link ([#552](https://github.com/gemini-testing/html-reporter/issues/552)) ([e7b2103](https://github.com/gemini-testing/html-reporter/commit/e7b2103))
* save RunMode to localStorage ([#554](https://github.com/gemini-testing/html-reporter/issues/554)) ([e523e21](https://github.com/gemini-testing/html-reporter/commit/e523e21))
* **pwt:** ignore private report options from pwt ([88e9e5d](https://github.com/gemini-testing/html-reporter/commit/88e9e5d))


### Features

* add ability to run cli commands using html-reporter binary ([db0862c](https://github.com/gemini-testing/html-reporter/commit/db0862c))
* add copy to clipboard button to all fields in meta ([fb651d0](https://github.com/gemini-testing/html-reporter/commit/fb651d0))
* add relativePath to refImg ([b722899](https://github.com/gemini-testing/html-reporter/commit/b722899))



<a name="10.2.0"></a>
# [10.2.0](https://github.com/gemini-testing/html-reporter/compare/v10.0.0...v10.2.0) (2024-06-20)


### Features

* add relativePath to refImg ([b722899](https://github.com/gemini-testing/html-reporter/commit/b722899))



<a name="10.1.0"></a>
# [10.1.0](https://github.com/gemini-testing/html-reporter/compare/v10.0.0...v10.1.0) (2024-06-20)


### Bug Fixes

* escape regexp chars when copying a test link ([#552](https://github.com/gemini-testing/html-reporter/issues/552)) ([e7b2103](https://github.com/gemini-testing/html-reporter/commit/e7b2103))
* save RunMode to localStorage ([#554](https://github.com/gemini-testing/html-reporter/issues/554)) ([e523e21](https://github.com/gemini-testing/html-reporter/commit/e523e21))
* **pwt:** ignore private report options from pwt ([88e9e5d](https://github.com/gemini-testing/html-reporter/commit/88e9e5d))


### Features

* add ability to run cli commands using html-reporter binary ([db0862c](https://github.com/gemini-testing/html-reporter/commit/db0862c))



<a name="10.0.0"></a>
# [10.0.0](https://github.com/gemini-testing/html-reporter/compare/v9.19.0...v10.0.0) (2024-05-31)


### Bug Fixes

* align the menu icon with the rest of the items ([0d493cc](https://github.com/gemini-testing/html-reporter/commit/0d493cc))
* handle edge case when error is null ([#523](https://github.com/gemini-testing/html-reporter/issues/523)) ([65b3808](https://github.com/gemini-testing/html-reporter/commit/65b3808))


### Features

* drop node versions less than 18 ([5569be6](https://github.com/gemini-testing/html-reporter/commit/5569be6))


### BREAKING CHANGES

* node versions less than 18.0.0 are no longer supported



<a name="9.19.0"></a>
# [9.19.0](https://github.com/gemini-testing/html-reporter/compare/v9.18.1...v9.19.0) (2024-05-01)

Expand Down
41 changes: 38 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ In order to make e2e/screenshot tests stable and reproducible across different e
you need to launch browsers inside a Docker container.

1. Make sure you have Docker installed.
<details><summary>How to?</summary>
<details>
<summary>How to?</summary>

1. If you want to make a personal open-source contribution, you may use Docker free of charge and follow the [official guide](https://docs.docker.com/get-docker/).
2. If you are acting on behalf of a company, you may not have access to Docker Desktop. In this case:
- On Linux, you may follow the official installation guide.
- On Mac, you may use [colima](https://github.com/abiosoft/colima) as a replacement for Docker Desktop.
- On Windows, you may use Windows Subsystem for Linux to run the Docker CLI without the Desktop application.
</details>

2. Build and start an image with browsers:
2. Start an image with browsers:
```
npm run e2e:build-browsers && npm run e2e:launch-browsers
npm run browsers:launch
```
3. Run e2e tests:
```bash
Expand All @@ -38,3 +40,36 @@ If you want a finer-grained control over the process, the following commands may
- `npm run e2e:generate-fixtures` — generate fixture reports to run tests on
- `npm run --workspace=test/func/tests gui:plugins` — launch hermione GUI for the `plugins` tests set
- `npm run e2e:test` — run e2e tests only, without building packages or generating fixtures
### Working with browser docker images
#### Building an image for current platform
If you want to build an image with browsers you can use this command:
- `npm run browsers:build:local`
#### Building a multiplatform image on Mac (Apple Silicon)
If you use colima then you can follow these steps to build a multiplatform image:
1. Install buildx
- `brew install docker-buildx`
- `docker buildx install`
2. Start 2 instances
- `colima start --profile amd --arch amd`
- `colima start --profile arm --arch arm`
3. Create a buildx context to use the created instances as nodes
- `docker buildx create --use --name custom colima-amd`
- `docker buildx create --append --name custom colima-arm`
4. Build and publish an image
- `npm run browsers:build-and-push`
Note: to use already created buildx instance, execute this command:
- `docker buildx use custom`
#### Managing multiple colima instances
To get the list of all colima instances you can use `colima list`.
To use specific colima instance, you have to set DOCKER_HOST environment variable.
To get the desired value for DOCKER_HOST, use `colima status [INSTANCE]`
If you want to update chromedriver or chrome version, change the variables at the beginning of the [Dockerfile](/test/func/docker/Dockerfile).
6 changes: 6 additions & 0 deletions bin/html-reporter
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node
'use strict';

(async () => {
await require('../build/lib/cli').run();
})();
5 changes: 5 additions & 0 deletions lib/adapters/test-result/hermione.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
TestplaneTestResultAdapter as HermioneTestResultAdapter,
TestplaneTestResultAdapterOptions as HermioneTestResultAdapterOptions,
getStatus
} from './testplane';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {TestStatus} from '../constants';
import {ErrorDetails, ImageBase64, ImageFile, ImageInfoFull, TestError} from '../types';
import {TestStatus} from '../../constants';
import {ErrorDetails, ImageBase64, ImageFile, ImageInfoFull, TestError} from '../../types';

export interface ReporterTestResult {
readonly attempt: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import _ from 'lodash';
import stripAnsi from 'strip-ansi';

import {ReporterTestResult} from './index';
import {getError, getShortMD5, isImageDiffError, isNoRefImageError} from '../common-utils';
import {ERROR, FAIL, PWT_TITLE_DELIMITER, SUCCESS, TestStatus} from '../constants';
import {ErrorName} from '../errors';
import {getError, getShortMD5, isImageDiffError, isNoRefImageError} from '../../common-utils';
import {ERROR, FAIL, PWT_TITLE_DELIMITER, SUCCESS, TestStatus} from '../../constants';
import {ErrorName} from '../../errors';
import {
DiffOptions,
ErrorDetails,
Expand All @@ -16,7 +16,7 @@ import {
ImageInfoFull, ImageInfoNoRef, ImageInfoPageError, ImageInfoPageSuccess, ImageInfoSuccess,
ImageSize,
TestError
} from '../types';
} from '../../types';
import type {CoordBounds} from 'looks-same';

export type PlaywrightAttachment = PlaywrightTestResult['attachments'][number];
Expand Down Expand Up @@ -127,7 +127,7 @@ const getImageData = (attachment: PlaywrightAttachment | undefined): ImageFile |
};
};

export class PlaywrightTestAdapter implements ReporterTestResult {
export class PlaywrightTestResultAdapter implements ReporterTestResult {
private readonly _testCase: PlaywrightTestCase;
private readonly _testResult: PlaywrightTestResult;
private _attempt: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {TestStatus} from '../constants';
import {TestError, ErrorDetails, ImageInfoFull, ImageBase64, ImageFile} from '../types';
import {TestStatus} from '../../constants';
import {TestError, ErrorDetails, ImageInfoFull, ImageBase64, ImageFile} from '../../types';
import {ReporterTestResult} from './index';
import _ from 'lodash';
import {extractErrorDetails} from './utils';
import {getShortMD5, getTestHash} from '../common-utils';
import {getShortMD5, getTestHash} from '../../common-utils';

// This class is primarily useful when cloning ReporterTestResult.
// It allows to override some properties while keeping computable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import {DB_COLUMN_INDEXES, TestStatus} from '../constants';
import {DB_COLUMN_INDEXES, TestStatus} from '../../constants';
import {
AssertViewResult,
TestError,
Expand All @@ -8,10 +8,10 @@ import {
ImageBase64,
ImageFile,
RawSuitesRow
} from '../types';
} from '../../types';
import {ReporterTestResult} from './index';
import {Writable} from 'type-fest';
import {getTestHash} from '../common-utils';
import {getTestHash} from '../../common-utils';

const tryParseJson = (json: string): unknown | undefined => {
try {
Expand All @@ -21,16 +21,16 @@ const tryParseJson = (json: string): unknown | undefined => {
}
};

interface SqliteTestAdapterOptions {
interface SqliteTestResultAdapterOptions {
titleDelimiter: string;
}

export class SqliteTestAdapter implements ReporterTestResult {
export class SqliteTestResultAdapter implements ReporterTestResult {
private _testResult: RawSuitesRow;
private _parsedTestResult: Writable<Partial<ReporterTestResult>>;
private _titleDelimiter: string;

constructor(testResult: RawSuitesRow, attempt: number, options: SqliteTestAdapterOptions) {
constructor(testResult: RawSuitesRow, attempt: number, options: SqliteTestResultAdapterOptions) {
this._testResult = testResult;
this._parsedTestResult = {attempt};
this._titleDelimiter = options.titleDelimiter;
Expand Down
Loading

0 comments on commit 412d940

Please sign in to comment.