/
editview.spec.js
78 lines (53 loc) 路 2.65 KB
/
editview.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { test, expect } from '@playwright/test';
import { login } from '../../utils/login';
import { resetDatabaseAndImportDataFromPath } from '../../scripts/dts-import';
test.describe('Edit View', () => {
test.beforeEach(async ({ page }) => {
await resetDatabaseAndImportDataFromPath('./e2e/data/with-admin.tar');
await page.goto('/admin');
await login({ page });
});
/**
* @note There is only one field in this content-type.
*/
test('A user should be able to navigate to the EditView of the content manager to create, save, publish, unpublish & delete a new entry', async ({
page,
}) => {
await page.getByRole('link', { name: 'Content Manager' }).click();
await page
.getByRole('link', { name: /Create new entry/ })
.nth(1)
.click();
/**
* Now we're in the edit view.
*/
await page.waitForURL('**/content-manager/collectionType/api::testing.testing/create');
await page.getByRole('textbox', { name: 'title' }).fill('my content');
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByText('Saved')).toBeVisible();
await expect(page.getByRole('button', { name: 'Save' })).toBeDisabled();
await page.getByRole('button', { name: 'Publish' }).click();
await expect(page.getByText('Published', { exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: 'Unpublish' })).not.toBeDisabled();
await page.getByRole('textbox', { name: 'title' }).fill('my content revised');
await expect(page.getByRole('button', { name: 'Unpublish' })).toBeDisabled();
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByRole('button', { name: 'Unpublish' })).not.toBeDisabled();
await page.getByRole('button', { name: 'Unpublish' }).click();
await expect(page.getByRole('dialog', { name: 'Confirmation' })).toBeVisible();
await page.getByRole('button', { name: 'Yes, confirm' }).click();
await expect(page.getByText('Unpublished')).toBeVisible();
await expect(page.getByRole('button', { name: 'Publish' })).not.toBeDisabled();
await page.getByRole('button', { name: 'Delete this entry' }).click();
await expect(page.getByRole('dialog', { name: 'Confirmation' })).toBeVisible();
await page.getByRole('button', { name: 'Confirm' }).click();
await expect(page.getByText('Deleted')).toBeVisible();
/**
* We're back on the list view
*/
await page.waitForURL(
'**/content-manager/collectionType/api::testing.testing?page=1&pageSize=10&sort=title:ASC'
);
await expect(page.getByRole('link', { name: /Create new entry/ }).nth(1)).toBeVisible();
});
});