2024-04-03 11:49:14 +02:00
|
|
|
import { expect, test } from '@playwright/test';
|
|
|
|
|
|
2025-01-10 15:32:39 +01:00
|
|
|
import {
|
|
|
|
|
createDoc,
|
|
|
|
|
goToGridDoc,
|
|
|
|
|
keyCloakSignIn,
|
|
|
|
|
randomName,
|
|
|
|
|
verifyDocName,
|
2025-07-16 13:56:18 +02:00
|
|
|
} from './utils-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 }) => {
|
2025-03-17 15:13:02 +01:00
|
|
|
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(
|
2025-03-17 15:13:02 +01:00
|
|
|
() => document.title.match(/my-new-doc - Docs/),
|
2024-10-01 15:55:02 +02:00
|
|
|
{ timeout: 5000 },
|
2024-09-05 12:45:02 +02:00
|
|
|
);
|
|
|
|
|
|
2024-07-05 14:14:43 +02:00
|
|
|
const header = page.locator('header').first();
|
2025-08-01 10:12:16 +02:00
|
|
|
await header.locator('h1').getByText('Docs').click();
|
2024-04-03 11:49:14 +02:00
|
|
|
|
2024-11-19 16:12:12 +01:00
|
|
|
const docsGrid = page.getByTestId('docs-grid');
|
|
|
|
|
await expect(docsGrid).toBeVisible();
|
2025-01-09 09:15:21 +01:00
|
|
|
await expect(page.getByTestId('grid-loader')).toBeHidden();
|
2024-11-19 16:12:12 +01:00
|
|
|
await expect(docsGrid.getByText(docTitle)).toBeVisible();
|
2024-04-18 13:21:08 +02:00
|
|
|
});
|
2025-04-23 17:40:27 +02:00
|
|
|
|
|
|
|
|
test('it creates a sub doc from slash menu editor', async ({
|
|
|
|
|
page,
|
|
|
|
|
browserName,
|
|
|
|
|
}) => {
|
|
|
|
|
const [title] = await createDoc(page, 'my-new-slash-doc', browserName, 1);
|
|
|
|
|
|
|
|
|
|
await verifyDocName(page, title);
|
|
|
|
|
|
|
|
|
|
await page.locator('.bn-block-outer').last().fill('/');
|
|
|
|
|
await page
|
|
|
|
|
.getByText('New sub-doc', {
|
|
|
|
|
exact: true,
|
|
|
|
|
})
|
|
|
|
|
.click();
|
|
|
|
|
|
2025-08-07 09:55:28 +02:00
|
|
|
const input = page.getByRole('textbox', { name: 'Document title' });
|
|
|
|
|
await expect(input).toHaveText('', { timeout: 10000 });
|
2025-04-23 17:40:27 +02:00
|
|
|
await expect(
|
|
|
|
|
page.locator('.c__tree-view--row-content').getByText('Untitled document'),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
});
|
2025-04-25 12:28:40 +02:00
|
|
|
|
|
|
|
|
test('it creates a sub doc from interlinking dropdown', async ({
|
|
|
|
|
page,
|
|
|
|
|
browserName,
|
|
|
|
|
}) => {
|
|
|
|
|
const [title] = await createDoc(page, 'my-new-slash-doc', browserName, 1);
|
|
|
|
|
|
|
|
|
|
await verifyDocName(page, title);
|
|
|
|
|
|
|
|
|
|
await page.locator('.bn-block-outer').last().fill('/');
|
|
|
|
|
await page.getByText('Link a doc').first().click();
|
|
|
|
|
await page
|
|
|
|
|
.locator('.quick-search-container')
|
|
|
|
|
.getByText('New sub-doc')
|
|
|
|
|
.click();
|
|
|
|
|
|
2025-08-07 09:55:28 +02:00
|
|
|
const input = page.getByRole('textbox', { name: 'Document title' });
|
|
|
|
|
await expect(input).toHaveText('', { timeout: 10000 });
|
2025-04-25 12:28:40 +02:00
|
|
|
await expect(
|
|
|
|
|
page.locator('.c__tree-view--row-content').getByText('Untitled document'),
|
|
|
|
|
).toBeVisible();
|
|
|
|
|
});
|
2024-04-03 11:49:14 +02:00
|
|
|
});
|
2024-12-16 22:49:06 +01:00
|
|
|
|
2025-05-26 10:27:17 +02:00
|
|
|
test.describe('Doc Create: Not logged', () => {
|
2024-12-16 22:49:06 +01:00
|
|
|
test.use({ storageState: { cookies: [], origins: [] } });
|
|
|
|
|
|
|
|
|
|
test('it creates a doc server way', async ({
|
|
|
|
|
page,
|
|
|
|
|
browserName,
|
|
|
|
|
request,
|
|
|
|
|
}) => {
|
2025-06-26 17:09:08 +02:00
|
|
|
const SERVER_TO_SERVER_API_TOKENS = 'server-api-token';
|
2024-12-16 22:49:06 +01:00
|
|
|
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,
|
2025-06-17 12:17:22 +02:00
|
|
|
sub: `user@${browserName}.test`,
|
|
|
|
|
email: `user@${browserName}.test`,
|
2024-12-16 22:49:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const newDoc = await request.post(
|
|
|
|
|
`http://localhost:8071/api/v1.0/documents/create-for-owner/`,
|
|
|
|
|
{
|
|
|
|
|
data,
|
|
|
|
|
headers: {
|
2025-06-26 17:09:08 +02:00
|
|
|
Authorization: `Bearer ${SERVER_TO_SERVER_API_TOKENS}`,
|
2024-12-16 22:49:06 +01:00
|
|
|
format: 'json',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(newDoc.ok()).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
await keyCloakSignIn(page, browserName);
|
|
|
|
|
|
|
|
|
|
await goToGridDoc(page, { title });
|
|
|
|
|
|
2025-01-10 15:32:39 +01:00
|
|
|
await verifyDocName(page, title);
|
2024-12-16 22:49:06 +01:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
});
|
|
|
|
|
});
|