diff --git a/e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts b/e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts index d2f8d2ffaa..8ccd08df8d 100755 --- a/e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts +++ b/e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts @@ -43,9 +43,9 @@ test.describe('Info Drawer - File Folder Properties', () => { let categoriesApi: CategoriesApi; let responseCategoryId: string; let responseTagsId: string; - let Folder17239Id: string; let Folder17240Id: string; let Folder17242Id: string; + const tagsPhraseForDeletion = 'e2e'; const username = `user-e2e-${Utils.random()}`; const manualTagName = `e2e-tag-${Utils.random()}`; const FolderC299162 = `C299162-e2e-${Utils.random()}`; @@ -57,7 +57,7 @@ test.describe('Info Drawer - File Folder Properties', () => { const Folder17242 = `xat-17242-e2e-${Utils.random()}`; const Folder17243 = `xat-17243-e2e-${Utils.random()}`; const Folder17244 = `xat-17244-e2e-${Utils.random()}`; - const tagBody = { tag: `tag-${Utils.random()}` }; + const tagBody = { tag: `e2e-${Utils.random()}` }; const categoryName = Utils.random(); const noCategoriesText = 'There are currently no categories added'; const noTagsText = 'There are currently no tags added'; @@ -102,7 +102,7 @@ test.describe('Info Drawer - File Folder Properties', () => { await nodesApi.createFolder(FolderC299162); await nodesApi.createFolder(FolderC599174); await nodesApi.createFolder(Folder17238); - Folder17239Id = (await nodesApi.createFolder(Folder17239)).entry.id; + await nodesApi.createFolder(Folder17239); Folder17240Id = (await nodesApi.createFolder(Folder17240)).entry.id; await nodesApi.createFolder(Folder17241); Folder17242Id = (await nodesApi.createFolder(Folder17242)).entry.id; @@ -120,7 +120,7 @@ test.describe('Info Drawer - File Folder Properties', () => { test.afterAll(async () => { await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed'); await categoriesApi.deleteCategory(responseCategoryId); - await tagsApi.deleteTag(responseTagsId); + await tagsApi.deleteTagsByTagName(tagsPhraseForDeletion); }); async function navigateAndOpenInfoDrawer(personalFiles: PersonalFilesPage, folderName: string) { @@ -132,18 +132,6 @@ test.describe('Info Drawer - File Folder Properties', () => { await personalFiles.acaHeader.viewDetails.click(); } - async function waitForTagToBeAdded(folderId: string, personalFiles: PersonalFilesPage, maxRetries: number) { - let retries = 0; - - while ((await tagsApi.listTagsForNode(folderId)).list.entries.length === 0) { - if (retries >= maxRetries) { - throw new Error('Tag was not added within the expected time frame.'); - } - await personalFiles.page.waitForTimeout(1000); - retries++; - } - } - test('[C299162] View properties - Default tabs', async ({ personalFiles }) => { await navigateAndOpenInfoDrawer(personalFiles, FolderC299162); expect(await personalFiles.infoDrawer.getHeaderTitle()).toEqual(FolderC299162); @@ -186,10 +174,6 @@ test.describe('Info Drawer - File Folder Properties', () => { await personalFiles.infoDrawer.tagsAccordionConfirmButton.click(); await expect(personalFiles.infoDrawer.tagsChipsXButton.first()).toBeHidden(); await expect(personalFiles.infoDrawer.tagsAccordionPenButton).toBeVisible(); - - await waitForTagToBeAdded(Folder17239Id, personalFiles, 10); - const tagId = (await tagsApi.listTagsForNode(Folder17239Id)).list.entries[0].entry.id; - await tagsApi.deleteTag(tagId); }); test('[XAT-17240] Remove a tag from a node', async ({ personalFiles }) => { diff --git a/e2e/playwright/search/src/tests/search-filters-tags.e2e.ts b/e2e/playwright/search/src/tests/search-filters-tags.e2e.ts index 77fd227939..b3a1c44b6d 100644 --- a/e2e/playwright/search/src/tests/search-filters-tags.e2e.ts +++ b/e2e/playwright/search/src/tests/search-filters-tags.e2e.ts @@ -70,8 +70,8 @@ test.describe('Search - Filters - Tags', () => { test.afterAll(async () => { await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed'); - await tagsApiAdmin.deleteTag(`${(tagEntries as TagPaging).list.entries[0].entry.id}`); - await tagsApiAdmin.deleteTag(`${(tagEntries as TagPaging).list.entries[1].entry.id}`); + await tagsApiAdmin.deleteTags([`${(tagEntries as TagPaging).list.entries[0].entry.id}`]); + await tagsApiAdmin.deleteTags([`${(tagEntries as TagPaging).list.entries[1].entry.id}`]); }); test('[C698515] Filter with Tags', async ({ searchPage }) => { diff --git a/projects/aca-playwright-shared/src/api/tags-api.ts b/projects/aca-playwright-shared/src/api/tags-api.ts index 57a896c8c8..bc66b8c474 100644 --- a/projects/aca-playwright-shared/src/api/tags-api.ts +++ b/projects/aca-playwright-shared/src/api/tags-api.ts @@ -56,9 +56,11 @@ export class TagsApi { } } - async deleteTag(tagId: string): Promise { + async deleteTags(tagIds: string[]): Promise { try { - return this.apiService.tagsApi.deleteTag(tagId); + for (const tagId of tagIds) { + await this.apiService.tagsApi.deleteTag(tagId); + } } catch (error) { console.error(error); } @@ -72,4 +74,23 @@ export class TagsApi { return null; } } + + async listTags(params?: { tag?: string; matching?: boolean }): Promise { + try { + return this.apiService.tagsApi.listTags(params); + } catch (error) { + console.error(error); + return null; + } + } + + async deleteTagsByTagName(tagName: string): Promise { + try { + const response = await this.listTags({ tag: tagName, matching: true }); + const tagIds = response.list.entries.map((entry) => entry.entry.id); + await this.deleteTags(tagIds); + } catch (error) { + console.error(error); + } + } }