0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/apps/admin-x-settings/test/acceptance/advanced/integrations/firstPromoter.test.ts
Jono M fb7bf6d01e
Improved AdminX test coverage based on old admin tests (#18502)
refs https://github.com/TryGhost/Product/issues/3832

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 7eda74c</samp>

This pull request improves the validation, customization, and feedback
of various form components and modals in the admin-x-settings app. It
also adds new components for user detail modal sections and modifies the
user type to allow null values for social accounts. Additionally, it
adds `dirty` props to some integration modals and a `data-testid`
attribute to the exit settings button. It also deletes an unused file.
2023-10-06 10:06:05 +01:00

62 lines
2.5 KiB
TypeScript

import {expect, test} from '@playwright/test';
import {globalDataRequests, mockApi, responseFixtures, updatedSettingsResponse} from '../../../utils/acceptance';
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'}
]
});
});
test('Warns when leaving without saving', async ({page}) => {
const {lastApiRequests} = await mockApi({page, requests: {
...globalDataRequests,
editSettings: {method: 'PUT', path: '/settings/', response: responseFixtures.settings}
}});
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();
await fpModal.getByRole('button', {name: 'Cancel'}).click();
await expect(page.getByTestId('confirmation-modal')).toHaveText(/leave/i);
await page.getByTestId('confirmation-modal').getByRole('button', {name: 'Leave'}).click();
await expect(fpModal).toBeHidden();
expect(lastApiRequests.editSettings).toBeUndefined();
});
});