From 9d3f78081b4dad3737eb76f12a58b98a59b71f27 Mon Sep 17 00:00:00 2001 From: Bill John Tran Date: Thu, 21 Mar 2024 06:55:07 -0700 Subject: [PATCH 1/2] add fix for redirect (#1997) (#2030) * add fix for redirect * add regwall fix more mobile * update PB preview query param * remove requireConfigFile config --- .../identity-block/components/login/index.jsx | 18 ++++++++++-------- .../components/login/index.test.jsx | 8 ++++++-- blocks/subscriptions-block/_index.scss | 6 ++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/blocks/identity-block/components/login/index.jsx b/blocks/identity-block/components/login/index.jsx index 1435763ee4..88a7f7fb01 100644 --- a/blocks/identity-block/components/login/index.jsx +++ b/blocks/identity-block/components/login/index.jsx @@ -22,13 +22,12 @@ const useLogin = ({ if (window?.location?.search) { const searchParams = new URLSearchParams(window.location.search.substring(1)); - //redirectURL could have additional params + // redirectURL could have additional params const params = ["paymentMethodID"]; - const aditionalParams = params.map((p) => { - const paramExist = searchParams.has(p) - if(paramExist){ - return {[p]:searchParams.get(p)} - } + const aditionalParams = params.filter((p) => { + const paramExist = searchParams.has(p); + + return paramExist; }) const fullURL = searchParams.get("redirect") ? appendURLParams(searchParams.get("redirect"), aditionalParams.filter(item => item !== undefined)) : null; @@ -37,7 +36,9 @@ const useLogin = ({ } if (redirectToPreviousPage && document?.referrer) { - setRedirectToURL(document.referrer); + const redirectUrl = new URL(document.referrer); + + setRedirectToURL(`${redirectUrl.pathname}${redirectUrl.search}`); } }, [redirectQueryParam, redirectToPreviousPage]); @@ -56,6 +57,7 @@ const useLogin = ({ const checkLoggedInStatus = async () => { const isLoggedIn = await Identity.isLoggedIn(); const validatedLoggedInPageLoc = validateURL(loggedInPageLocation); + if (isLoggedIn) { if (isOIDC) { loginByOIDC(); @@ -67,7 +69,7 @@ const useLogin = ({ if (Identity && !isAdmin) { checkLoggedInStatus(); } - }, [Identity, redirectQueryParam, loggedInPageLocation, isAdmin]); + }, [Identity, redirectQueryParam, loggedInPageLocation, isAdmin, loginByOIDC, isOIDC]); return { loginRedirect: redirectQueryParam || redirectToURL, diff --git a/blocks/identity-block/components/login/index.test.jsx b/blocks/identity-block/components/login/index.test.jsx index 55e5d5066d..f977f7076f 100644 --- a/blocks/identity-block/components/login/index.test.jsx +++ b/blocks/identity-block/components/login/index.test.jsx @@ -35,6 +35,10 @@ describe("useLogin()", () => { beforeEach(() => { Object.defineProperty(window, "location", { writable: true, + value: { + href: 'http://localhost', + search: '' + } }); useIdentity.mockImplementation(() => ({ isInitialized: true, @@ -68,14 +72,14 @@ describe("useLogin()", () => { }); it("uses document referrer", async () => { - const referrerURL = "http://referrer.com"; + const referrerURL = "http://referrer.com/article/1234"; Object.defineProperty(document, "referrer", { value: referrerURL, configurable: true, }); await render(); fireEvent.click(screen.getByRole("button")); - expect(window.location).toBe(referrerURL); + expect(window.location).toBe("/article/1234"); delete document.referrer; }); diff --git a/blocks/subscriptions-block/_index.scss b/blocks/subscriptions-block/_index.scss index 9110d00343..f58a46ee1c 100644 --- a/blocks/subscriptions-block/_index.scss +++ b/blocks/subscriptions-block/_index.scss @@ -281,3 +281,9 @@ @include scss.block-properties("paywall-subscription-dialog"); } } + +@media (min-width: 320px) and (max-width: 480px) { + .b-paywall__overlay { + inset-block-start: initial; + } +} \ No newline at end of file From f352901a21a6dadb1fd383498a2602a03a2979aa Mon Sep 17 00:00:00 2001 From: Ryan Barnett Date: Thu, 21 Mar 2024 14:43:09 -0400 Subject: [PATCH 2/2] ci: add playwright github action --- .github/workflows/playwright.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/playwright.yml diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000000..bc8e7a68db --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ arc-themes-release-version-** ] + pull_request: + branches: [ arc-themes-release-version-** ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 \ No newline at end of file