(frontend) interlinking custom inline content

We want to be able to interlink documents in the editor.
We created a custom inline content that allows
users to interlink documents.
This commit is contained in:
Anthony LC
2025-04-23 18:41:11 +02:00
parent afa48b6675
commit 155e7dfe22
21 changed files with 685 additions and 153 deletions

View File

@@ -706,4 +706,59 @@ test.describe('Doc Editor', () => {
'pink',
);
});
test('it checks interlink feature', async ({ page, browserName }) => {
const [randomDoc] = await createDoc(page, 'doc-interlink', browserName, 1);
await verifyDocName(page, randomDoc);
const { name: docChild1 } = await createRootSubPage(
page,
browserName,
'doc-interlink-child-1',
);
await verifyDocName(page, docChild1);
const { name: docChild2 } = await createRootSubPage(
page,
browserName,
'doc-interlink-child-2',
);
await verifyDocName(page, docChild2);
await page.locator('.bn-block-outer').last().fill('/');
await page.getByText('Link a doc').first().click();
const input = page.locator(
"span[data-inline-content-type='interlinkingSearchInline'] input",
);
const searchContainer = page.locator('.quick-search-container');
await input.fill('doc-interlink');
await expect(searchContainer.getByText(randomDoc)).toBeVisible();
await expect(searchContainer.getByText(docChild1)).toBeVisible();
await expect(searchContainer.getByText(docChild2)).toBeVisible();
await input.pressSequentially('-child');
await expect(searchContainer.getByText(docChild1)).toBeVisible();
await expect(searchContainer.getByText(docChild2)).toBeVisible();
await expect(searchContainer.getByText(randomDoc)).toBeHidden();
// use keydown to select the second result
await page.keyboard.press('ArrowDown');
await page.keyboard.press('Enter');
const interlink = page.getByRole('link', {
name: 'child-2',
});
await expect(interlink).toBeVisible();
await interlink.click();
await verifyDocName(page, docChild2);
});
});

View File

@@ -179,7 +179,7 @@ test.describe('Doc grid dnd mobile', () => {
await expect(docsGrid.getByRole('row').first()).toBeVisible();
await expect(docsGrid.locator('.--docs--grid-droppable')).toHaveCount(0);
await createDoc(page, 'Draggable doc mobile', browserName, 1, false, true);
await createDoc(page, 'Draggable doc mobile', browserName, 1, true);
await createRootSubPage(
page,

View File

@@ -78,17 +78,11 @@ export const createDoc = async (
docName: string,
browserName: string,
length: number = 1,
isChild: boolean = false,
isMobile: boolean = false,
) => {
const randomDocs = randomName(docName, browserName, length);
for (let i = 0; i < randomDocs.length; i++) {
if (!isChild && !isMobile) {
const header = page.locator('header').first();
await header.locator('h2').getByText('Docs').click();
}
if (isMobile) {
await page
.getByRole('button', { name: 'Open the header menu' })