-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
4,034 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,39 @@ | ||
import { test, expect } from "@playwright/experimental-ct-react"; | ||
import { test, expect } from "@playwright/test"; | ||
import { readdirSync } from "node:fs"; | ||
import path from "node:path"; | ||
import { bundle } from "../src/plugin/bundler"; | ||
import { WEB_ROOT_ID } from "../src/constants"; | ||
|
||
test.use({ viewport: { width: 500, height: 1000 } }); | ||
test.describe("smoke webview code", () => { | ||
const fixturePath = path.join(process.cwd(), "fixtures"); | ||
readdirSync(fixturePath).forEach((filename) => { | ||
if (filename.endsWith(".jsx") || filename.endsWith(".tsx")) { | ||
test(filename, async ({ page }) => { | ||
await page.goto("localhost:3000"); | ||
|
||
test("should work", async ({ mount }) => { | ||
const component = await mount(<div>Learn React</div>); | ||
await expect(component).toContainText("Learn React"); | ||
const code = await bundle(path.join(fixturePath, filename)); | ||
|
||
const rootHandle = await page.waitForFunction( | ||
(id) => document.getElementById(id)!, | ||
WEB_ROOT_ID | ||
); | ||
|
||
await page.evaluate((code) => { | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.onload = eval(code); | ||
|
||
document.head.appendChild(script); | ||
}, code); | ||
|
||
await page.waitForFunction((e) => e.innerHTML, rootHandle); | ||
await expect( | ||
await rootHandle.evaluate((e) => e.innerHTML) | ||
).toMatchSnapshot(); | ||
await expect( | ||
await page.evaluate(() => document.head.innerHTML) | ||
).toMatchSnapshot(); | ||
}); | ||
} | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
...index.spec.tsx-snapshots/smoke-webview-code-app-export-commonjs-jsx-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div style="background: red; width: 100vw; height: 100vh;">hoge</div> |
5 changes: 5 additions & 0 deletions
5
...index.spec.tsx-snapshots/smoke-webview-code-app-export-commonjs-jsx-2-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Testing Page</title> | ||
<script type="text/javascript"></script> |
1 change: 1 addition & 0 deletions
1
e2e/index.spec.tsx-snapshots/smoke-webview-code-app-export-default-jsx-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div style="background: red; width: 100vw; height: 100vh;">hoge</div> |
Oops, something went wrong.