Ghost/apps/admin-x-settings/test/acceptance/advanced/labs.test.ts
Peter Zimon 770f657ae9
Improve messaging and error handling (#20078)
ref DES-228

This PR updates messaging and error handling in order to make Ghost calmer and friendlier. High level summary of the changes:

- Removed all onBlur validation in Settings -> now it’s possible to just click around without being warned to fill mandatory fields
- Removed  lot of technical errors like `ValidationError: Validation (isEmpty) failed for locale`
- Completely removed the red background toast notifications, it was aggressive and raw esp. on the top
- Removed some unnecessary notifications (e.g. when removing a webhook, the removal already communicates the result)
- Now we show field errors on submitting forms, and in case of an error we show a “Retry” button in Settings too. This allowed to remove a lot of unnecessary error messages, like the big error message on the top, plus it’s consistent with the patterns outside Settings.
- Notification style is white now with filled color icons which makes everything much calmer and more refined.
- Removes redundant copy (e.g. "successful(ly)") from notifications

---------

Co-authored-by: Sodbileg Gansukh <sodbileg.gansukh@gmail.com>
2024-05-14 09:31:19 +02:00

70 lines
2.8 KiB
TypeScript

import {expect, test} from '@playwright/test';
import {globalDataRequests} from '../../utils/acceptance';
import {mockApi} from '@tryghost/admin-x-framework/test/acceptance';
test.describe('Labs', async () => {
test('Uploading/downloading redirects', async ({page}) => {
const {lastApiRequests} = await mockApi({page, requests: {
...globalDataRequests,
uploadRedirects: {method: 'POST', path: '/redirects/upload/', response: {}},
downloadRedirects: {method: 'GET', path: '/redirects/download/', response: 'redirects'}
}});
await page.goto('/');
const labsSection = page.getByTestId('labs');
await labsSection.getByRole('button', {name: 'Open'}).click();
await labsSection.getByRole('tab', {name: 'Beta features'}).click();
const fileChooserPromise = page.waitForEvent('filechooser');
await labsSection.getByText('Upload redirects file').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(`${__dirname}/../../utils/files/redirects.yml`);
await expect(page.getByTestId('toast-success')).toContainText('Redirects uploaded');
expect(lastApiRequests.uploadRedirects).toBeTruthy();
await labsSection.getByRole('button', {name: 'Download current redirects'}).click();
await expect(page.locator('iframe#iframeDownload')).toHaveAttribute('src', /\/redirects\/download\//);
expect(lastApiRequests.downloadRedirects).toBeTruthy();
});
test('Uploading/downloading routes', async ({page}) => {
const {lastApiRequests} = await mockApi({page, requests: {
...globalDataRequests,
uploadRoutes: {method: 'POST', path: '/settings/routes/yaml/', response: {}},
downloadRoutes: {method: 'GET', path: '/settings/routes/yaml/', response: 'routes'}
}});
await page.goto('/');
const labsSection = page.getByTestId('labs');
await labsSection.getByRole('button', {name: 'Open'}).click();
await labsSection.getByRole('tab', {name: 'Beta features'}).click();
const fileChooserPromise = page.waitForEvent('filechooser');
await labsSection.getByText('Upload routes file').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(`${__dirname}/../../utils/files/routes.yml`);
await expect(page.getByTestId('toast-success')).toContainText('Routes uploaded');
expect(lastApiRequests.uploadRoutes).toBeTruthy();
await labsSection.getByRole('button', {name: 'Download current routes'}).click();
await expect(page.locator('iframe#iframeDownload')).toHaveAttribute('src', /\/settings\/routes\/yaml\//);
expect(lastApiRequests.downloadRoutes).toBeTruthy();
});
});