2023-06-06 15:50:07 +12:00
|
|
|
import {expect, test} from '@playwright/test';
|
2023-10-03 16:20:40 +07:00
|
|
|
import {globalDataRequests, mockApi, updatedSettingsResponse} from '../../utils/acceptance';
|
2023-06-06 15:50:07 +12:00
|
|
|
|
|
|
|
test.describe('Social account settings', async () => {
|
|
|
|
test('Supports editing social URLs', async ({page}) => {
|
2023-08-03 09:29:14 +01:00
|
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
|
|
...globalDataRequests,
|
|
|
|
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
|
|
|
{key: 'facebook', value: 'fb'},
|
|
|
|
{key: 'twitter', value: '@tw'}
|
|
|
|
])}
|
2023-06-06 15:50:07 +12:00
|
|
|
}});
|
|
|
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
const section = page.getByTestId('social-accounts');
|
|
|
|
|
|
|
|
await expect(section.getByText('https://www.facebook.com/ghost')).toHaveCount(1);
|
|
|
|
await expect(section.getByText('https://twitter.com/ghost')).toHaveCount(1);
|
|
|
|
|
|
|
|
await section.getByRole('button', {name: 'Edit'}).click();
|
|
|
|
|
|
|
|
await section.getByLabel(`URL of your publication's Facebook Page`).fill('https://www.facebook.com/fb');
|
2023-10-02 15:14:46 +03:00
|
|
|
await section.getByLabel('URL of your X (formerly Twitter) profile').fill('https://twitter.com/tw');
|
2023-06-06 15:50:07 +12:00
|
|
|
|
|
|
|
await section.getByRole('button', {name: 'Save'}).click();
|
|
|
|
|
2023-10-02 15:14:46 +03:00
|
|
|
await expect(section.getByLabel('URL of your X (formerly Twitter) profile')).toHaveCount(0);
|
2023-06-06 15:50:07 +12:00
|
|
|
|
|
|
|
await expect(section.getByText('https://www.facebook.com/fb')).toHaveCount(1);
|
|
|
|
await expect(section.getByText('https://twitter.com/tw')).toHaveCount(1);
|
|
|
|
|
2023-08-03 09:29:14 +01:00
|
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
2023-06-06 15:50:07 +12:00
|
|
|
settings: [
|
|
|
|
{key: 'facebook', value: 'fb'},
|
|
|
|
{key: 'twitter', value: '@tw'}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|