Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Don’t flood Playwright traces with `route.continue()`
Thomas Scholtes committed 2 years ago
commit 684700a24d8f799797c270ed84169fde07b319ab
parent f80b193bbde1b535bbdfaf8ca61845aa4fdd600c
2 files changed +27 -29
modified tests/e2e/project.spec.ts
@@ -438,14 +438,11 @@ test.describe("browser error handling", () => {
});

test("external markdown link", async ({ page }) => {
-
  await page.route("http://github.github.com/**", route => {
+
  await page.route("https://example.com/**", route => {
    return route.fulfill({ body: "hello", contentType: "text/plain" });
  });
-
  await page.goto(`${markdownUrl}/tree/main/cheatsheet.md`);
-
  await page
-
    .getByRole("link", { name: "Github-flavored Markdown info page" })
-
    .click();
-
  await expect(page).toHaveURL(
-
    "http://github.github.com/github-flavored-markdown/",
-
  );
+
  await page.goto(`${markdownUrl}/tree/main/footnotes.md`);
+
  await page.getByRole("link", { name: "https://example.com" }).click();
+
  await page.pause();
+
  await expect(page).toHaveURL("https://example.com");
});
modified tests/support/fixtures.ts
@@ -112,33 +112,34 @@ export const test = base.extend<{
      }

      const playwrightLabel = logLabel.make("playwright");
-
      await page.route("**/*", route => {
-
        if (
-
          route.request().url().startsWith("http://127.0.0.1") ||
-
          route.request().url().startsWith("http://localhost") ||
-
          route.request().url().startsWith("http://0.0.0.0")
-
        ) {
-
          return route.continue();
-
        } else if (
-
          route
-
            .request()
-
            .url()
-
            .startsWith("https://www.gravatar.com/avatar/") ||
-
          route.request().url().endsWith(".png")
-
        ) {
-
          return route.fulfill({
-
            status: 200,
-
            path: "./public/radicle.svg",
-
          });
-
        } else {
+

+
      function isLocalhost(url: URL) {
+
        return url.hostname === "localhost" || url.hostname === "127.0.0.1";
+
      }
+

+
      await page.route(
+
        url => !isLocalhost(url),
+
        route => {
          log(
            `Aborted remote request: ${route.request().url()}`,
            playwrightLabel,
            outputLog,
          );
          return route.abort();
-
        }
-
      });
+
        },
+
      );
+

+
      await page.route(
+
        url =>
+
          url.href.startsWith("https://www.gravatar.com/avatar/") ||
+
          (url.href.endsWith(".png") && !isLocalhost(url)),
+
        route => {
+
          return route.fulfill({
+
            status: 200,
+
            path: "./public/radicle.svg",
+
          });
+
        },
+
      );

      await use();
    },