Skip to content

Commit

Permalink
Merge pull request #41 from lino-levan/chore-move-away-from-data-urls
Browse files Browse the repository at this point in the history
chore(tests): move away from goto data url
  • Loading branch information
lino-levan authored Nov 8, 2023
2 parents a8fb5d0 + 9a82abf commit 9022632
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
3 changes: 2 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "https://esm.sh/[email protected]"
}
},
"lock": false
}
17 changes: 6 additions & 11 deletions tests/dialog_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Deno.test("Accepting basic alert", async () => {
});

// navigate to a page with an alert
await page.goto("data:text/html,<script>alert('hi');</script>");
await page.setContent("<script>alert('hi');</script>");

// Close browser
await browser.close();
Expand All @@ -37,10 +37,7 @@ Deno.test("Accepting basic alert with playwright-like syntax", async () => {
const dialogPromise = page.waitForEvent("dialog");

// navigate to a page with an alert
// note: waitUntil: "none" is required because we're using a data url
await page.goto("data:text/html,<script>alert('hi');</script>", {
waitUntil: "none",
});
page.setContent("<script>alert('hi');</script>");

// handle dialog
const dialog = await dialogPromise;
Expand Down Expand Up @@ -70,8 +67,8 @@ Deno.test("Accepting prompt", async () => {
});

// navigate to a page with an alert
await page.goto(
"data:text/html,<script>prompt('Please type your username');</script>",
await page.setContent(
"<script>prompt('Please type your username');</script>",
);

// Close browser
Expand All @@ -96,7 +93,7 @@ Deno.test("Declining comfirm", async () => {
});

// navigate to a page with an alert
await page.goto("data:text/html,<script>confirm('Is this good?');</script>");
await page.setContent("<script>confirm('Is this good?');</script>");

// Close browser
await browser.close();
Expand All @@ -110,9 +107,7 @@ Deno.test("Input choose file", async () => {
const page = await browser.newPage();

// navigate to a page with an alert
await page.goto('data:text/html,<input type="file"></input>', {
waitUntil: "none",
});
await page.setContent('<input type="file"></input>');

// click input and handle file chooser
const element = await page.$("input");
Expand Down

0 comments on commit 9022632

Please sign in to comment.