TagSpaces is an offline, open source, document manager with tagging support
chore: added e2e tests for crud operations
Ilian Sapundshievffbef9de0874
diff --git a/src/renderer/components/dialogs/components/SettingsTemplates.tsx b/src/renderer/components/dialogs/components/SettingsTemplates.tsxindex f182c91e8..4679ba311 100644--- a/src/renderer/components/dialogs/components/SettingsTemplates.tsx+++ b/src/renderer/components/dialogs/components/SettingsTemplates.tsx@@ -282,7 +282,7 @@ function SettingsTemplates(props: Props) {deleteTemplate(template.id);}}}- data-tid="removeAIProviderTID"+ data-tid={'removeTemplate_' + template.id + 'TID'}><RemoveIcon /></TsIconButton>@@ -313,6 +313,7 @@ function SettingsTemplates(props: Props) {<AccordionDetails><TsTextFieldfullWidth+ data-tid={'templateName_' + template.id + 'TID'}disabled={!Pro || !!AppConfig.ExtFileTemplates}label={t('name')}error={!currentTemplate(template).name}@@ -337,6 +338,7 @@ function SettingsTemplates(props: Props) {fullWidthmultilinerows={2}+ data-tid={'templateDescription_' + template.id + 'TID'}disabled={!Pro || !!AppConfig.ExtFileTemplates}label={t('core:templateDescription')}value={currentTemplate(template).description || ''}@@ -407,6 +409,7 @@ function SettingsTemplates(props: Props) {fullWidthmultilinerows={5}+ data-tid={'templateContent_' + template.id + 'TID'}disabled={!Pro || !!AppConfig.ExtFileTemplates}label={t('core:templateContent')}value={currentTemplate(template).content}@@ -423,6 +426,7 @@ function SettingsTemplates(props: Props) {/><TsTextFieldfullWidth+ data-tid={'templateFileName_' + template.id + 'TID'}disabled={!Pro || !!AppConfig.ExtFileTemplates}error={!currentTemplate(template).fileNameTmpl}label={t('fileNameTmpl')}diff --git a/tests/e2e/template.pw.e2e.js b/tests/e2e/template.pw.e2e.jsindex 448f8635b..1d6e9110d 100644--- a/tests/e2e/template.pw.e2e.js+++ b/tests/e2e/template.pw.e2e.js@@ -66,6 +66,16 @@ async function openTemplateGrid() {await expectElementExist('[data-tid=newFileDialog]', true, 5000);}+/**+ * Opens the templates management view (Settings -> Templates) and waits for the+ * default Markdown template accordion to be present.+ */+async function openManageTemplates() {+ await clickOn('[data-tid=settings]');+ await clickOn('[data-tid=templatesDialogTID]');+ await expectElementExist('[data-tid=templateMdTemplateTID]', true, 5000);+}+test.describe('TST74 - File templates', () => {test('TST7401 - Create file by picking a template tile [electron,_pro]', async () => {await createNewDirectory(testFolder);@@ -226,4 +236,89 @@ test.describe('TST74 - File templates', () => {await deleteDirectory(testFolder);});++ test('TST7411 - Manage templates: editing a template (incl. description) persists [electron,_pro]', async () => {+ // The name field is single-line (input); content/description are multiline+ // (textarea). MUI renders a hidden shadow textarea for autosize, so target+ // the real one explicitly.+ const nameSelector = '[data-tid=templateName_templateMdTID] input';+ const descSelector =+ '[data-tid=templateDescription_templateMdTID] textarea:not([aria-hidden="true"])';+ const newName = 'Edited Markdown';+ const newDescription = 'Edited template description for e2e';++ // Open Settings -> Templates and expand the Markdown template. Click the+ // expand icon specifically — the summary center can land on the remove+ // button (which stops propagation and would fire a delete confirm).+ await openManageTemplates();+ await clickOn(+ '[data-tid=templateMdTemplateTID] .MuiAccordionSummary-expandIconWrapper',+ );+ await global.client+ .locator(descSelector)+ .waitFor({ state: 'visible', timeout: 5000 });++ // Edit the name + description and save.+ await setInputValue(nameSelector, newName);+ await setInputValue(descSelector, newDescription);+ await clickOn('[data-tid=saveTemplateTID]');+ await clickOn('[data-tid=closeSettingsDialog]');++ // Reopen, expand again and assert both edits persisted.+ await openManageTemplates();+ await clickOn(+ '[data-tid=templateMdTemplateTID] .MuiAccordionSummary-expandIconWrapper',+ );+ await global.client+ .locator(descSelector)+ .waitFor({ state: 'visible', timeout: 5000 });+ await expect+ .poll(async () => global.client.locator(nameSelector).inputValue(), {+ timeout: 5000,+ message: 'edited template name should persist',+ })+ .toBe(newName);+ await expect+ .poll(async () => global.client.locator(descSelector).inputValue(), {+ timeout: 5000,+ message: 'edited template description should persist',+ })+ .toBe(newDescription);++ // Restore defaults to keep state clean for following tests.+ await clickOn('[data-tid=resetTemplatesTID]');+ await clickOn('[data-tid=closeSettingsDialog]');+ });++ test('TST7412 - Manage templates: deleting a template removes it [electron,_pro]', async () => {+ // The plain-text template exists by default.+ await openManageTemplates();+ await expectElementExist('[data-tid=templateTxtTemplateTID]', true, 5000);++ // The remove button triggers a native confirm() dialog — accept it.+ global.client.once('dialog', (dialog) => dialog.accept());+ await clickOn('[data-tid=removeTemplate_templateTxtTID]');++ // The template accordion disappears.+ await expectElementExist('[data-tid=templateTxtTemplateTID]', false, 5000);+ await clickOn('[data-tid=closeSettingsDialog]');++ // It also disappears from the create-from-template tile grid.+ await createNewDirectory(testFolder);+ await openFolder(testFolder);+ await openTemplateGrid();+ await expectElementExist(+ '[data-tid=newFileTemplateTile_templateTxt]',+ false,+ 2000,+ );+ await clickOn('[data-tid=closeNewFileDialogTID]');++ // Restore defaults for the following tests.+ await openManageTemplates();+ await clickOn('[data-tid=resetTemplatesTID]');+ await clickOn('[data-tid=closeSettingsDialog]');++ await deleteDirectory(testFolder);+ });});