a596b3aaca
ref https://www.notion.so/AdminX-testing-plan-99b2dab27e794fc893767ccd01c84a63?d=26612fc2b9d84e65bbb269fa3bc5079e&pvs=4#f0089cd4d9f24e93bd7f8e2868987bf6 This pull request renames the end-to-end tests to acceptance tests in the `apps/admin-x-settings` folder. It updates the `ci.yml` file, the `package.json` file, the `playwright.config.ts` file, and the test files to reflect the new naming convention. This change aims to better reflect the purpose and scope of the tests.
58 lines
2.4 KiB
TypeScript
58 lines
2.4 KiB
TypeScript
import {expect, test} from '@playwright/test';
|
|
import {globalDataRequests, mockApi, updatedSettingsResponse} from '../../utils/acceptance';
|
|
|
|
test.describe('Analytics settings', async () => {
|
|
test('Supports toggling analytics settings', async ({page}) => {
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
...globalDataRequests,
|
|
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
|
{key: 'members_track_sources', value: false},
|
|
{key: 'email_track_opens', value: false},
|
|
{key: 'email_track_clicks', value: false},
|
|
{key: 'outbound_link_tagging', value: false}
|
|
])}
|
|
}});
|
|
|
|
await page.goto('/');
|
|
|
|
const section = page.getByTestId('analytics');
|
|
|
|
await expect(section.getByLabel(/Newsletter opens/)).toBeChecked();
|
|
await expect(section.getByLabel(/Newsletter clicks/)).toBeChecked();
|
|
await expect(section.getByLabel(/Member sources/)).toBeChecked();
|
|
await expect(section.getByLabel(/Outbound link tagging/)).toBeChecked();
|
|
|
|
await section.getByLabel(/Newsletter opens/).uncheck();
|
|
await section.getByLabel(/Newsletter clicks/).uncheck();
|
|
await section.getByLabel(/Member sources/).uncheck();
|
|
await section.getByLabel(/Outbound link tagging/).uncheck();
|
|
|
|
await section.getByRole('button', {name: 'Save'}).click();
|
|
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
|
settings: [
|
|
{key: 'members_track_sources', value: false},
|
|
{key: 'email_track_opens', value: false},
|
|
{key: 'email_track_clicks', value: false},
|
|
{key: 'outbound_link_tagging', value: false}
|
|
]
|
|
});
|
|
});
|
|
|
|
test('Supports downloading analytics csv export', async ({page}) => {
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
...globalDataRequests,
|
|
postsExport: {method: 'GET', path: '/posts/export/?limit=1000', response: 'csv data'}
|
|
}});
|
|
|
|
await page.goto('/');
|
|
|
|
const section = page.getByTestId('analytics');
|
|
|
|
await section.getByRole('button', {name: 'Export'}).click();
|
|
|
|
const hasDownloadUrl = lastApiRequests.postsExport?.url?.includes('/posts/export/?limit=1000');
|
|
expect(hasDownloadUrl).toBe(true);
|
|
});
|
|
});
|