-
Notifications
You must be signed in to change notification settings - Fork 9
integration: create charm using ci, view in jumble #518
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d516d1d
load a charm using cli, then view and use it in jumble
anotherjesse 3f4751b
ci is slow?
anotherjesse fa4d2ec
close testing browser after integration tests
anotherjesse 06a46c4
use unique space for each integration run
anotherjesse 4a9b10d
verify the updates propagate using CLI.
anotherjesse bcbdb3d
chore: smoke test follow ups
jsantell 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
|---|---|---|
| @@ -1,28 +1,82 @@ | ||
| import { launch } from "@astral/astral"; | ||
| import { Browser, launch } from "@astral/astral"; | ||
| import { assert } from "@std/assert"; | ||
| import { login } from "./utils.ts"; | ||
| import { | ||
| addCharm, | ||
| inspectCharm, | ||
| login, | ||
| sleep, | ||
| waitForSelectorWithText, | ||
| } from "./utils.ts"; | ||
|
|
||
| const FRONTEND_URL = "http://localhost:5173/"; | ||
| const TOOLSHED_API_URL = Deno.env.get("TOOLSHED_API_URL") ?? | ||
| "http://localhost:8000/"; | ||
| const FRONTEND_URL = Deno.env.get("FRONTEND_URL") ?? "http://localhost:5173/"; | ||
|
|
||
| async function main(browser: Browser) { | ||
| console.log(`TOOLSHED_API_URL=${TOOLSHED_API_URL}`); | ||
| console.log(`FRONTEND_URL=${FRONTEND_URL}`); | ||
|
|
||
| const { charmId, space } = await addCharm(TOOLSHED_API_URL); | ||
| console.log(`Charm added`, { charmId, space }); | ||
|
|
||
| async function main() { | ||
| const browser = await launch(); | ||
| console.log(`Waiting to open website at ${FRONTEND_URL}`); | ||
| const page = await browser.newPage(FRONTEND_URL); | ||
| console.log(`Opened website at ${FRONTEND_URL}`); | ||
|
|
||
| console.log("Logging in"); | ||
| await login(page); | ||
|
|
||
| console.log("Checking if logged in"); | ||
| const anchor = await page.waitForSelector("nav a"); | ||
| assert( | ||
| (await anchor.innerText()) === "common-knowledge", | ||
| "Logged in and Common Knowledge title renders", | ||
| ); | ||
| await browser.close(); | ||
|
|
||
| await page.goto(`${FRONTEND_URL}${space}/${charmId}`); | ||
| console.log(`Waiting for charm to render`); | ||
|
|
||
| await waitForSelectorWithText( | ||
| page, | ||
| "a[aria-current='charm-title']", | ||
| "Simple Value: 1", | ||
| ); | ||
| console.log("Charm rendered."); | ||
|
|
||
| console.log("Clicking button"); | ||
| // Sometimes clicking this button throws: | ||
| // https://jsr.io/@astral/astral/0.5.2/src/element_handle.ts#L192 | ||
| // As if the reference was invalidated by a spurious re-render between | ||
| // getting an element handle, and clicking it. | ||
| await sleep(1000); | ||
| const button = await page.waitForSelector( | ||
| "div[aria-label='charm-content'] button", | ||
| ); | ||
| await button.click(); | ||
|
|
||
| console.log("Checking if title changed"); | ||
| await waitForSelectorWithText( | ||
| page, | ||
| "a[aria-current='charm-title']", | ||
| "Simple Value: 2", | ||
| ); | ||
| console.log("Title changed"); | ||
|
|
||
| console.log("Inspecting charm to verify updates propagated from browser."); | ||
| const charm = await inspectCharm(TOOLSHED_API_URL, space, charmId); | ||
| console.log("Charm:", charm); | ||
| assert(charm.includes("Simple Value: 2"), "Charm updates propagated."); | ||
| } | ||
|
|
||
| let browser = null; | ||
| try { | ||
| await main(); | ||
| browser = await launch(); | ||
| await main(browser); | ||
| await browser.close(); | ||
| } catch (e) { | ||
| if (browser) { | ||
| await browser.close(); | ||
| } | ||
| console.error(e); | ||
| Deno.exit(1); | ||
| } |
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
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.