mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
738ce491f4
refs: https://github.com/TryGhost/Product/issues/3729 - Wired up the FirstPromoter api to 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 bacd8ec</samp> This pull request refactors the `FirstPromoterModal` component to use hooks and helper functions, and adds a new end-to-end test file to verify its functionality. The purpose of these changes is to improve the code quality and the user experience of the FirstPromoter integration feature.
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('First Promoter integration', async () => {
|
|
test('Supports toggling and filling in First Promoter integration', async ({page}) => {
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
...globalDataRequests,
|
|
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
|
{key: 'firstpromoter', value: true},
|
|
{key: 'firstpromoter_id', value: '123456789'}
|
|
])}
|
|
}});
|
|
|
|
await page.goto('/');
|
|
const section = page.getByTestId('integrations');
|
|
const fpElement = section.getByText('FirstPromoter').last();
|
|
await fpElement.hover();
|
|
await page.getByRole('button', {name: 'Configure'}).click();
|
|
const fpModal = page.getByTestId('firstpromoter-modal');
|
|
|
|
const fpToggle = fpModal.getByRole('switch');
|
|
await fpToggle.click();
|
|
const input = fpModal.getByRole('textbox');
|
|
await input.fill('123456789');
|
|
|
|
await fpModal.getByRole('button', {name: 'Save'}).click();
|
|
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
|
settings: [
|
|
{key: 'firstpromoter', value: true},
|
|
{key: 'firstpromoter_id', value: '123456789'}
|
|
]
|
|
});
|
|
});
|
|
});
|