mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
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.
This commit is contained in:
1 parent
85cf476754
commit
69e81920ce
8 files changed
+24
-3
No files matched your search
@@ -7,6 +7,7 @@
|
||||
aria-labelledby="disclaimerModalTitle"
|
||||
aria-describedby="disclaimerModalDescription"
|
||||
data-ds="new"
|
||||
data-testid="disclaimer-modal"
|
||||
>
|
||||
<div class="bv-modal-backdrop" data-dismiss></div>
|
||||
|
||||
@@ -130,6 +131,7 @@
|
||||
id="acceptDisclaimer"
|
||||
class="modal-primary"
|
||||
type="button"
|
||||
data-testid="disclaimer-accept-btn"
|
||||
>
|
||||
I Understand
|
||||
</button>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
aria-labelledby="lockdownModalTitle"
|
||||
aria-describedby="lockdownModalDescription"
|
||||
data-ds="new"
|
||||
data-testid="lockdown-modal"
|
||||
>
|
||||
<div class="bv-modal-backdrop"></div>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
aria-labelledby="loginModalTitle"
|
||||
aria-describedby="loginModalDescription"
|
||||
data-ds="new"
|
||||
data-testid="login-modal"
|
||||
>
|
||||
<div class="bv-modal-backdrop" data-dismiss></div>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
tabindex="-1"
|
||||
data-ds="new"
|
||||
data-mobile-view="menu"
|
||||
data-testid="profile-modal"
|
||||
>
|
||||
<div class="bv-modal-backdrop"></div>
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
aria-labelledby="uploadModalTitle"
|
||||
aria-describedby="uploadModalDescription"
|
||||
data-ds="new"
|
||||
data-testid="upload-modal"
|
||||
>
|
||||
<div class="bv-modal-backdrop" data-dismiss></div>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
aria-modal="true"
|
||||
data-ds="new"
|
||||
hidden
|
||||
data-testid="video-modal"
|
||||
>
|
||||
<div class="bv-modal-backdrop" data-dismiss></div>
|
||||
<div class="bv-modal__panel" tabindex="-1">
|
||||
|
||||
@@ -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();
|
||||
|
||||
+12
-3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user