Skip to content

Commit 6791515

Browse files
committed
✅(e2e) add a test on doc creation server side
We recently added a new feature to the app, which is the ability to create a document from server to server. Server A will send a request to Server B with a markdown content, and Server B will create a the document after converting the markdown to yjs base64 format. This test will check all the steps of the process and assert that the document is displayed correctly on the frontend in the blocknote editor.
1 parent de25b36 commit 6791515

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

env.d/development/common.e2e.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# For the CI job test-e2e
22
SUSTAINED_THROTTLE_RATES="200/hour"
33
BURST_THROTTLE_RATES="200/minute"
4+
DJANGO_SERVER_TO_SERVER_API_TOKENS=test-e2e
5+
Y_PROVIDER_API_KEY=yprovider-api-key
6+
Y_PROVIDER_API_BASE_URL=http://y-provider:4444/api/

src/frontend/apps/e2e/__tests__/app-impress/doc-create.spec.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test } from '@playwright/test';
22

3-
import { createDoc } from './common';
3+
import { createDoc, goToGridDoc, keyCloakSignIn, randomName } from './common';
44

55
test.beforeEach(async ({ page }) => {
66
await page.goto('/');
@@ -29,3 +29,47 @@ test.describe('Doc Create', () => {
2929
});
3030
});
3131
});
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

Comments
 (0)