Skip to content

Commit a8bc839

Browse files
committed
PRO-16178 fix: use lexical steps stack via AsyncLocalStorage
1 parent 001c5ce commit a8bc839

22 files changed

Lines changed: 224 additions & 166 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ If the mapping returns `undefined`, the log entry is not skipped, but is printed
333333
For example, if it is equal to three, the test will be run no more than three times.
334334

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

338338
`overriddenConfigFields: PlaywrightTestConfig | null`: if not `null`, then this value will override
339339
fields of internal `Playwright` config.

autotests/pageObjects/pages/E2edReportExample/E2edReportExample.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ type CustomPageParams =
2121
* The e2ed report example page.
2222
*/
2323
export class E2edReportExample extends Page<CustomPageParams> {
24+
/**
25+
* Page navigation timeout.
26+
*/
27+
static override readonly navigationTimeout = 5_000;
28+
2429
/**
2530
* Page header.
2631
*/
@@ -47,11 +52,6 @@ export class E2edReportExample extends Page<CustomPageParams> {
4752
readonly navigationRetriesButtonSelected: Selector =
4853
this.navigationRetriesButton.filterByLocatorParameter('selected', 'true');
4954

50-
/**
51-
* Page navigation timeout.
52-
*/
53-
override readonly navigationTimeout = 5_000;
54-
5555
/**
5656
* Cookies that we set (additionally) on a page before navigating to it.
5757
*/

autotests/pageObjects/pages/Main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ type CustomPageParams = Partial<RouteParams> | undefined;
1515
* The Main (index) page.
1616
*/
1717
export class Main extends Page<CustomPageParams> {
18+
/**
19+
* Page navigation timeout.
20+
*/
21+
static override readonly navigationTimeout = 12_000;
22+
1823
/**
1924
* Body selector.
2025
*/
File renamed without changes.
File renamed without changes.

src/Page.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import type {
2424
* Abstract page with base methods.
2525
*/
2626
export abstract class Page<PageParams = undefined> {
27+
/**
28+
* Default timeout for navigation to url (`navigateToPage`, `navigateToUrl` actions) in milliseconds.
29+
*/
30+
static readonly navigationTimeout: number = 8_000;
31+
2732
/**
2833
* Type of page parameters.
2934
*/
@@ -40,12 +45,6 @@ export abstract class Page<PageParams = undefined> {
4045
*/
4146
readonly maxIntervalBetweenRequestsInMs: number;
4247

43-
/**
44-
* Default timeout for navigation to url (`navigateToPage`, `navigateToUrl` actions) in milliseconds.
45-
* The default value is taken from the corresponding field of the pack config.
46-
*/
47-
readonly navigationTimeout: number;
48-
4948
/**
5049
* Immutable page parameters.
5150
*/
@@ -67,12 +66,10 @@ export abstract class Page<PageParams = undefined> {
6766
this.pageParams = pageParams as PageParams;
6867

6968
const {
70-
navigationTimeout,
7169
waitForAllRequestsComplete: {maxIntervalBetweenRequestsInMs},
7270
} = getFullPackConfig();
7371

7472
this.maxIntervalBetweenRequestsInMs = maxIntervalBetweenRequestsInMs;
75-
this.navigationTimeout = navigationTimeout;
7673
}
7774

7875
/**
@@ -132,7 +129,7 @@ export abstract class Page<PageParams = undefined> {
132129
): Promise<NavigationReturn> {
133130
const navigationReturn = await navigateToUrl(url, {
134131
skipLogs: true,
135-
timeout: this.navigationTimeout,
132+
timeout: (this.constructor as typeof Page).navigationTimeout,
136133
...options,
137134
});
138135
const {statusCode} = navigationReturn;

src/README.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,35 @@ Modules in the dependency graph should only import the modules above them:
2323
16. `utils/error`
2424
17. `utils/asserts`
2525
18. `utils/object`
26-
19. `utils/uiMode`
27-
20. `utils/runLabel`
28-
21. `utils/clone`
29-
22. `utils/notIncludedInPackTests`
30-
23. `utils/userland`
31-
24. `utils/fn`
32-
25. `utils/environment`
33-
26. `utils/packCompiler`
34-
27. `config`
35-
28. `utils/config`
36-
29. `utils/generalLog`
37-
30. `utils/testFilePaths`
38-
31. `utils/exit`
39-
32. `utils/promise`
40-
33. `utils/resourceUsage`
41-
34. `utils/fs`
42-
35. `utils/getGlobalErrorHandler`
43-
36. `utils/tests`
44-
37. `utils/end`
45-
38. `utils/pack`
46-
39. `useContext`
47-
40. `context`
48-
41. `utils/apiStatistics`
49-
42. `utils/selectors`
50-
43. `selectors`
51-
44. `utils/log`
52-
45. `utils/waitForEvents`
53-
46. `utils/expect`
54-
47. `expect`
55-
48. ...
26+
19. `utils/step`
27+
20. `utils/uiMode`
28+
21. `utils/runLabel`
29+
22. `utils/clone`
30+
23. `utils/notIncludedInPackTests`
31+
24. `utils/userland`
32+
25. `utils/fn`
33+
26. `utils/environment`
34+
27. `utils/packCompiler`
35+
28. `config`
36+
29. `utils/config`
37+
30. `utils/generalLog`
38+
31. `utils/testFilePaths`
39+
32. `utils/exit`
40+
33. `utils/promise`
41+
34. `utils/resourceUsage`
42+
35. `utils/fs`
43+
36. `utils/getGlobalErrorHandler`
44+
37. `utils/tests`
45+
38. `utils/end`
46+
39. `utils/pack`
47+
40. `useContext`
48+
41. `context`
49+
42. `utils/apiStatistics`
50+
43. `utils/selectors`
51+
44. `selectors`
52+
45. `utils/log`
53+
46. `step`
54+
47. `utils/waitForEvents`
55+
48. `utils/expect`
56+
49. `expect`
57+
50. ...

src/actions/pages/assertPage.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {LogEventStatus, LogEventType} from '../../constants/internal';
1+
import {ADDITIONAL_STEP_TIMEOUT, LogEventStatus, LogEventType} from '../../constants/internal';
22
import {step} from '../../step';
33
import {assertValueIsDefined} from '../../utils/asserts';
44
import {getDocumentUrl} from '../../utils/document';
@@ -38,7 +38,11 @@ export const assertPage = async <SomePageClass extends AnyPageClassType>(
3838

3939
return {documentUrl, isMatch, logEventStatus, routeParams};
4040
},
41-
{payload: {pageParams}, type: LogEventType.InternalAction},
41+
{
42+
payload: {pageParams},
43+
timeout: PageClass.navigationTimeout + ADDITIONAL_STEP_TIMEOUT,
44+
type: LogEventType.InternalAction,
45+
},
4246
);
4347

4448
assertValueIsDefined(page, 'page is defined', {name: PageClass.name, pageParams});

src/actions/pages/navigateToPage.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {LogEventType} from '../../constants/internal';
1+
import {ADDITIONAL_STEP_TIMEOUT, LogEventType} from '../../constants/internal';
22
import {step} from '../../step';
33
import {addPageToApiStatistics} from '../../utils/apiStatistics';
44
import {assertValueIsDefined} from '../../utils/asserts';
@@ -56,7 +56,11 @@ export const navigateToPage = async <SomePageClass extends AnyPageClassType>(
5656

5757
return {documentUrl, isMatch, pageInstanceCreatedInMs, routeParams, url};
5858
},
59-
{payload: {pageParams}, type: LogEventType.InternalAction},
59+
{
60+
payload: {pageParams},
61+
timeout: PageClass.navigationTimeout + ADDITIONAL_STEP_TIMEOUT,
62+
type: LogEventType.InternalAction,
63+
},
6064
);
6165

6266
assertValueIsDefined(page, 'page is defined', {name: PageClass.name, pageParams});

src/context/stepsStack.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)