Skip to content

Commit 9d99d5e

Browse files
committed
✅(e2e) add e2e tests for odt export and interlinking features
covers odt document export and cross-section interlinking use cases Signed-off-by: Cyril <c.gromoff@gmail.com>
1 parent 7ccc61d commit 9d99d5e

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

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

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,51 @@ test.describe('Doc Export', () => {
138138
expect(download.suggestedFilename()).toBe(`${randomDoc}.docx`);
139139
});
140140

141+
test('it exports the doc to odt', async ({ page, browserName }) => {
142+
const [randomDoc] = await createDoc(page, 'doc-editor-odt', browserName, 1);
143+
144+
await verifyDocName(page, randomDoc);
145+
146+
await page.locator('.ProseMirror.bn-editor').click();
147+
await page.locator('.ProseMirror.bn-editor').fill('Hello World ODT');
148+
149+
await page.keyboard.press('Enter');
150+
await page.locator('.bn-block-outer').last().fill('/');
151+
await page.getByText('Resizable image with caption').click();
152+
153+
const fileChooserPromise = page.waitForEvent('filechooser');
154+
await page.getByText('Upload image').click();
155+
156+
const fileChooser = await fileChooserPromise;
157+
await fileChooser.setFiles(path.join(__dirname, 'assets/test.svg'));
158+
159+
const image = page
160+
.locator('.--docs--editor-container img.bn-visual-media')
161+
.first();
162+
163+
await expect(image).toBeVisible();
164+
165+
await page
166+
.getByRole('button', {
167+
name: 'Export the document',
168+
})
169+
.click();
170+
171+
await page.getByRole('combobox', { name: 'Format' }).click();
172+
await page.getByRole('option', { name: 'Odt' }).click();
173+
174+
await expect(page.getByTestId('doc-export-download-button')).toBeVisible();
175+
176+
const downloadPromise = page.waitForEvent('download', (download) => {
177+
return download.suggestedFilename().includes(`${randomDoc}.odt`);
178+
});
179+
180+
void page.getByTestId('doc-export-download-button').click();
181+
182+
const download = await downloadPromise;
183+
expect(download.suggestedFilename()).toBe(`${randomDoc}.odt`);
184+
});
185+
141186
/**
142187
* This test tell us that the export to pdf is working with images
143188
* but it does not tell us if the images are being displayed correctly
@@ -451,4 +496,68 @@ test.describe('Doc Export', () => {
451496

452497
expect(pdfData.text).toContain(randomDoc);
453498
});
499+
500+
test('it exports the doc with interlinking to odt', async ({
501+
page,
502+
browserName,
503+
}) => {
504+
const [randomDoc] = await createDoc(
505+
page,
506+
'export-interlinking-odt',
507+
browserName,
508+
1,
509+
);
510+
511+
await verifyDocName(page, randomDoc);
512+
513+
const { name: docChild } = await createRootSubPage(
514+
page,
515+
browserName,
516+
'export-interlink-child-odt',
517+
);
518+
519+
await verifyDocName(page, docChild);
520+
521+
await page.locator('.bn-block-outer').last().fill('/');
522+
await page.getByText('Link a doc').first().click();
523+
524+
const input = page.locator(
525+
"span[data-inline-content-type='interlinkingSearchInline'] input",
526+
);
527+
const searchContainer = page.locator('.quick-search-container');
528+
529+
await input.fill('export-interlink');
530+
531+
await expect(searchContainer).toBeVisible();
532+
await expect(searchContainer.getByText(randomDoc)).toBeVisible();
533+
534+
// We are in docChild, we want to create a link to randomDoc (parent)
535+
await searchContainer.getByText(randomDoc).click();
536+
537+
// Search the interlinking link in the editor (not in the document tree)
538+
const editor = page.locator('.ProseMirror.bn-editor');
539+
const interlink = editor.getByRole('button', {
540+
name: randomDoc,
541+
});
542+
543+
await expect(interlink).toBeVisible();
544+
545+
await page
546+
.getByRole('button', {
547+
name: 'Export the document',
548+
})
549+
.click();
550+
551+
await page.getByRole('combobox', { name: 'Format' }).click();
552+
await page.getByRole('option', { name: 'Odt' }).click();
553+
554+
const downloadPromise = page.waitForEvent('download', (download) => {
555+
return download.suggestedFilename().includes(`${docChild}.odt`);
556+
});
557+
558+
void page.getByTestId('doc-export-download-button').click();
559+
560+
const download = await downloadPromise;
561+
expect(download.suggestedFilename()).toBe(`${docChild}.odt`);
562+
});
454563
});

0 commit comments

Comments
 (0)