Skip to content

Commit

Permalink
Merge branch 'main' into FI-494
Browse files Browse the repository at this point in the history
  • Loading branch information
nnn3d authored Nov 17, 2023
2 parents b03ad55 + 1b71e54 commit ab4f911
Show file tree
Hide file tree
Showing 51 changed files with 674 additions and 301 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rules:
import/no-commonjs: error
import/no-default-export: error
import/no-deprecated: error
import/no-duplicates: error
import/no-duplicates: [error, {prefer-inline: true}]
import/no-extraneous-dependencies: [error, {devDependencies: false, packageDir: [., ./autotests]}]
import/no-internal-modules:
- error
Expand Down Expand Up @@ -166,6 +166,7 @@ rules:
- {selector: typeLike, format: [StrictPascalCase]}
- {selector: [objectLiteralProperty, typeProperty], format: null, modifiers: [requiresQuotes]}
- {selector: [classProperty, typeMethod], filter: '^toJSON$', format: null}
'@typescript-eslint/no-import-type-side-effects': error
'@typescript-eslint/no-invalid-void-type':
[error, {allowInGenericTypeArguments: true, allowAsThisParameter: true}]
'@typescript-eslint/no-namespace': [error, {allowDeclarations: true}]
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## [v0.15.10](https://github.com/joomcode/e2ed/tree/v0.15.10) (2023-11-15)

[Full Changelog](https://github.com/joomcode/e2ed/compare/v0.15.9...v0.15.10)

- [Merge pull request #45 from joomcode/fix/timeout-for-take-screenshot](https://github.com/joomcode/e2ed/commit/ff05c039df004d94e87195a971caa993e1cb555b) ([uid11](https://github.com/uid11))

fix: disable timeout for taking error screenshot

- [FI-1015 feat: add locators to HTML report for testing locator utils](https://github.com/joomcode/e2ed/commit/14e743a5345f327d98d2fd7ccc13a4514955cf17) ([uid11](https://github.com/uid11))
- [chore: update devDependencies (@typescript-eslint/\*, prettier)](https://github.com/joomcode/e2ed/commit/65238598df2529dfce2cd164b3159a991ad2ad17) ([uid11](https://github.com/uid11))
- [fix: trim strings in logs by default](https://github.com/joomcode/e2ed/commit/96844c19ca8cba477ae58699df7a3faa50ae13cc) ([uid11](https://github.com/uid11))

fix: improving the stability of `exists` test (`waitFor*` checks)

- [FI-1013 fix: disable timeout for taking error screenshot](https://github.com/joomcode/e2ed/commit/9ab6f35b1162ec45ce6113ee6c140bf9f9533546) ([uid11](https://github.com/uid11))

feat: add `replaceFields` utility in configurator to reduce logs

fix: add more eslint rules abouts type imports

## [v0.15.9](https://github.com/joomcode/e2ed/tree/v0.15.9) (2023-11-12)

[Full Changelog](https://github.com/joomcode/e2ed/compare/v0.15.8...v0.15.9)
Expand Down
1 change: 1 addition & 0 deletions autotests/configurator/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export {doAfterPack} from './doAfterPack';
export {doBeforePack} from './doBeforePack';
export {mapLogPayloadInConsole} from './mapLogPayloadInConsole';
export {mapLogPayloadInReport} from './mapLogPayloadInReport';
export {skipTests} from './skipTests';
27 changes: 27 additions & 0 deletions autotests/configurator/mapLogPayloadInReport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {replaceFields} from 'e2ed/configurator';

import type {MapLogPayloadInReport} from 'autotests/types/packSpecific';
import type {FieldReplacer} from 'e2ed/types';

const maxStringLengthInReportLogs = 512;

const replacer: FieldReplacer = (path, value) => {
if (typeof value === 'string' && value.length > maxStringLengthInReportLogs) {
const halfOfLength = Math.floor(maxStringLengthInReportLogs / 2);
const numberOfCuttedSymbols = value.length - 2 * halfOfLength;

return `${value.slice(0, halfOfLength)}...(${numberOfCuttedSymbols} symbols)...${value.slice(
-halfOfLength,
)}`;
}

return value;
};

/**
* Maps log payload for logging in HTML console to clarify, shorten or skip a console log entry.
* If the mapping returns `null`, the log entry is skipped.
* If the mapping returns `undefined`, the log entry is not skipped, but is printed with an empty payload.
*/
export const mapLogPayloadInReport: MapLogPayloadInReport = (_message, payload) =>
replaceFields(payload, replacer);
10 changes: 8 additions & 2 deletions autotests/packs/allTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import {RunEnvironment, runEnvironment} from 'e2ed/configurator';

import {doAfterPack, doBeforePack, mapLogPayloadInConsole, skipTests} from '../configurator';
import {
doAfterPack,
doBeforePack,
mapLogPayloadInConsole,
mapLogPayloadInReport,
skipTests,
} from '../configurator';

import type {FilterTestsIntoPack, Pack} from 'autotests/types/packSpecific';

Expand Down Expand Up @@ -37,7 +43,7 @@ export const pack: Pack = {
logFileName: 'pack-logs.log',
mapLogPayloadInConsole,
mapLogPayloadInLogFile: (_message, payload) => payload,
mapLogPayloadInReport: (_message, payload) => payload,
mapLogPayloadInReport,
maxRetriesCountInDocker: 3,
packTimeout: 90 * 60_000,
pageRequestTimeout: 30_000,
Expand Down
4 changes: 2 additions & 2 deletions autotests/pageObjects/pages/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export class Main extends Page<CustomPageParams> {
readonly searchInput = new Input('q');

/**
* Current search string.
* Current value of search query.
*/
get searchString(): Promise<string> {
get searchQuery(): Promise<string> {
return this.searchInput.value;
}

Expand Down
2 changes: 1 addition & 1 deletion autotests/routes/pageRoutes/E2edReportExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {Url} from 'e2ed/types';
*/
export class E2edReportExample extends PageRoute {
override getOrigin(): Url {
return 'https://uid11.github.io' as Url;
return 'https://joomcode.github.io' as Url;
}

getPath(): string {
Expand Down
12 changes: 7 additions & 5 deletions autotests/tests/main/exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,23 @@ it('exists', {meta: {testId: '1'}, testIdleTimeout: 35_000, testTimeout: 90_000}
language,
});

await expect(mainPage.searchString, 'search string is empty').eql('');
await expect(mainPage.searchQuery, 'search query on page is empty').eql('');

await mainPage.typeIntoSearchInput(searchQuery);

await expect(mainPage.searchString, 'search string has setted value').eql(searchQuery);
await expect(mainPage.searchQuery, 'search query on page has setted value').eql(searchQuery);

await expect(mainPage.body.find('input').exists, 'page contains some input element').ok();

await pressKey('enter', {stabilizationInterval: 300});

const [requestWithQuery, successfulResponse] = await Promise.all([
const requestsPromises = Promise.all([
waitForRequest(({url}) => url.includes(searchQuery)),
waitForResponse(({statusCode}) => statusCode === 200),
]);

await pressKey('enter', {stabilizationInterval: 300});

const [requestWithQuery, successfulResponse] = await requestsPromises;

await expect(requestWithQuery.url, 'request with query contains search query').contains(
searchQuery,
);
Expand Down
Loading

0 comments on commit ab4f911

Please sign in to comment.