(frontend) link to create new doc

We create a special URL to create a new doc,
we can set the doc with the URL param to set
the visibility, the permission and the title.
This commit is contained in:
Anthony LC
2025-12-01 15:08:13 +01:00
parent c13f0e97bb
commit 7475b7c3bc
8 changed files with 253 additions and 42 deletions

View File

@@ -7,6 +7,7 @@ import {
randomName,
verifyDocName,
} from './utils-common';
import { connectOtherUserToDoc } from './utils-share';
test.beforeEach(async ({ page }) => {
await page.goto('/');
@@ -73,6 +74,82 @@ test.describe('Doc Create', () => {
page.locator('.c__tree-view--row-content').getByText('Untitled document'),
).toBeVisible();
});
test('it creates a doc with link "/doc/new/', async ({
page,
browserName,
}) => {
test.slow();
// Private doc creation
await page.goto('/docs/new/?title=My+private+doc+from+url');
await verifyDocName(page, 'My private doc from url');
await page.getByRole('button', { name: 'Share' }).click();
await expect(
page.getByTestId('doc-visibility').getByText('Private').first(),
).toBeVisible();
// Public editing doc creation
await page.goto(
'/docs/new/?title=My+public+doc+from+url&link-reach=public&link-role=editor',
);
await verifyDocName(page, 'My public doc from url');
await page.getByRole('button', { name: 'Share' }).click();
await expect(
page.getByTestId('doc-visibility').getByText('Public').first(),
).toBeVisible();
await expect(
page.getByTestId('doc-access-mode').getByText('Editing').first(),
).toBeVisible();
// Authenticated reading doc creation
await page.goto(
'/docs/new/?title=My+authenticated+doc+from+url&link-reach=authenticated&link-role=reader',
);
await verifyDocName(page, 'My authenticated doc from url');
await page.getByRole('button', { name: 'Share' }).click();
await expect(
page.getByTestId('doc-visibility').getByText('Connected').first(),
).toBeVisible();
await expect(
page.getByTestId('doc-access-mode').getByText('Reading').first(),
).toBeVisible();
const { cleanup, otherPage, otherBrowserName } =
await connectOtherUserToDoc({
docUrl:
'/docs/new/?title=From+unlogged+doc+from+url&link-reach=authenticated&link-role=reader',
browserName,
withoutSignIn: true,
});
await keyCloakSignIn(otherPage, otherBrowserName, false);
await verifyDocName(otherPage, 'From unlogged doc from url');
await otherPage.getByRole('button', { name: 'Share' }).click();
await expect(
otherPage.getByTestId('doc-visibility').getByText('Connected').first(),
).toBeVisible();
await expect(
otherPage.getByTestId('doc-access-mode').getByText('Reading').first(),
).toBeVisible();
await cleanup();
});
});
test.describe('Doc Create: Not logged', () => {