Skip to content
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
- [fix: add `expect` method `toBeInViewport` instead of separate asserts](https://github.com/joomcode/e2ed/commit/0c50fe8f6b7c3adc20c21c66a334a15dd00c054f) ([uid11](https://github.com/uid11))
- [Merge pull request #125 from joomcode/feat/support-steps-in-actions](https://github.com/joomcode/e2ed/commit/72b7b394289085dc955f200621aa19f9e83f1e9e) ([uid11](https://github.com/uid11))

feat: support steps in actions (for groupping steps)
feat: support steps in actions (for grouping steps)

- [PRO-16178 feat: support steps in actions (for groupping steps)](https://github.com/joomcode/e2ed/commit/ba860e4ed6f2e778374d8c0ddd4d758836a98859) ([uid11](https://github.com/uid11))
- [PRO-16178 feat: support steps in actions (for grouping steps)](https://github.com/joomcode/e2ed/commit/ba860e4ed6f2e778374d8c0ddd4d758836a98859) ([uid11](https://github.com/uid11))
- [Merge pull request #124 from joomcode/feat/add-logs-with-children](https://github.com/joomcode/e2ed/commit/e8e72d924150feefcc382dfdcf7c86ca51127657) ([uid11](https://github.com/uid11))

feat: add functionality of `regroupSteps` in HTML reports
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ If the mapping returns `undefined`, the log entry is not skipped, but is printed
For example, if it is equal to three, the test will be run no more than three times.

`navigationTimeout: number`: default timeout for navigation to url
(`navigateToPage`, `navigateToUrl` actions) in milliseconds.
(`navigateToUrl`, `setHeadersAndNavigateToUrl` actions) in milliseconds.

`overriddenConfigFields: PlaywrightTestConfig | null`: if not `null`, then this value will override
fields of internal `Playwright` config.
Expand Down
2 changes: 1 addition & 1 deletion autotests/configurator/regroupSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {setReadonlyProperty} from 'e2ed/utils';
import type {LogEvent, Mutable} from 'e2ed/types';

/**
* Regroup log events (for groupping of `TestRun` steps).
* Regroup log events (for grouping of `TestRun` steps).
* This base client function should not use scope variables (except other base functions).
* @internal
*/
Expand Down
2 changes: 1 addition & 1 deletion autotests/packs/allTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const browserFlags = [
const filterTestsIntoPack: FilterTestsIntoPack = ({options}) => options.meta.testId !== '13';

const userAgent =
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36';
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36';

const msInMinute = 60_000;
const packTimeoutInMinutes = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ type CustomPageParams =
* The e2ed report example page.
*/
export class E2edReportExample extends Page<CustomPageParams> {
/**
* Page navigation timeout.
*/
static override readonly navigationTimeout = 5_000;

/**
* Page header.
*/
Expand All @@ -47,11 +52,6 @@ export class E2edReportExample extends Page<CustomPageParams> {
readonly navigationRetriesButtonSelected: Selector =
this.navigationRetriesButton.filterByLocatorParameter('selected', 'true');

/**
* Page navigation timeout.
*/
override readonly navigationTimeout = 5_000;

/**
* Cookies that we set (additionally) on a page before navigating to it.
*/
Expand Down
5 changes: 5 additions & 0 deletions autotests/pageObjects/pages/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ type CustomPageParams = Partial<RouteParams> | undefined;
* The Main (index) page.
*/
export class Main extends Page<CustomPageParams> {
/**
* Page navigation timeout.
*/
static override readonly navigationTimeout = 12_000;

/**
* Body selector.
*/
Expand Down
15 changes: 6 additions & 9 deletions src/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import type {
* Abstract page with base methods.
*/
export abstract class Page<PageParams = undefined> {
/**
* Default timeout for navigation to url (`navigateToPage`, `navigateToUrl` actions) in milliseconds.
*/
static readonly navigationTimeout: number = 8_000;

/**
* Type of page parameters.
*/
Expand All @@ -40,12 +45,6 @@ export abstract class Page<PageParams = undefined> {
*/
readonly maxIntervalBetweenRequestsInMs: number;

/**
* Default timeout for navigation to url (`navigateToPage`, `navigateToUrl` actions) in milliseconds.
* The default value is taken from the corresponding field of the pack config.
*/
readonly navigationTimeout: number;

/**
* Immutable page parameters.
*/
Expand All @@ -67,12 +66,10 @@ export abstract class Page<PageParams = undefined> {
this.pageParams = pageParams as PageParams;

const {
navigationTimeout,
waitForAllRequestsComplete: {maxIntervalBetweenRequestsInMs},
} = getFullPackConfig();

this.maxIntervalBetweenRequestsInMs = maxIntervalBetweenRequestsInMs;
this.navigationTimeout = navigationTimeout;
}

/**
Expand Down Expand Up @@ -132,7 +129,7 @@ export abstract class Page<PageParams = undefined> {
): Promise<NavigationReturn> {
const navigationReturn = await navigateToUrl(url, {
skipLogs: true,
timeout: this.navigationTimeout,
timeout: (this.constructor as typeof Page).navigationTimeout,
...options,
});
const {statusCode} = navigationReturn;
Expand Down
62 changes: 32 additions & 30 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,35 @@ Modules in the dependency graph should only import the modules above them:
16. `utils/error`
17. `utils/asserts`
18. `utils/object`
19. `utils/uiMode`
20. `utils/runLabel`
21. `utils/clone`
22. `utils/notIncludedInPackTests`
23. `utils/userland`
24. `utils/fn`
25. `utils/environment`
26. `utils/packCompiler`
27. `config`
28. `utils/config`
29. `utils/generalLog`
30. `utils/testFilePaths`
31. `utils/exit`
32. `utils/promise`
33. `utils/resourceUsage`
34. `utils/fs`
35. `utils/getGlobalErrorHandler`
36. `utils/tests`
37. `utils/end`
38. `utils/pack`
39. `useContext`
40. `context`
41. `utils/apiStatistics`
42. `utils/selectors`
43. `selectors`
44. `utils/log`
45. `utils/waitForEvents`
46. `utils/expect`
47. `expect`
48. ...
19. `utils/step`
20. `utils/uiMode`
21. `utils/runLabel`
22. `utils/clone`
23. `utils/notIncludedInPackTests`
24. `utils/userland`
25. `utils/fn`
26. `utils/environment`
27. `utils/packCompiler`
28. `config`
29. `utils/config`
30. `utils/generalLog`
31. `utils/testFilePaths`
32. `utils/exit`
33. `utils/promise`
34. `utils/resourceUsage`
35. `utils/fs`
36. `utils/getGlobalErrorHandler`
37. `utils/tests`
38. `utils/end`
39. `utils/pack`
40. `useContext`
41. `context`
42. `utils/apiStatistics`
43. `utils/selectors`
44. `selectors`
45. `utils/log`
46. `step`
47. `utils/waitForEvents`
48. `utils/expect`
49. `expect`
50. ...
11 changes: 8 additions & 3 deletions src/actions/navigateToUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {LogEventType} from '../constants/internal';
import {ADDITIONAL_STEP_TIMEOUT, LogEventType} from '../constants/internal';
import {step} from '../step';
import {getPlaywrightPage} from '../useContext';

Expand All @@ -11,7 +11,7 @@ export const navigateToUrl = async (
url: Url,
options: NavigateToUrlOptions = {},
): Promise<NavigationReturn> => {
const {skipLogs = false} = options;
const {skipLogs = false, timeout} = options;
let statusCode: StatusCode | undefined;

await step(
Expand All @@ -27,7 +27,12 @@ export const navigateToUrl = async (

return {statusCode};
},
{payload: options, skipLogs, type: LogEventType.InternalAction},
{
payload: options,
skipLogs,
...(timeout !== undefined ? {timeout: timeout + ADDITIONAL_STEP_TIMEOUT} : undefined),
type: LogEventType.InternalAction,
},
);

return {statusCode};
Expand Down
8 changes: 6 additions & 2 deletions src/actions/pages/assertPage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {LogEventStatus, LogEventType} from '../../constants/internal';
import {ADDITIONAL_STEP_TIMEOUT, LogEventStatus, LogEventType} from '../../constants/internal';
import {step} from '../../step';
import {assertValueIsDefined} from '../../utils/asserts';
import {getDocumentUrl} from '../../utils/document';
Expand Down Expand Up @@ -38,7 +38,11 @@ export const assertPage = async <SomePageClass extends AnyPageClassType>(

return {documentUrl, isMatch, logEventStatus, routeParams};
},
{payload: {pageParams}, type: LogEventType.InternalAction},
{
payload: {pageParams},
timeout: PageClass.navigationTimeout + ADDITIONAL_STEP_TIMEOUT,
type: LogEventType.InternalAction,
},
);

assertValueIsDefined(page, 'page is defined', {name: PageClass.name, pageParams});
Expand Down
8 changes: 6 additions & 2 deletions src/actions/pages/navigateToPage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {LogEventType} from '../../constants/internal';
import {ADDITIONAL_STEP_TIMEOUT, LogEventType} from '../../constants/internal';
import {step} from '../../step';
import {addPageToApiStatistics} from '../../utils/apiStatistics';
import {assertValueIsDefined} from '../../utils/asserts';
Expand Down Expand Up @@ -56,7 +56,11 @@ export const navigateToPage = async <SomePageClass extends AnyPageClassType>(

return {documentUrl, isMatch, pageInstanceCreatedInMs, routeParams, url};
},
{payload: {pageParams}, type: LogEventType.InternalAction},
{
payload: {pageParams},
timeout: PageClass.navigationTimeout + ADDITIONAL_STEP_TIMEOUT,
type: LogEventType.InternalAction,
},
);

assertValueIsDefined(page, 'page is defined', {name: PageClass.name, pageParams});
Expand Down
11 changes: 7 additions & 4 deletions src/actions/setHeadersAndNavigateToUrl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AsyncLocalStorage} from 'node:async_hooks';

import {LogEventType} from '../constants/internal';
import {ADDITIONAL_STEP_TIMEOUT, LogEventType} from '../constants/internal';
import {step} from '../step';
import {getPlaywrightPage} from '../useContext';
import {assertValueIsDefined} from '../utils/asserts';
Expand All @@ -26,6 +26,7 @@ export const setHeadersAndNavigateToUrl = async (
navigateToUrlOptions?: NavigateToUrlOptions,
): Promise<NavigationReturn> => {
let navigationReturn: NavigationReturn | undefined;
const timeout = navigateToUrlOptions?.timeout ?? getFullPackConfig().navigationTimeout;

await step(
`Navigate to ${url} and map headers`,
Expand All @@ -42,8 +43,6 @@ export const setHeadersAndNavigateToUrl = async (
return route.fallback();
}

const timeout = navigateToUrlOptions?.timeout ?? getFullPackConfig().navigationTimeout;

const response = await route.fetch({timeout});
const headers = response.headers();

Expand Down Expand Up @@ -76,7 +75,11 @@ export const setHeadersAndNavigateToUrl = async (

return {requestHeaders, responseHeaders};
},
{skipLogs, type: LogEventType.InternalAction},
{
skipLogs,
timeout: timeout + ADDITIONAL_STEP_TIMEOUT,
type: LogEventType.InternalAction,
},
);

assertValueIsDefined(navigationReturn, 'navigationReturn is defined', {
Expand Down
27 changes: 0 additions & 27 deletions src/context/stepsStack.ts

This file was deleted.

Loading
Loading