From 194205769b2589d566e16415f5891364dfe72724 Mon Sep 17 00:00:00 2001 From: Aileen Booker Date: Wed, 3 Jul 2024 12:29:54 -0400 Subject: [PATCH] Added test assertion to verify limit modal redirects to `/pro` route ref ENG-1035 We didn't have a test assertion for when a user is prompted with a limit upgrade modal, which verifies that a click on the `Upgrade` button will redirect correctly to the Billing App (`\pro` route). --- .../test/acceptance/site/theme.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/admin-x-settings/test/acceptance/site/theme.test.ts b/apps/admin-x-settings/test/acceptance/site/theme.test.ts index bcaf610fa9..2dfdfc53f6 100644 --- a/apps/admin-x-settings/test/acceptance/site/theme.test.ts +++ b/apps/admin-x-settings/test/acceptance/site/theme.test.ts @@ -168,7 +168,7 @@ test.describe('Theme settings', async () => { expect(lastApiRequests.uploadTheme).toBeTruthy(); }); - test('Limits uploading new themes', async ({page}) => { + test('Limits uploading new themes and redirect to /pro', async ({page}) => { await mockApi({page, requests: { ...globalDataRequests, ...limitRequests, @@ -206,6 +206,18 @@ test.describe('Theme settings', async () => { await modal.getByRole('button', {name: 'Upload theme'}).click(); await expect(page.getByTestId('limit-modal')).toHaveText(/Upgrade to enable custom themes/); + + const limitModal = page.getByTestId('limit-modal'); + + await limitModal.getByRole('button', {name: 'Upgrade'}).click(); + + // The route should be updated + const newPageUrl = page.url(); + const newPageUrlObject = new URL(newPageUrl); + const decodedUrl = decodeURIComponent(newPageUrlObject.pathname); + + // expect the route to be updated to /pro + await expect(decodedUrl).toMatch(/\/\{\"route\":\"\/pro\",\"isExternal\":true\}$/); }); test('Prevents overwriting the default theme', async ({page}) => {