Skip to content

Commit

Permalink
[ACS-8951] review fix 2
Browse files Browse the repository at this point in the history
  • Loading branch information
datguychen committed Nov 5, 2024
1 parent 49abaaf commit 516e6df
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 14 deletions.
47 changes: 36 additions & 11 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,6 +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 username = `user-e2e-${Utils.random()}`;
const manualTagName = `e2e-tag-${Utils.random()}`;
const FolderC299162 = `C299162-e2e-${Utils.random()}`;
Expand Down Expand Up @@ -91,6 +94,16 @@ test.describe('Info Drawer - File Folder Properties', () => {
categoriesApi = await CategoriesApi.initialize('admin');
responseCategoryId = await createCategoryGetId();
responseTagsId = await createTagGetId();

await nodesApi.createFolder(FolderC299162);
await nodesApi.createFolder(FolderC599174);
await nodesApi.createFolder(Folder17238);
Folder17239Id = (await nodesApi.createFolder(Folder17239)).entry.id;
Folder17240Id = (await nodesApi.createFolder(Folder17240)).entry.id;
await nodesApi.createFolder(Folder17241);
Folder17242Id = (await nodesApi.createFolder(Folder17242)).entry.id;
await nodesApi.createFolder(Folder17243);
await nodesApi.createFolder(Folder17244);
} catch (error) {
console.error(`beforeAll failed : ${error}`);
}
Expand All @@ -106,8 +119,7 @@ test.describe('Info Drawer - File Folder Properties', () => {
await tagsApi.deleteTag(responseTagsId);
});

async function setupFolderAndNavigate(personalFiles: PersonalFilesPage, folderName: string) {
await nodesApi.createFolder(folderName);
async function navigateAndOpenInfoDrawer(personalFiles: PersonalFilesPage, folderName: string) {
await fileActionsApi.waitForNodes(folderName, { expect: 1 });
await personalFiles.navigate();
await Utils.reloadPageIfRowNotVisible(personalFiles, folderName);
Expand All @@ -116,16 +128,28 @@ 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 setupFolderAndNavigate(personalFiles, FolderC299162);
await navigateAndOpenInfoDrawer(personalFiles, FolderC299162);
expect(await personalFiles.infoDrawer.getHeaderTitle()).toEqual(FolderC299162);
await expect(personalFiles.infoDrawer.propertiesTab).toBeVisible();
await expect(personalFiles.infoDrawer.commentsTab).toBeVisible();
expect(await personalFiles.infoDrawer.getTabsCount()).toEqual(2);
});

test('[C599174] View properties - Should be able to make the files/folders info drawer expandable as for Sites', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, FolderC599174);
await navigateAndOpenInfoDrawer(personalFiles, FolderC599174);
await personalFiles.infoDrawer.expandDetailsButton.click();
await expect(personalFiles.infoDrawer.expandedDetailsPermissionsTab).toBeVisible();

Expand All @@ -137,7 +161,7 @@ test.describe('Info Drawer - File Folder Properties', () => {
});

test('[XAT-17238] State for no tags and categories - accordion expanded', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, Folder17238);
await navigateAndOpenInfoDrawer(personalFiles, Folder17238);
await personalFiles.infoDrawer.tagsAccordion.click();
await expect(personalFiles.infoDrawer.tagsAccordion).toContainText(noTagsText);

Expand All @@ -146,7 +170,7 @@ test.describe('Info Drawer - File Folder Properties', () => {
});

test('[XAT-17239] Add a new tag to a node', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, Folder17239);
await navigateAndOpenInfoDrawer(personalFiles, Folder17239);
await personalFiles.infoDrawer.tagsAccordionPenButton.click();
await expect(personalFiles.infoDrawer.tagsAccordionPenButton).toBeHidden();
await expect(personalFiles.infoDrawer.tagsAccordionCancelButton).toBeEnabled();
Expand All @@ -158,10 +182,13 @@ 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 }) => {
const Folder17240Id = (await nodesApi.createFolder(Folder17240)).entry.id;
await fileActionsApi.waitForNodes(Folder17240, { expect: 1 });
await tagsApi.assignTagToNode(Folder17240Id, tagBody);
await personalFiles.navigate();
Expand All @@ -180,7 +207,6 @@ test.describe('Info Drawer - File Folder Properties', () => {
});

test('[XAT-17243] Cancel adding a tag to a node', async ({ personalFiles }) => {
await nodesApi.createFolder(Folder17243);
await fileActionsApi.waitForNodes(Folder17243, { expect: 1 });
await personalFiles.navigate();
await Utils.reloadPageIfRowNotVisible(personalFiles, Folder17243);
Expand All @@ -196,7 +222,7 @@ test.describe('Info Drawer - File Folder Properties', () => {
});

test('[XAT-17241] Add a new category to a node', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, Folder17241);
await navigateAndOpenInfoDrawer(personalFiles, Folder17241);
await personalFiles.infoDrawer.categoriesAccordionPenButton.click();
await expect(personalFiles.infoDrawer.categoriesAccordionPenButton).toBeHidden();
await expect(personalFiles.infoDrawer.categoriesAccordionCancelButton).toBeEnabled();
Expand All @@ -212,7 +238,6 @@ test.describe('Info Drawer - File Folder Properties', () => {
});

test('[XAT-17242] Remove a category from a node', async ({ personalFiles }) => {
const Folder17242Id = (await nodesApi.createFolder(Folder17242)).entry.id;
await fileActionsApi.waitForNodes(Folder17242, { expect: 1 });
await categoriesApi.linkNodeToCategory(Folder17242Id, [{ categoryId: responseCategoryId }]);
await personalFiles.navigate();
Expand All @@ -230,7 +255,7 @@ test.describe('Info Drawer - File Folder Properties', () => {
});

test('[XAT-17244] Cancel adding a category to a node', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, Folder17244);
await navigateAndOpenInfoDrawer(personalFiles, Folder17244);
await personalFiles.infoDrawer.categoriesAccordionPenButton.click();
await personalFiles.infoDrawer.categoriesInput.fill('*');
await personalFiles.infoDrawer.categoriesListItems.first().click();
Expand Down
11 changes: 10 additions & 1 deletion projects/aca-playwright-shared/src/api/tags-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { TagBody, TagEntry } from '@alfresco/js-api';
import { TagBody, TagEntry, TagPaging } from '@alfresco/js-api';
import { ApiClientFactory } from './api-client-factory';

export class TagsApi {
Expand Down Expand Up @@ -63,4 +63,13 @@ export class TagsApi {
console.error(error);
}
}

async listTagsForNode(nodeId: string): Promise<TagPaging> {
try {
return this.apiService.tagsApi.listTagsForNode(nodeId);
} catch (error) {
console.error(error);
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export class AdfInfoDrawerComponent extends BaseComponent {
super(page, AdfInfoDrawerComponent.rootElement);
}

private readonly categoriesManagement = this.getChild('adf-categories-management');
private readonly tagsCreator = this.getChild('adf-tags-creator');

public getNameField = (labelText: string) =>
this.getChild(`[data-automation-id="library-name-properties-wrapper"] input[placeholder='${labelText}']`);
public getIdField = (labelText: string) => this.getChild(`[data-automation-id="library-id-properties-wrapper"] input[placeholder='${labelText}']`);
Expand Down Expand Up @@ -67,7 +70,6 @@ export class AdfInfoDrawerComponent extends BaseComponent {
public categoriesAccordion = this.getChild('[data-automation-id="adf-content-metadata-categories-panel"]');
public tagsAccordionPenButton = this.tagsAccordion.locator('[data-automation-id="showing-tag-input-button"]');
public categoriesAccordionPenButton = this.categoriesAccordion.locator('[data-automation-id="meta-data-categories-edit"]');
private readonly tagsCreator = this.getChild('adf-tags-creator');
public tagsInput = this.tagsCreator.locator('input');
public createTagButton = this.tagsCreator.locator('[role="button"]');
public tagsChips = this.tagsCreator.locator('mat-chip');
Expand All @@ -76,7 +78,6 @@ export class AdfInfoDrawerComponent extends BaseComponent {
public tagsAccordionConfirmButton = this.getChild('[data-automation-id="save-tags-metadata"]');
public categoriesAccordionCancelButton = this.getChild('[data-automation-id="reset-metadata"]');
public categoriesAccordionConfirmButton = this.getChild('[data-automation-id="save-categories-metadata"]');
private readonly categoriesManagement = this.getChild('adf-categories-management');
public categoriesInput = this.categoriesManagement.locator('input');
public categoriesListItems = this.categoriesManagement.locator('mat-list-item');
public categoriesItemRemoveButton = this.categoriesManagement.locator('[data-automation-id="categories-remove-category-button"]');
Expand Down

0 comments on commit 516e6df

Please sign in to comment.