🚚(app-impress) move templates api to pad-tools
Before removing the templates feature, we move the necessary api to the pad feature.
This commit is contained in:
@@ -8,10 +8,7 @@ test.beforeEach(async ({ page, browserName }) => {
|
||||
});
|
||||
|
||||
test.describe('Menu', () => {
|
||||
const menuItems = [
|
||||
{ name: 'Pad', isDefault: true },
|
||||
{ name: 'Template', isDefault: false },
|
||||
];
|
||||
const menuItems = [{ name: 'Pad', isDefault: true }];
|
||||
for (const { name, isDefault } of menuItems) {
|
||||
test(`checks that ${name} menu item is displaying correctly`, async ({
|
||||
page,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
|
||||
import cs from 'convert-stream';
|
||||
import pdf from 'pdf-parse';
|
||||
|
||||
import { createPad, createTemplate, keyCloakSignIn } from './common';
|
||||
import { createPad, keyCloakSignIn } from './common';
|
||||
|
||||
test.beforeEach(async ({ page, browserName }) => {
|
||||
await page.goto('/');
|
||||
@@ -77,51 +77,19 @@ test.describe('Pad Editor', () => {
|
||||
).toHaveAttribute('href', 'http://test-markdown.html');
|
||||
});
|
||||
|
||||
test('it converts the pad to pdf with a template created', async ({
|
||||
test('it converts the pad to pdf with a template integrated', async ({
|
||||
page,
|
||||
browserName,
|
||||
}) => {
|
||||
// eslint-disable-next-line playwright/no-skipped-test
|
||||
test.skip(
|
||||
browserName !== 'chromium',
|
||||
'This test failed with safary because of the dragNdrop',
|
||||
);
|
||||
|
||||
const downloadPromise = page.waitForEvent('download', (download) => {
|
||||
return download.suggestedFilename().includes('impress-document.pdf');
|
||||
});
|
||||
|
||||
const templates = await createTemplate(
|
||||
page,
|
||||
'template-pad',
|
||||
browserName,
|
||||
1,
|
||||
);
|
||||
|
||||
const iframe = page.frameLocator('iFrame.gjs-frame');
|
||||
await page.getByTitle('Open Blocks').click();
|
||||
await page
|
||||
.locator('.gjs-editor .gjs-block[title="Text"]')
|
||||
.dragTo(iframe.locator('body.gjs-dashed'));
|
||||
|
||||
await iframe
|
||||
.getByText('Insert your text here')
|
||||
.fill('My template ! {{body}}');
|
||||
await iframe.locator('body.gjs-dashed').click();
|
||||
|
||||
await page.getByText('Save template').click();
|
||||
|
||||
const menu = page.locator('menu').first();
|
||||
await menu.getByLabel(`Pad button`).click();
|
||||
|
||||
const randomPad = await createPad(page, 'pad-editor', browserName, 1);
|
||||
await expect(page.locator('h2').getByText(randomPad[0])).toBeVisible();
|
||||
|
||||
await page.locator('.ProseMirror.bn-editor').click();
|
||||
await page.locator('.ProseMirror.bn-editor').fill('And my pad !');
|
||||
|
||||
await page.getByRole('combobox', { name: 'Template' }).click();
|
||||
await page.getByRole('option', { name: templates[0] }).click();
|
||||
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
|
||||
|
||||
await page.getByText('Generate PDF').first().click();
|
||||
|
||||
@@ -131,8 +99,9 @@ test.describe('Pad Editor', () => {
|
||||
const pdfBuffer = await cs.toBuffer(await download.createReadStream());
|
||||
const pdfText = (await pdf(pdfBuffer)).text;
|
||||
|
||||
expect(pdfText).toContain('My template !');
|
||||
expect(pdfText).toContain('And my pad !');
|
||||
expect(pdfText).toContain('Monsieur le Premier Ministre'); // This is the template text
|
||||
expect(pdfText).toContain('La directrice'); // This is the template text
|
||||
expect(pdfText).toContain('Hello World'); // This is the pad text
|
||||
});
|
||||
|
||||
test('it renders correctly when we switch from one pad to another', async ({
|
||||
|
||||
Reference in New Issue
Block a user