|
1 | 1 | import { expect, test } from '@playwright/test';
|
2 | 2 |
|
3 |
| -import { createDoc } from './common'; |
| 3 | +import { createDoc, goToGridDoc, keyCloakSignIn, randomName } from './common'; |
4 | 4 |
|
5 | 5 | test.beforeEach(async ({ page }) => {
|
6 | 6 | await page.goto('/');
|
@@ -29,3 +29,47 @@ test.describe('Doc Create', () => {
|
29 | 29 | });
|
30 | 30 | });
|
31 | 31 | });
|
| 32 | + |
| 33 | +test.describe('Doc Create: Not loggued', () => { |
| 34 | + test.use({ storageState: { cookies: [], origins: [] } }); |
| 35 | + |
| 36 | + test('it creates a doc server way', async ({ |
| 37 | + page, |
| 38 | + browserName, |
| 39 | + request, |
| 40 | + }) => { |
| 41 | + const markdown = `This is a normal text\n\n# And this is a large heading`; |
| 42 | + const [title] = randomName('My server way doc create', browserName, 1); |
| 43 | + const data = { |
| 44 | + title, |
| 45 | + content: markdown, |
| 46 | + sub: `user@${browserName}.e2e`, |
| 47 | + email: `user@${browserName}.e2e`, |
| 48 | + }; |
| 49 | + |
| 50 | + const newDoc = await request.post( |
| 51 | + `http://localhost:8071/api/v1.0/documents/create-for-owner/`, |
| 52 | + { |
| 53 | + data, |
| 54 | + headers: { |
| 55 | + Authorization: 'Bearer test-e2e', |
| 56 | + format: 'json', |
| 57 | + }, |
| 58 | + }, |
| 59 | + ); |
| 60 | + |
| 61 | + expect(newDoc.ok()).toBeTruthy(); |
| 62 | + |
| 63 | + await keyCloakSignIn(page, browserName); |
| 64 | + |
| 65 | + await goToGridDoc(page, { title }); |
| 66 | + |
| 67 | + await expect(page.getByRole('heading', { name: title })).toBeVisible(); |
| 68 | + |
| 69 | + const editor = page.locator('.ProseMirror'); |
| 70 | + await expect(editor.getByText('This is a normal text')).toBeVisible(); |
| 71 | + await expect( |
| 72 | + editor.locator('h1').getByText('And this is a large heading'), |
| 73 | + ).toBeVisible(); |
| 74 | + }); |
| 75 | +}); |
0 commit comments