🚚(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 ({
|
||||
|
||||
@@ -6,7 +6,8 @@ import {
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
|
||||
import { Template } from '@/features/templates/template';
|
||||
|
||||
import { Template } from '../types';
|
||||
|
||||
export enum TemplatesOrdering {
|
||||
BY_CREATED_ON = 'created_at',
|
||||
@@ -7,9 +7,9 @@ import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Pad, usePadStore } from '@/features/pads/pad';
|
||||
import { Template } from '@/features/templates/template';
|
||||
|
||||
import { useCreatePdf } from '../api/useCreatePdf';
|
||||
import { Template } from '../types';
|
||||
import { downloadFile } from '../utils';
|
||||
|
||||
interface PDFButtonProps {
|
||||
|
||||
@@ -4,7 +4,8 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { Pad } from '@/features/pads/pad';
|
||||
import { TemplatesOrdering, useTemplates } from '@/features/templates';
|
||||
|
||||
import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
|
||||
|
||||
import PDFButton from './PDFButton';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user