Skip to content

Commit 97019a9

Browse files
committed
Update e2e
1 parent ebbcfa6 commit 97019a9

File tree

51 files changed

+422
-938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+422
-938
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
lib
22
node_modules
3+
e2e/temp
34
/test-results/
45
/playwright-report/
56
/blob-report/

e2e/index.html

-11
This file was deleted.

e2e/index.spec.tsx

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
import { test, expect } from "@playwright/test";
22
import { readdirSync } from "node:fs";
3+
import { writeFile } from "node:fs/promises";
34
import path from "node:path";
45
import { bundle } from "../src/plugin/bundler";
6+
import { wrapWithWebViewHTML } from "../src/plugin/html";
57
import { WEB_ROOT_ID } from "../src/constants";
68

79
test.beforeEach(async ({}, testInfo) => {
810
// https://github.com/microsoft/playwright/issues/7575#issuecomment-1168800666
911
testInfo.snapshotSuffix = "";
1012
});
1113

12-
test.describe("smoke webview code", () => {
14+
test.describe("smoke webview", () => {
1315
const fixturePath = path.join(process.cwd(), "fixtures");
16+
const tempPath = path.join(process.cwd(), "e2e/temp");
17+
1418
readdirSync(fixturePath).forEach((filename) => {
1519
if (filename.endsWith(".jsx") || filename.endsWith(".tsx")) {
1620
test(filename, async ({ page }) => {
17-
await page.goto("localhost:3000");
21+
const code = await bundle(
22+
path.join(fixturePath, filename),
23+
wrapWithWebViewHTML
24+
);
25+
const html = eval(code);
26+
27+
await writeFile(path.join(tempPath, filename) + ".html", html, "utf-8");
1828

19-
const code = await bundle(path.join(fixturePath, filename));
29+
await page.goto(`localhost:3000/temp/${filename}.html`);
2030

2131
const rootHandle = await page.waitForFunction(
2232
(id) => document.getElementById(id)!,
2333
WEB_ROOT_ID
2434
);
2535

26-
await page.evaluate((code) => {
27-
const rawCode = eval(code);
28-
eval(rawCode);
29-
}, code);
30-
31-
await page.waitForFunction((e) => e.innerHTML, rootHandle);
32-
await expect(
33-
await rootHandle.evaluate((e) => e.innerHTML)
34-
).toMatchSnapshot();
35-
await expect(
36+
expect(await rootHandle.evaluate((e) => e.innerHTML)).toMatchSnapshot();
37+
expect(
3638
await page.evaluate(() => document.head.innerHTML)
3739
).toMatchSnapshot();
40+
expect(html).toMatchSnapshot();
3841
});
3942
}
4043
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-commonjs-jsx-3-chromium.txt

+29
Large diffs are not rendered by default.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-tsx-2-chromium.txt e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-jsx-2-chromium.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

2-
<meta charset="UTF-8">
3-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4-
<title>Testing Page</title>
5-
<style type="text/css">html {
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
4+
<style type="text/css">html {
65
background-color: #e2e2e2;
76
margin: 0;
87
padding: 0;

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-jsx-3-chromium.txt

+31
Large diffs are not rendered by default.

e2e/index.spec.tsx-snapshots/smoke-webview-code-issue45-jsx-2-chromium.txt e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-react-jsx-2-chromium.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

2-
<meta charset="UTF-8">
3-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4-
<title>Testing Page</title>
5-
<style type="text/css">html {
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
4+
<style type="text/css">html {
65
background-color: #e2e2e2;
76
margin: 0;
87
padding: 0;

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-react-jsx-3-chromium.txt

+31
Large diffs are not rendered by default.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-jsx-2-chromium.txt e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-tsx-2-chromium.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

2-
<meta charset="UTF-8">
3-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4-
<title>Testing Page</title>
5-
<style type="text/css">html {
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
4+
<style type="text/css">html {
65
background-color: #e2e2e2;
76
margin: 0;
87
padding: 0;

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-tsx-3-chromium.txt

+31
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-with-html-jsx-3-chromium.txt

+30
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-with-images-jsx-3-chromium.txt

+35
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-with-json-jsx-3-chromium.txt

+30
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-with-md-jsx-3-chromium.txt

+31
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-default-with-txt-jsx-3-chromium.txt

+31
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-named-jsx-3-chromium.txt

+29
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

e2e/index.spec.tsx-snapshots/smoke-webview-app-export-non-jsx-3-chromium.txt

+29
Large diffs are not rendered by default.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-commonjs-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-with-html-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-with-images-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-with-json-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-with-md-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-with-txt-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-named-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-non-jsx-2-chromium.txt

-5
This file was deleted.

e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-react-jsx-2-chromium.txt e2e/index.spec.tsx-snapshots/smoke-webview-issue45-jsx-2-chromium.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

2-
<meta charset="UTF-8">
3-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4-
<title>Testing Page</title>
5-
<style type="text/css">html {
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
4+
<style type="text/css">html {
65
background-color: #e2e2e2;
76
margin: 0;
87
padding: 0;

e2e/index.spec.tsx-snapshots/smoke-webview-issue45-jsx-3-chromium.txt

+31
Large diffs are not rendered by default.

e2e/temp/.keep

Whitespace-only changes.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"scripts": {
3636
"build": "rollup -c",
3737
"test": "vitest --run",
38-
"pretest": "npm run build",
3938
"tsc": "tsc -p . --noEmit",
39+
"pree2e": "npm run build",
4040
"e2e": "npx playwright test",
4141
"typedoc": "typedoc",
4242
"prepublishOnly": "npm run typedoc && rimraf lib && npm run build"

src/plugin/__snapshots__/bundler.spec.ts.snap

-833
This file was deleted.

src/plugin/bundler.spec.ts

-24
This file was deleted.

0 commit comments

Comments
 (0)