Skip to content

Commit 3a8b5c6

Browse files
committed
fix: e2e issue
1 parent 00759d5 commit 3a8b5c6

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

.github/workflows/reusable-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ jobs:
283283
run: npm run build
284284

285285
- name: Run e2e tests
286-
run: npm run task:run-e2e
286+
run: npm run e2e
287287

288288
# Run tests on single specified Node.js version
289289
run-jest-single:

test/engines/playwright.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class PlaywrightEngine extends TestEngineBase {
2525

2626
test(`(es) ${name}`, async ({ page }) => {
2727
await page.goto('/modern.html', { waitUntil: 'load' });
28-
await new Promise((resolve) => setTimeout(resolve, 100)); // wait for the page to load completely
2928
await this.executeEvaluation({ page, assert, serializedEvaluateParams });
3029
});
3130

@@ -49,7 +48,40 @@ export class PlaywrightEngine extends TestEngineBase {
4948
}) {
5049
const { page, assert, serializedEvaluateParams } = options;
5150
const resultStr = await page.evaluate((contextStr) => {
52-
throw new Error(document.documentElement.outerHTML);
51+
const EnumPlus = window.EnumPlus;
52+
const WeekConfig = window.WeekConfig;
53+
const WeekData = window.WeekData;
54+
const SerializeJavascript = window.SerializeJavascript;
55+
56+
// Deserialize request
57+
const runtimeContext = {
58+
EnumPlus,
59+
WeekConfig,
60+
WeekData,
61+
SerializeJavascript,
62+
};
63+
// console.log('window', runtimeContext);
64+
const { stringify: serialize, parse: deserialize } = SerializeJavascript;
65+
const args = deserialize(contextStr) as { evaluateFn: (context: RuntimeContext) => Data };
66+
const { evaluateFn, ...rest } = args;
67+
68+
// Set the initial state to en-US before executing evaluation
69+
WeekConfig.setLang('en-US', EnumPlus.Enum, WeekConfig.getLocales, EnumPlus.defaultLocalize);
70+
71+
// Execute the evaluation
72+
const evaluateResult = evaluateFn({ ...runtimeContext, ...rest });
73+
// console.log('evaluateResult');
74+
// console.log(evaluateResult);
75+
76+
// Serialize the evaluation result and pass it to assertion method
77+
const serializedStr = serialize({
78+
EnumLocalize: EnumPlus.Enum.localize,
79+
lang: WeekConfig.lang,
80+
...evaluateResult,
81+
});
82+
// console.log('serialize result');
83+
// console.log(serializeResult);
84+
return serializedStr;
5385
}, serializedEvaluateParams);
5486

5587
const initialState = parse(resultStr, { /* debug: true, */ prettyPrint: false });

0 commit comments

Comments
 (0)