2024-04-03 11:49:14 +02:00
|
|
|
import { expect, test } from '@playwright/test';
|
|
|
|
|
|
2024-12-16 22:49:06 +01:00
|
|
|
import { createDoc, goToGridDoc, keyCloakSignIn, randomName } from './common';
|
2024-07-05 14:14:43 +02:00
|
|
|
|
2024-06-06 22:13:18 +02:00
|
|
|
test.beforeEach(async ({ page }) => {
|
2024-04-03 11:49:14 +02:00
|
|
|
await page.goto('/');
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-25 14:49:53 +02:00
|
|
|
test.describe('Doc Create', () => {
|
2024-09-06 18:03:19 +02:00
|
|
|
test('it creates a doc', async ({ page, browserName }) => {
|
|
|
|
|
const [docTitle] = await createDoc(page, 'My new doc', browserName, 1);
|
2024-04-03 11:49:14 +02:00
|
|
|
|
2024-10-01 15:55:02 +02:00
|
|
|
await page.waitForFunction(
|
|
|
|
|
() => document.title.match(/My new doc - Docs/),
|
|
|
|
|
{ timeout: 5000 },
|
2024-09-05 12:45:02 +02:00
|
|
|
);
|
|
|
|
|
|
2024-07-05 14:14:43 +02:00
|
|
|
const header = page.locator('header').first();
|
|
|
|
|
await header.locator('h2').getByText('Docs').click();
|
2024-04-03 11:49:14 +02:00
|
|
|
|
2024-11-19 16:12:12 +01:00
|
|
|
await expect(page.getByTestId('docs-grid-loader')).toBeVisible();
|
|
|
|
|
|
|
|
|
|
const docsGrid = page.getByTestId('docs-grid');
|
|
|
|
|
await expect(docsGrid).toBeVisible();
|
|
|
|
|
await expect(page.getByTestId('docs-grid-loader')).toBeHidden();
|
|
|
|
|
await expect(docsGrid.getByText(docTitle)).toBeVisible();
|
2024-04-18 13:21:08 +02:00
|
|
|
});
|
2024-04-03 11:49:14 +02:00
|
|
|
});
|
2024-12-16 22:49:06 +01:00
|
|
|
|
|
|
|
|
test.describe('Doc Create: Not loggued', () => {
|
|
|
|
|
test.use({ storageState: { cookies: [], origins: [] } });
|
|
|
|
|
|
|
|
|
|
test('it creates a doc server way', async ({
|
|
|
|
|
page,
|
|
|
|
|
browserName,
|
|
|
|
|
request,
|
|
|
|
|
}) => {
|
|
|
|
|
const markdown = `This is a normal text\n\n# And this is a large heading`;
|
|
|
|
|
const [title] = randomName('My server way doc create', browserName, 1);
|
|
|
|
|
const data = {
|
|
|
|
|
title,
|
|
|
|
|
content: markdown,
|
|
|
|
|
sub: `user@${browserName}.e2e`,
|
|
|
|
|
email: `user@${browserName}.e2e`,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const newDoc = await request.post(
|
|
|
|
|
`http://localhost:8071/api/v1.0/documents/create-for-owner/`,
|
|
|
|
|
{
|
|
|
|
|
data,
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: 'Bearer test-e2e',
|
|
|
|
|
format: 'json',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(newDoc.ok()).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
await keyCloakSignIn(page, browserName);
|
|
|
|
|
|
|
|
|
|
await goToGridDoc(page, { title });
|
|
|
|
|
|
|
|
|
|
await expect(page.getByRole('heading', { name: title })).toBeVisible();
|
|
|
|
|
|
|
|
|
|
const editor = page.locator('.ProseMirror');
|
|
|
|
|
await expect(editor.getByText('This is a normal text')).toBeVisible();
|
|
|
|
|
await expect(
|
|
|
|
|
editor.locator('h1').getByText('And this is a large heading'),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
});
|