Repository navigation
Update bundle source options and e2e tests #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 +1,4 @@ | ||
| # Bump this when upgrading the FFI, then run `node scripts/install.mjs`. | ||
| # (`ffi/<version>` for releases, `prerelease/<sha>` for prereleases). | ||
| # See releases from https://github.com/webview-bundle/webview-bundles. | ||
| prerelease/7e38986 | ||
| prerelease/76b4cbf |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -11,3 +11,6 @@ build | |
| local.properties | ||
|
|
||
| /lib/src/main/jniLibs/**/* | ||
|
|
||
| # misc | ||
| .DS_Store* | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,134 @@ | ||
| import { createAppiumDriver } from "@wvb-playground/testdriver/appium"; | ||
| import { | ||
| methodSel, | ||
| sel, | ||
| testCases, | ||
| type WebviewDriver, | ||
| } from "@wvb-playground/webview-testbed/testing"; | ||
| import { beforeAll, describe, expect, test } from "vitest"; | ||
| import { type Driver, getTestContext } from "./context.js"; | ||
|
|
||
| // Drives the `@wvb-playground/webview-testbed` bundle inside the Android WebView. The | ||
| // testapp ships the builtin `testbed` bundle and points its updater at the live | ||
| // playground remote (https://playground-remote.wvb.dev). | ||
| describe("testbed (android)", () => { | ||
| const BASE_URL = "https://testbed.wvb"; | ||
| const BUNDLE = "testbed"; | ||
| const BUILTIN_VERSION = "0.2.0"; | ||
| const REMOTE_VERSION = "0.3.0"; | ||
|
|
||
| // Loading the app shell (a full navigation) and the network download need more | ||
| // headroom than the driver's default. | ||
| const NAV_TIMEOUT = 30_000; | ||
| const RESULT_TIMEOUT = 90_000; | ||
|
|
||
| let browser: Driver; | ||
| let driver: WebviewDriver; | ||
|
|
||
| beforeAll(() => { | ||
| browser = getTestContext().driver; | ||
| driver = createAppiumDriver(browser, { | ||
| baseURL: BASE_URL, | ||
| defaultTimeoutMs: NAV_TIMEOUT, | ||
| }); | ||
| }); | ||
|
|
||
| async function open(): Promise<void> { | ||
| await driver.goto("/"); | ||
| await driver.waitForVisible(sel.appShell, { timeoutMs: NAV_TIMEOUT }); | ||
| } | ||
|
|
||
| /** | ||
| * Runs one testbed method card on a freshly-loaded page and returns its terminal | ||
| * outcome. Reloading first guarantees the card starts idle (its result element is | ||
| * only rendered once a call settles), so waiting for the result can never observe a | ||
| * stale value left by an earlier run of the same method. | ||
| */ | ||
| async function runMethod( | ||
| id: string, | ||
| params: Record<string, string> = {}, | ||
| ): Promise<{ status: string | null; text: string }> { | ||
| await open(); | ||
|
seokju-na marked this conversation as resolved.
|
||
| for (const [name, value] of Object.entries(params)) { | ||
| await driver.fill(methodSel.param(id, name), value); | ||
| } | ||
| await driver.click(methodSel.run(id)); | ||
| await driver.waitForVisible(methodSel.result(id), { timeoutMs: RESULT_TIMEOUT }); | ||
| const outcome = { | ||
| status: await driver.getAttribute(methodSel.result(id), "data-status"), | ||
| text: await driver.text(methodSel.result(id)), | ||
| }; | ||
| console.log(`[testbed] ${id} -> ${outcome.status}: ${outcome.text}`); | ||
| return outcome; | ||
| } | ||
|
|
||
| function parseJson(text: string): Record<string, unknown> { | ||
| try { | ||
| return JSON.parse(text) as Record<string, unknown>; | ||
| } catch { | ||
| throw new Error(`expected a JSON result, got: ${text}`); | ||
| } | ||
| } | ||
|
|
||
| // The only test that *asserts* the real remote download succeeds. Skipped on CI: | ||
| // this fill + reload + download sequence hangs on the GitHub Actions Android emulator | ||
| // (the network is reachable — the generic suite below downloads over it — but this | ||
| // specific flow stalls there). It passes locally, and the generic suite still | ||
| // exercises the download (as ok|error) on CI. | ||
| test.skipIf(!!process.env.CI)( | ||
| "downloads + installs the real remote update (builtin 0.2.0 -> remote 0.3.0)", | ||
| async () => { | ||
| await open(); | ||
| expect(await driver.text(sel.platformType)).toBe("android"); | ||
|
|
||
| const before = parseJson( | ||
| (await runMethod("source.loadVersion", { bundleName: BUNDLE })).text, | ||
| ); | ||
| expect(before).toEqual({ type: "builtin", version: BUILTIN_VERSION }); | ||
|
|
||
| const update = await runMethod("updater.getUpdate", { bundleName: BUNDLE }); | ||
| expect(update.status).toBe("ok"); | ||
| const info = parseJson(update.text); | ||
| expect(info.name).toBe(BUNDLE); | ||
| expect(info.version).toBe(REMOTE_VERSION); | ||
| expect(info.isAvailable).toBe(true); | ||
| expect(info.localVersion).toBe(BUILTIN_VERSION); | ||
|
|
||
| const download = await runMethod("updater.download", { bundleName: BUNDLE }); | ||
| expect(download.status).toBe("ok"); | ||
| expect(parseJson(download.text).version).toBe(REMOTE_VERSION); | ||
|
|
||
| const install = await runMethod("updater.install", { | ||
| bundleName: BUNDLE, | ||
| version: REMOTE_VERSION, | ||
| }); | ||
| expect(install.status).toBe("ok"); | ||
|
|
||
| const after = parseJson( | ||
| (await runMethod("source.loadVersion", { bundleName: BUNDLE })).text, | ||
| ); | ||
| expect(after).toEqual({ type: "remote", version: REMOTE_VERSION }); | ||
|
|
||
| // Drop the cached descriptor so the next request loads the freshly-installed | ||
| // version, and cache-bust so the WebView can't serve stale HTML. | ||
| await runMethod("source.unloadDescriptor", { bundleName: BUNDLE }); | ||
| await driver.goto(`/?updated=${Date.now()}`); | ||
| await driver.waitForVisible(sel.appShell, { timeoutMs: NAV_TIMEOUT }); | ||
| expect(await driver.text(".app__version")).toContain(REMOTE_VERSION); | ||
| }, | ||
| 240_000, | ||
| ); | ||
|
|
||
| // The platform-agnostic suite the testbed package ships (each `@wvb/bridge` method | ||
| // asserted to render an ok|error outcome). The "raw invoke" case is the only one that | ||
| // fills a text input, which hangs on the CI Android emulator; skip it there (its | ||
| // coverage overlaps source.listBundles). Runs after the strict update test so it | ||
| // can't perturb that test's clean starting state. | ||
| for (const testCase of testCases) { | ||
| const register = | ||
| process.env.CI && testCase.name.startsWith("raw invoke") ? test.skip : test; | ||
| register(testCase.name, async () => { | ||
| await testCase.run(driver); | ||
| }); | ||
| } | ||
| }); | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.