From 4c09a96a3c5e82b7a6377b74a53f078aff366679 Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Mon, 11 Dec 2023 16:28:35 +0200 Subject: [PATCH] Changed request type to fetching iframe content in previews (#19307) refs PROD-227 - Swapped out the request type from `POST` to `GET`. --- apps/admin-x-framework/src/test/acceptance.ts | 2 +- .../settings/site/announcementBar/AnnouncementBarPreview.tsx | 2 +- .../components/settings/site/designAndBranding/ThemePreview.tsx | 2 +- .../test/acceptance/site/announcementbar.test.ts | 2 +- apps/admin-x-settings/test/acceptance/site/design.test.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/admin-x-framework/src/test/acceptance.ts b/apps/admin-x-framework/src/test/acceptance.ts index ab107c2a10..bf15ba2901 100644 --- a/apps/admin-x-framework/src/test/acceptance.ts +++ b/apps/admin-x-framework/src/test/acceptance.ts @@ -223,7 +223,7 @@ export async function mockSitePreview({page, url, response}: {page: Page, url: s const lastRequest: {previewHeader?: string} = {}; await page.route(url, async (route) => { - if (route.request().method() !== 'POST') { + if (route.request().method() !== 'GET') { return route.continue(); } diff --git a/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx b/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx index 6bd8ae2737..f68c0bb465 100644 --- a/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx +++ b/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx @@ -28,7 +28,7 @@ const AnnouncementBarPreview: React.FC = ({announcement } fetch(url, { - method: 'POST', + method: 'GET', headers: { 'Content-Type': 'text/html;charset=utf-8', 'x-ghost-preview': getPreviewData( diff --git a/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemePreview.tsx b/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemePreview.tsx index ce155836b4..42008969f9 100644 --- a/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemePreview.tsx +++ b/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemePreview.tsx @@ -65,7 +65,7 @@ const ThemePreview: React.FC = ({settings,url}) => { // Fetch theme preview HTML fetch(url, { - method: 'POST', + method: 'GET', headers: { 'Content-Type': 'text/html;charset=utf-8', 'x-ghost-preview': previewData, diff --git a/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts b/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts index e0f0f0c798..bc160f9306 100644 --- a/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts +++ b/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts @@ -44,7 +44,7 @@ test.describe('Announcement Bar', async () => { const iframesHandleHome = await page.$$('[data-testid="announcement-bar-preview-iframe"] > iframe'); const textExistsInHomeIframes = await checkTextInIframes(iframesHandleHome, 'homepage preview'); - expect(textExistsInHomeIframes).toBeTruthy(); + await expect(textExistsInHomeIframes).toBeTruthy(); const modal = page.getByTestId('announcement-bar-modal'); await modal.getByTestId('design-toolbar').getByRole('tab', {name: 'Post'}).click(); diff --git a/apps/admin-x-settings/test/acceptance/site/design.test.ts b/apps/admin-x-settings/test/acceptance/site/design.test.ts index 9f062e7443..9e567a44af 100644 --- a/apps/admin-x-settings/test/acceptance/site/design.test.ts +++ b/apps/admin-x-settings/test/acceptance/site/design.test.ts @@ -220,7 +220,7 @@ test.describe('Design settings', async () => { await expect(modal.getByTestId('design-setting-tabs').getByRole('tab', {name: 'Post'})).toBeHidden(); const expectedEncoded = new URLSearchParams([['custom', JSON.stringify({})]]).toString(); - expect(lastPreviewRequest.previewHeader).toMatch(new RegExp(`&${expectedEncoded.replace(/\+/g, '\\+')}`)); + await expect(lastPreviewRequest.previewHeader).toMatch(new RegExp(`&${expectedEncoded.replace(/\+/g, '\\+')}`)); }); test('Custom theme setting visibility', async ({page}) => {