2023-06-06 06:50:07 +03:00
|
|
|
import {expect, test} from '@playwright/test';
|
2023-10-03 12:20:40 +03:00
|
|
|
import {globalDataRequests, mockApi, responseFixtures} from '../../utils/acceptance';
|
2023-06-06 06:50:07 +03:00
|
|
|
|
|
|
|
test.describe('Twitter settings', async () => {
|
|
|
|
test('Supports editing the twitter card', async ({page}) => {
|
2023-08-03 11:29:14 +03:00
|
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
|
|
...globalDataRequests,
|
|
|
|
uploadImage: {method: 'POST', path: '/images/upload/', response: {images: [{url: 'http://example.com/image.png', ref: null}]}},
|
|
|
|
editSettings: {method: 'PUT', path: '/settings/', response: responseFixtures.settings}
|
2023-06-06 06:50:07 +03:00
|
|
|
}});
|
|
|
|
|
|
|
|
await page.goto('/');
|
|
|
|
|
|
|
|
const section = page.getByTestId('twitter');
|
|
|
|
|
|
|
|
await section.getByRole('button', {name: 'Edit'}).click();
|
|
|
|
|
|
|
|
const fileChooserPromise = page.waitForEvent('filechooser');
|
|
|
|
|
|
|
|
await page.locator('label[for="twitter-image"]').click();
|
|
|
|
|
|
|
|
const fileChooser = await fileChooserPromise;
|
|
|
|
await fileChooser.setFiles(`${__dirname}/../../utils/images/image.png`);
|
|
|
|
|
2023-10-09 11:07:34 +03:00
|
|
|
await expect(section.locator('img[src="http://example.com/image.png"]')).toBeVisible();
|
2023-06-06 06:50:07 +03:00
|
|
|
|
2023-10-02 15:14:46 +03:00
|
|
|
await section.getByLabel('X title').fill('Twititle');
|
|
|
|
await section.getByLabel('X description').fill('Twitscription');
|
2023-06-06 06:50:07 +03:00
|
|
|
|
|
|
|
await section.getByRole('button', {name: 'Save'}).click();
|
|
|
|
|
|
|
|
await expect(section.getByLabel('Twitter title')).toHaveCount(0);
|
|
|
|
|
2023-08-03 11:29:14 +03:00
|
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
2023-06-06 06:50:07 +03:00
|
|
|
settings: [
|
|
|
|
{key: 'twitter_image', value: 'http://example.com/image.png'},
|
|
|
|
{key: 'twitter_title', value: 'Twititle'},
|
|
|
|
{key: 'twitter_description', value: 'Twitscription'}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|