From a8248f10d216788ca2c4427e59bde2bf0c8965e2 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 17 Apr 2024 10:22:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=94(app-impress)=20button=20to=20save?= =?UTF-8?q?=20html=20and=20css=20of=20the=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We created a button to save the template's html and css. With the template saved we will be able to use it in the near future with our pads. --- .../app-impress/template-editor.spec.ts | 27 +++++++++++ .../template/api/useUpdateTemplate.tsx | 13 +++++- .../template/components/TemplateEditor.tsx | 46 ++++++++++++++++--- 3 files changed, 78 insertions(+), 8 deletions(-) diff --git a/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts index 5e5b2735..041ed437 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts @@ -59,4 +59,31 @@ test.describe('Template Editor', () => { timeout: 5000, }); }); + + test('it saves the html generated by the template', async ({ + page, + browserName, + }) => { + const randomTemplate = await createTemplate( + page, + 'template-html', + browserName, + 1, + ); + + await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible(); + + 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('Hello World'); + await iframe.locator('body.gjs-dashed').click(); + + await page.getByText('Save template').click(); + await expect(page.getByText('Template save successfully')).toBeVisible(); + }); }); diff --git a/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx b/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx index 3264e623..8e833410 100644 --- a/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx +++ b/src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx @@ -7,16 +7,25 @@ import { Template } from '../types'; import { KEY_TEMPLATE } from './useTemplate'; -type UpdateTemplateProps = Pick; +type UpdateTemplateProps = { + id: Template['id']; + css?: string; + html?: string; + title?: Template['title']; +}; export const updateTemplate = async ({ - title, id, + title, + css, + html, }: UpdateTemplateProps): Promise