mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
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.
104 lines
4.7 KiB
TypeScript
104 lines
4.7 KiB
TypeScript
import {expect, test} from '@playwright/test';
|
|
import {globalDataRequests, mockApi, updatedSettingsResponse} from '../../../utils/acceptance';
|
|
|
|
test.describe('Pintura integration', async () => {
|
|
test('Can toggle Pintura', async ({page}) => {
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
...globalDataRequests,
|
|
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
|
{key: 'pintura', value: false}
|
|
])}
|
|
}});
|
|
|
|
await page.goto('/');
|
|
const section = page.getByTestId('integrations');
|
|
const pinturaElement = section.getByText('Pintura').last();
|
|
await pinturaElement.hover();
|
|
await page.getByRole('button', {name: 'Configure'}).click();
|
|
const pinturaModal = page.getByTestId('pintura-modal');
|
|
const pinturaToggle = pinturaModal.getByRole('switch');
|
|
await pinturaToggle.click();
|
|
// Upload Pintura script text should be visible
|
|
await expect(pinturaModal.getByText('Upload Pintura script')).toBeVisible();
|
|
await expect(pinturaModal.getByText('Upload Pintura styles')).toBeVisible();
|
|
await pinturaToggle.click();
|
|
await expect(pinturaModal.getByText('Upload Pintura script')).not.toBeVisible();
|
|
await expect(pinturaModal.getByText('Upload Pintura styles')).not.toBeVisible();
|
|
|
|
// we want it true, so click again
|
|
await pinturaToggle.click();
|
|
|
|
await page.getByRole('button', {name: 'Save'}).click();
|
|
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
|
settings: [
|
|
{key: 'pintura', value: true}
|
|
]
|
|
});
|
|
});
|
|
|
|
test('Can upload Pintura script', async ({page}) => {
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
...globalDataRequests,
|
|
uploadFile: {method: 'POST', path: '/files/upload/', response: {files: [{url: 'http://example.com/pintura-umd.js', ref: null}]}},
|
|
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
|
{key: 'pintura_js_url', value: 'http://example.com/pintura-umd.js'}
|
|
])}
|
|
}});
|
|
|
|
await page.goto('/');
|
|
|
|
const section = page.getByTestId('integrations');
|
|
const pinturaElement = section.getByText('Pintura').last();
|
|
await pinturaElement.hover();
|
|
await page.getByRole('button', {name: 'Configure'}).click();
|
|
const pinturaModal = page.getByTestId('pintura-modal');
|
|
const pinturaToggle = pinturaModal.getByRole('switch');
|
|
await pinturaToggle.click();
|
|
const jsFileChooserPromise = page.waitForEvent('filechooser');
|
|
|
|
const jsUploadButton = pinturaModal.getByRole('button', {name: 'Upload'}).first();
|
|
await jsUploadButton.click();
|
|
const jsFileChooser = await jsFileChooserPromise;
|
|
await jsFileChooser.setFiles(`${__dirname}/../../../utils/files/pintura-umd.js`);
|
|
|
|
await expect(jsUploadButton).toBeEnabled();
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
|
settings: [
|
|
{key: 'pintura_js_url', value: 'http://example.com/pintura-umd.js'}
|
|
]
|
|
});
|
|
});
|
|
|
|
test('Can upload Pintura styles', async ({page}) => {
|
|
const {lastApiRequests} = await mockApi({page, requests: {
|
|
...globalDataRequests,
|
|
uploadFile: {method: 'POST', path: '/files/upload/', response: {files: [{url: 'http://example.com/pintura.css', ref: null}]}},
|
|
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
|
{key: 'pintura_css_url', value: 'http://example.com/pintura.css'}
|
|
])}
|
|
}});
|
|
|
|
await page.goto('/');
|
|
|
|
const section = page.getByTestId('integrations');
|
|
const pinturaElement = section.getByText('Pintura').last();
|
|
await pinturaElement.hover();
|
|
await page.getByRole('button', {name: 'Configure'}).click();
|
|
const pinturaModal = page.getByTestId('pintura-modal');
|
|
const pinturaToggle = pinturaModal.getByRole('switch');
|
|
await pinturaToggle.click();
|
|
const cssFileChooserPromise = page.waitForEvent('filechooser');
|
|
|
|
const cssUploadButton = pinturaModal.getByRole('button', {name: 'Upload'}).last();
|
|
await cssUploadButton.click();
|
|
const cssFileChooser = await cssFileChooserPromise;
|
|
await cssFileChooser.setFiles(`${__dirname}/../../../utils/files/pintura.css`);
|
|
await expect(cssUploadButton).toBeEnabled();
|
|
expect(lastApiRequests.editSettings?.body).toEqual({
|
|
settings: [
|
|
{key: 'pintura_css_url', value: 'http://example.com/pintura.css'}
|
|
]
|
|
});
|
|
});
|
|
});
|