From d2144787850fb32507449a19620f974b267a24c8 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Tue, 28 May 2024 08:41:27 -0500 Subject: [PATCH] ignore playwright --- integration/e2e_tests/all-scenarios.spec.js | 2 ++ lib/dotcom_web/controllers/tracker_controller.ex | 14 ++++++++++---- playwright.config.js | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/integration/e2e_tests/all-scenarios.spec.js b/integration/e2e_tests/all-scenarios.spec.js index d2052e0ab9..c337fbb3be 100644 --- a/integration/e2e_tests/all-scenarios.spec.js +++ b/integration/e2e_tests/all-scenarios.spec.js @@ -14,6 +14,8 @@ const baseURL = process.env.HOST files.forEach((file) => { test.describe("All scenarios", {tag: "@scenarios"}, (_) => { + test.use({userAgent: "Playwright"}); + const filePath = path.join(filesPath, file); const { scenario } = require(filePath); diff --git a/lib/dotcom_web/controllers/tracker_controller.ex b/lib/dotcom_web/controllers/tracker_controller.ex index b80b9b3aab..72672126c8 100644 --- a/lib/dotcom_web/controllers/tracker_controller.ex +++ b/lib/dotcom_web/controllers/tracker_controller.ex @@ -9,6 +9,16 @@ defmodule DotcomWeb.TrackerController do require Logger def tracker(conn, _params) do + if Plug.Conn.get_req_header(conn, "user-agent") != ["Playwright"] do + maybe_log(conn) + end + + conn + |> send_resp(200, "ok") + |> halt + end + + defp maybe_log(conn) do case Plug.Conn.read_body(conn) do {:ok, _body, conn} -> %{"path" => path, "session_id" => session_id} = conn.body_params @@ -18,9 +28,5 @@ defmodule DotcomWeb.TrackerController do _ -> nil end - - conn - |> send_resp(200, "ok") - |> halt end end diff --git a/playwright.config.js b/playwright.config.js index 907fa8e4a8..6738c3b223 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -18,7 +18,6 @@ module.exports = defineConfig({ baseURL: process.env.HOST ? `https://${process.env.HOST}` : 'http://localhost:4001', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', - userAgent: 'Playwright', }, /* set the expect timeout to 30s */ expect: { timeout: 30000 },