Skip to content

Commit

Permalink
[ACS-8981] [E2E] added deleteTagsByTagName method for TagsApiin ACA (#…
Browse files Browse the repository at this point in the history
…4226)

* [ACS-8981] [E2E] added deleteTagsByTagName method for TagsApiin ACA

* [ACS-8981] fixed C698515
  • Loading branch information
datguychen authored Nov 7, 2024
1 parent 64e3419 commit 8d78a40
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
24 changes: 4 additions & 20 deletions e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
Expand All @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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 }) => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/playwright/search/src/tests/search-filters-tags.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
25 changes: 23 additions & 2 deletions projects/aca-playwright-shared/src/api/tags-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ export class TagsApi {
}
}

async deleteTag(tagId: string): Promise<void> {
async deleteTags(tagIds: string[]): Promise<void> {
try {
return this.apiService.tagsApi.deleteTag(tagId);
for (const tagId of tagIds) {
await this.apiService.tagsApi.deleteTag(tagId);
}
} catch (error) {
console.error(error);
}
Expand All @@ -72,4 +74,23 @@ export class TagsApi {
return null;
}
}

async listTags(params?: { tag?: string; matching?: boolean }): Promise<TagPaging> {
try {
return this.apiService.tagsApi.listTags(params);
} catch (error) {
console.error(error);
return null;
}
}

async deleteTagsByTagName(tagName: string): Promise<void> {
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);
}
}
}

0 comments on commit 8d78a40

Please sign in to comment.