Skip to content

Commit

Permalink
[ACS-8951] [E2E] tags and categories e2es added in ACA
Browse files Browse the repository at this point in the history
  • Loading branch information
datguychen committed Oct 30, 2024
1 parent d25c08a commit 4462619
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 20 deletions.
177 changes: 157 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 @@ -23,13 +23,49 @@
*/

import { expect } from '@playwright/test';
import { ApiClientFactory, Utils, test, TrashcanApi, NodesApi, FileActionsApi } from '@alfresco/aca-playwright-shared';
import {
ApiClientFactory,
Utils,
test,
TrashcanApi,
NodesApi,
FileActionsApi,
TagsApi,
CategoriesApi,
PersonalFilesPage
} from '@alfresco/aca-playwright-shared';

test.describe('Info Drawer - File Folder Properties', () => {
let nodesApi: NodesApi;
let trashcanApi: TrashcanApi;
let fileActionsApi: FileActionsApi;
let tagsApi: TagsApi;
let categoriesApi: CategoriesApi;
let responseCategoryId: string;
const username = `user-e2e-${Utils.random()}`;
const tagName = 'e2etag';
const FolderC299162 = `C299162-e2e-${Utils.random()}`;
const FolderC599174 = `C599174-e2e-${Utils.random()}`;
const Folder17238 = `xat-17238-e2e-${Utils.random()}`;
const Folder17239 = `xat-17239-e2e-${Utils.random()}`;
const Folder17240 = `xat-17240-e2e-${Utils.random()}`;
const Folder17241 = `xat-17241-e2e-${Utils.random()}`;
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 categoryId2 = `-root-`;
const categoryName = Utils.random();

async function createCategoryGetId() {
const requestData = await categoriesApi.createCategory(categoryId2, [{ name: categoryName }]);
if ('entry' in requestData) {
return requestData.entry.id;
} else {
console.error('Unexpected response format:', requestData);
return null;
}
}

test.beforeAll(async () => {
try {
Expand All @@ -39,6 +75,9 @@ test.describe('Info Drawer - File Folder Properties', () => {
nodesApi = await NodesApi.initialize(username, username);
trashcanApi = await TrashcanApi.initialize(username, username);
fileActionsApi = await FileActionsApi.initialize(username, username);
tagsApi = await TagsApi.initialize('admin');
categoriesApi = await CategoriesApi.initialize('admin');
responseCategoryId = await createCategoryGetId();
} catch (error) {
console.error(`beforeAll failed : ${error}`);
}
Expand All @@ -50,41 +89,139 @@ test.describe('Info Drawer - File Folder Properties', () => {

test.afterAll(async () => {
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed');
await categoriesApi.deleteCategory(responseCategoryId);
});

test('[C299162] View properties - Default tabs', async ({ personalFiles }) => {
const defaultTabsFolderName = `defaultTabsFolder-e2e-${Utils.random()}`;
await nodesApi.createFolder(defaultTabsFolderName);
await fileActionsApi.waitForNodes(defaultTabsFolderName, { expect: 1 });
async function setupFolderAndNavigate(personalFiles: PersonalFilesPage, folderName: string) {
await nodesApi.createFolder(folderName);
await fileActionsApi.waitForNodes(folderName, { expect: 1 });
await personalFiles.navigate();
await Utils.reloadPageIfRowNotVisible(personalFiles, defaultTabsFolderName);
await expect(personalFiles.dataTable.getRowByName(defaultTabsFolderName)).toBeVisible();
await personalFiles.dataTable.getRowByName(defaultTabsFolderName).click();
await Utils.reloadPageIfRowNotVisible(personalFiles, folderName);
await expect(personalFiles.dataTable.getRowByName(folderName)).toBeVisible();
await personalFiles.dataTable.getRowByName(folderName).click();
await personalFiles.acaHeader.viewDetails.click();
}

expect(await personalFiles.infoDrawer.getHeaderTitle()).toEqual(defaultTabsFolderName);
test('[C299162] View properties - Default tabs', async ({ personalFiles }) => {
await setupFolderAndNavigate(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 }) => {
const expandDetailsFolderName = `expandDetailsFolder-e2e-${Utils.random()}`;
await nodesApi.createFolder(expandDetailsFolderName);
await fileActionsApi.waitForNodes(expandDetailsFolderName, { expect: 1 });
await personalFiles.navigate();
await Utils.reloadPageIfRowNotVisible(personalFiles, expandDetailsFolderName);
await expect(personalFiles.dataTable.getRowByName(expandDetailsFolderName)).toBeVisible();
await personalFiles.dataTable.getRowByName(expandDetailsFolderName).click();
await personalFiles.acaHeader.viewDetails.click();

await setupFolderAndNavigate(personalFiles, FolderC599174);
await personalFiles.infoDrawer.expandDetailsButton.click();
await expect(personalFiles.infoDrawer.expandedDetailsPermissionsTab).toBeVisible();

await personalFiles.navigate();
await expect(personalFiles.dataTable.getRowByName(expandDetailsFolderName)).toBeVisible();
await personalFiles.dataTable.getRowByName(expandDetailsFolderName).click({ button: 'right' });
await expect(personalFiles.dataTable.getRowByName(FolderC599174)).toBeVisible();
await personalFiles.dataTable.getRowByName(FolderC599174).click({ button: 'right' });
await personalFiles.pagination.clickMenuItem('Permissions');
await expect(personalFiles.infoDrawer.expandedDetailsPermissionsTab).toBeVisible();
});

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

await personalFiles.infoDrawer.categoriesAccordion.click();
await expect(personalFiles.infoDrawer.categoriesAccordion).toContainText('There are currently no categories added');
});

test('[XAT-17239] Add a new tag to a node', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, Folder17239);
await personalFiles.infoDrawer.tagsAccordionPenButton.click();
await expect(personalFiles.infoDrawer.tagsAccordionPenButton).toBeHidden();
await expect(personalFiles.infoDrawer.tagsAccordionCancelButton).toBeEnabled();
await expect(personalFiles.infoDrawer.tagsAccordionConfirmButton).toBeDisabled();
await personalFiles.infoDrawer.tagsInput.fill(tagName);
await personalFiles.infoDrawer.createTagButton.click();
await expect(personalFiles.infoDrawer.tagsChips.first()).toContainText(tagName);
await expect(personalFiles.infoDrawer.tagsChipsXButton.first()).toBeVisible();
await personalFiles.infoDrawer.tagsAccordionConfirmButton.click();
await expect(personalFiles.infoDrawer.tagsChipsXButton.first()).toBeHidden();
await expect(personalFiles.infoDrawer.tagsAccordionPenButton).toBeVisible();
});

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.createTags([tagBody]);
await tagsApi.assignTagToNode(Folder17240Id, tagBody);
await personalFiles.navigate();
await Utils.reloadPageIfRowNotVisible(personalFiles, Folder17240);
await expect(personalFiles.dataTable.getRowByName(Folder17240)).toBeVisible();
await personalFiles.dataTable.getRowByName(Folder17240).click();
await personalFiles.acaHeader.viewDetails.click();

await personalFiles.infoDrawer.tagsAccordion.click();
await expect(personalFiles.infoDrawer.tagsChipsXButton.first()).toBeHidden();
await personalFiles.infoDrawer.tagsAccordionPenButton.click();
await personalFiles.infoDrawer.tagsChipsXButton.first().click();
await personalFiles.infoDrawer.tagsAccordionConfirmButton.click();
await expect(personalFiles.infoDrawer.tagsChips.first()).toBeHidden();
await expect(personalFiles.infoDrawer.tagsAccordion).toContainText('There are currently no tags added');
});

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);
await expect(personalFiles.dataTable.getRowByName(Folder17243)).toBeVisible();
await personalFiles.dataTable.getRowByName(Folder17243).click();
await personalFiles.acaHeader.viewDetails.click();

await personalFiles.infoDrawer.tagsAccordionPenButton.click();
await personalFiles.infoDrawer.tagsInput.fill(tagName);
await personalFiles.infoDrawer.tagsAccordionCancelButton.click();
await expect(personalFiles.infoDrawer.tagsAccordionPenButton).toBeVisible();
await expect(personalFiles.infoDrawer.tagsAccordion).toContainText('There are currently no tags added');
});

test('[XAT-17241] Add a new category to a node', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, Folder17241);
await personalFiles.infoDrawer.categoriesAccordionPenButton.click();
await expect(personalFiles.infoDrawer.categoriesAccordionPenButton).toBeHidden();
await expect(personalFiles.infoDrawer.categoriesAccordionCancelButton).toBeEnabled();
await expect(personalFiles.infoDrawer.categoriesAccordionConfirmButton).toBeDisabled();
await personalFiles.infoDrawer.categoriesInput.fill('*');
await personalFiles.infoDrawer.categoriesListItems.first().click();
await expect(personalFiles.infoDrawer.categoriesItemRemoveButton.first()).toBeVisible();
await personalFiles.infoDrawer.categoriesAccordionConfirmButton.click();
await expect(personalFiles.infoDrawer.tagsChipsXButton.first()).toBeHidden();
await expect(personalFiles.infoDrawer.tagsAccordionPenButton).toBeVisible();
await expect(personalFiles.infoDrawer.categoriesAccordion).not.toContainText('There are currently no categories added');
await expect(personalFiles.infoDrawer.categoriesCreatedList.first()).toBeVisible();
});

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();
await Utils.reloadPageIfRowNotVisible(personalFiles, Folder17242);
await expect(personalFiles.dataTable.getRowByName(Folder17242)).toBeVisible();
await personalFiles.dataTable.getRowByName(Folder17242).click();
await personalFiles.acaHeader.viewDetails.click();

await personalFiles.infoDrawer.categoriesAccordion.click();
await expect(personalFiles.infoDrawer.categoriesAccordion).not.toContainText('There are currently no categories added');
await personalFiles.infoDrawer.categoriesAccordionPenButton.click();
await personalFiles.infoDrawer.categoriesItemRemoveButton.first().click();
await personalFiles.infoDrawer.categoriesAccordionConfirmButton.click();
await expect(personalFiles.infoDrawer.categoriesAccordion).toContainText('There are currently no categories added');
});

test('[XAT-17243] Cancel adding a category to a node', async ({ personalFiles }) => {
await setupFolderAndNavigate(personalFiles, Folder17244);
await personalFiles.infoDrawer.categoriesAccordionPenButton.click();
await personalFiles.infoDrawer.categoriesInput.fill('*');
await personalFiles.infoDrawer.categoriesListItems.first().click();
await personalFiles.infoDrawer.categoriesAccordionCancelButton.click();
await expect(personalFiles.infoDrawer.categoriesAccordion).toContainText('There are currently no categories added');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ export class AdfInfoDrawerComponent extends BaseComponent {
public descriptionField = this.page.locator('textarea[placeholder=Description]');
public visibilityField = this.infoDrawerPanel.getByRole('combobox');
public selectVisibility = (visibilityOption: string) => this.page.getByRole('listbox').getByRole('option', { name: visibilityOption }).click();
public tagsAccordion = this.getChild('[data-automation-id="adf-content-metadata-tags-panel"]');
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 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');
public tagsChipsXButton = this.tagsChips.locator('button');
public tagsAccordionCancelButton = this.getChild('[data-automation-id="reset-tags-metadata"]');
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 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"]');
public categoriesCreatedList = this.getChild('.adf-metadata-categories');

async checkCommentsHeaderCount(): Promise<number> {
const commentsCountTextContent = await this.commentsHeader.textContent();
Expand Down

0 comments on commit 4462619

Please sign in to comment.