From 69e81920cec48e2c77b1db8cfefc167174f382a3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 05:18:36 +0000 Subject: [PATCH] Add Playwright automation aids for disclaimer and modals - Added `data-testid` attributes to key modals (Disclaimer, Login, Upload, Video, Profile, Lockdown) to facilitate reliable selection in Playwright tests. - Updated `js/disclaimer.js` and `js/index.js` to respect a new `playwright-bypass-disclaimer` localStorage flag, allowing automated tests to skip the disclaimer modal entirely. --- components/disclaimer.html | 2 ++ components/lockdown-modal.html | 1 + components/login-modal.html | 1 + components/profile-modal.html | 1 + components/upload-modal.html | 1 + components/video-modal.html | 1 + js/disclaimer.js | 5 +++++ js/index.js | 15 ++++++++++++--- 8 files changed, 24 insertions(+), 3 deletions(-) diff --git a/components/disclaimer.html b/components/disclaimer.html index 80910136..dfddca2b 100644 --- a/components/disclaimer.html +++ b/components/disclaimer.html @@ -7,6 +7,7 @@ aria-labelledby="disclaimerModalTitle" aria-describedby="disclaimerModalDescription" data-ds="new" + data-testid="disclaimer-modal" >
@@ -130,6 +131,7 @@ id="acceptDisclaimer" class="modal-primary" type="button" + data-testid="disclaimer-accept-btn" > I Understand diff --git a/components/lockdown-modal.html b/components/lockdown-modal.html index 62ff260d..596e693d 100644 --- a/components/lockdown-modal.html +++ b/components/lockdown-modal.html @@ -6,6 +6,7 @@ aria-labelledby="lockdownModalTitle" aria-describedby="lockdownModalDescription" data-ds="new" + data-testid="lockdown-modal" >
diff --git a/components/login-modal.html b/components/login-modal.html index 1bf08fec..f6543a22 100644 --- a/components/login-modal.html +++ b/components/login-modal.html @@ -6,6 +6,7 @@ aria-labelledby="loginModalTitle" aria-describedby="loginModalDescription" data-ds="new" + data-testid="login-modal" >
diff --git a/components/profile-modal.html b/components/profile-modal.html index d3861443..55304256 100644 --- a/components/profile-modal.html +++ b/components/profile-modal.html @@ -8,6 +8,7 @@ tabindex="-1" data-ds="new" data-mobile-view="menu" + data-testid="profile-modal" >
diff --git a/components/upload-modal.html b/components/upload-modal.html index 3033ac62..fea00e60 100644 --- a/components/upload-modal.html +++ b/components/upload-modal.html @@ -7,6 +7,7 @@ aria-labelledby="uploadModalTitle" aria-describedby="uploadModalDescription" data-ds="new" + data-testid="upload-modal" >
diff --git a/components/video-modal.html b/components/video-modal.html index 0969fd66..47d3ee47 100644 --- a/components/video-modal.html +++ b/components/video-modal.html @@ -6,6 +6,7 @@ aria-modal="true" data-ds="new" hidden + data-testid="video-modal" >
diff --git a/js/disclaimer.js b/js/disclaimer.js index 8fa7df76..cf7f8c1f 100644 --- a/js/disclaimer.js +++ b/js/disclaimer.js @@ -45,6 +45,11 @@ class DisclaimerModal { } show() { + // Check if Playwright automation requested to bypass the disclaimer + if (localStorage.getItem("playwright-bypass-disclaimer") === "true") { + return; + } + // In case the modal hasn't been initialized yet. if (!this.modal) { this.init(); diff --git a/js/index.js b/js/index.js index 55224106..c6a1902e 100644 --- a/js/index.js +++ b/js/index.js @@ -1223,7 +1223,10 @@ async function bootstrapInterface() { if (closeNostrFormBtn) { closeNostrFormBtn.addEventListener("click", () => { closeStaticModal("nostrFormModal"); - if (!localStorage.getItem("hasSeenDisclaimer")) { + if ( + !localStorage.getItem("hasSeenDisclaimer") && + localStorage.getItem("playwright-bypass-disclaimer") !== "true" + ) { const disclaimerModal = document.getElementById("disclaimerModal"); if (disclaimerModal) { openStaticModal(disclaimerModal); @@ -1306,7 +1309,10 @@ function handleQueryParams() { if (closeAppealsBtn) { closeAppealsBtn.addEventListener("click", () => { closeStaticModal("contentAppealsModal"); - if (!localStorage.getItem("hasSeenDisclaimer")) { + if ( + !localStorage.getItem("hasSeenDisclaimer") && + localStorage.getItem("playwright-bypass-disclaimer") !== "true" + ) { const disclaimerModal = document.getElementById("disclaimerModal"); if (disclaimerModal) { openStaticModal(disclaimerModal); @@ -1323,7 +1329,10 @@ function handleQueryParams() { } } else { const hasSeenDisclaimer = localStorage.getItem("hasSeenDisclaimer"); - if (!hasSeenDisclaimer) { + const bypassDisclaimer = + localStorage.getItem("playwright-bypass-disclaimer") === "true"; + + if (!hasSeenDisclaimer && !bypassDisclaimer) { const disclaimerModal = document.getElementById("disclaimerModal"); if (disclaimerModal) { openStaticModal(disclaimerModal);