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/membership/analytics.test.ts
Daniël van der Winden db3bab4f79
Updated layout for Analytics in Settings (#21322)
fixes
https://linear.app/tryghost/issue/DES-483/improve-analytics-card-layout-in-settings

Analytics settings in admin were difficult to read, as they were all
bunched together. This change lays them out in rows, making the
Analytics settings much easier to scan.

---------

Co-authored-by: Steve Larson <9larsons@gmail.com>
Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
Co-authored-by: Cathy Sarisky <42299862+cathysarisky@users.noreply.github.com>
Co-authored-by: Ghost CI <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: jubi-git <117194340+jubi-git@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-21 09:44:48 +00:00

60 lines
2.5 KiB
TypeScript

import {expect, test} from '@playwright/test';
import {globalDataRequests} from '../../utils/acceptance';
import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/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).toBeVisible();
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);
});
});