mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
a6776301e3
refs https://github.com/TryGhost/Product/issues/3729 - wired up api to the AMP integration on AdminX --- <!-- Leave the line below if you'd like GitHub Copilot to generate a summary from your commit --> <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 930d3b2</samp> This file adds a modal component to the advanced settings page that allows users to toggle and customize AMP integration for their site. It uses the `settings` API and React hooks to handle the modal logic and state.
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import {expect, test} from '@playwright/test';
|
|
import {globalDataRequests, mockApi, updatedSettingsResponse} from '../../../utils/e2e';
|
|
|
|
test.describe('AMP integration', async () => {
|
|
test('Supports toggling and filling in AMP integration', async ({page}) => {
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
...globalDataRequests,
|
|
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
|
{key: 'amp', value: true},
|
|
{key: 'amp_gtag_id', value: 'UA-1234567-1'}
|
|
])}
|
|
}});
|
|
|
|
await page.goto('/');
|
|
const section = page.getByTestId('integrations');
|
|
const ampElement = section.getByText('AMP').last();
|
|
await ampElement.hover();
|
|
await page.getByRole('button', {name: 'Configure'}).click();
|
|
const ampModal = page.getByTestId('amp-modal');
|
|
|
|
const ampToggle = ampModal.getByRole('switch');
|
|
await ampToggle.click();
|
|
const input = ampModal.getByRole('textbox');
|
|
await input.fill('UA-1234567-1');
|
|
|
|
await ampModal.getByRole('button', {name: 'Save'}).click();
|
|
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
|
settings: [
|
|
{key: 'amp', value: true},
|
|
{key: 'amp_gtag_id', value: 'UA-1234567-1'}
|
|
]
|
|
});
|
|
});
|
|
});
|