Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-8951] [E2E] tags and categories e2es added in ACA #4210

Merged
merged 9 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 199 additions & 20 deletions e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!

Check failure on line 1 in e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts

View workflow job for this annotation

GitHub Actions / E2E Playwright - info-drawer

[Info Drawer] › src/tests/file-folder-properties.e2e.ts:228:7 › Info Drawer - File Folder Properties › [XAT-17241] Add a new category to a node

2) [Info Drawer] › src/tests/file-folder-properties.e2e.ts:228:7 › Info Drawer - File Folder Properties › [XAT-17241] Add a new category to a node Test timeout of 85000ms exceeded.

Check failure on line 1 in e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts

View workflow job for this annotation

GitHub Actions / E2E Playwright - info-drawer

[Info Drawer] › src/tests/file-folder-properties.e2e.ts:228:7 › Info Drawer - File Folder Properties › [XAT-17241] Add a new category to a node

2) [Info Drawer] › src/tests/file-folder-properties.e2e.ts:228:7 › Info Drawer - File Folder Properties › [XAT-17241] Add a new category to a node Error: {"error":{"errorKey":"framework.exception.EntityNotFound","statusCode":404,"briefSummary":"10052585 The entity with id: 326cacec-1e6e-41d6-acac-ec1e6e61d6d9 was not found","stackTrace":"For security reasons the stack trace is no longer displayed, but the property is kept for previous versions","descriptionURL":"https://api-explorer.alfresco.com","logId":"1d121efd-31d6-4561-921e-fd31d6f561c7"}} at Request.callback (/home/runner/work/alfresco-content-app/alfresco-content-app/node_modules/superagent/src/node/index.js:875:17) at fn (/home/runner/work/alfresco-content-app/alfresco-content-app/node_modules/superagent/src/node/index.js:1165:18) at IncomingMessage.<anonymous> (/home/runner/work/alfresco-content-app/alfresco-content-app/node_modules/superagent/src/node/parsers/json.js:19:7)
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
Expand All @@ -23,13 +23,64 @@
*/

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;
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()}`;
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 categoryName = Utils.random();
const noCategoriesText = 'There are currently no categories added';
const noTagsText = 'There are currently no tags added';

async function createCategoryGetId(): Promise<string> {
const createdCategory = await categoriesApi.createCategory(`-root-`, [{ name: categoryName }]);
if ('entry' in createdCategory) {
return createdCategory.entry.id;
} else {
console.error('Unexpected response format:', createdCategory);
return null;
}
}

async function createTagGetId(): Promise<string> {
const createdTag = await tagsApi.createTags([tagBody]);
if ('entry' in createdTag) {
return (createdTag as { entry: { id: string } }).entry.id;
} else {
console.error('Unexpected response format:', createdTag);
return null;
}
}

test.beforeAll(async () => {
try {
Expand All @@ -39,6 +90,24 @@
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();
responseTagsId = await createTagGetId();

if (responseCategoryId === null || responseTagsId === null) {
throw new Error('Failed to create category or tag - check API manually');
}

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 @@ -50,41 +119,151 @@

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responseCategoryId might be null if error will happen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, please check if properly.

await tagsApi.deleteTag(responseTagsId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responseTagsId may be null as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, please check if properly.

});

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 navigateAndOpenInfoDrawer(personalFiles: PersonalFilesPage, folderName: string) {
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();

Check failure on line 130 in e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts

View workflow job for this annotation

GitHub Actions / E2E Playwright - info-drawer

[Info Drawer] › src/tests/file-folder-properties.e2e.ts:228:7 › Info Drawer - File Folder Properties › [XAT-17241] Add a new category to a node

2) [Info Drawer] › src/tests/file-folder-properties.e2e.ts:228:7 › Info Drawer - File Folder Properties › [XAT-17241] Add a new category to a node Error: expect.toBeVisible: Target page, context or browser has been closed 128 | await personalFiles.navigate(); 129 | await Utils.reloadPageIfRowNotVisible(personalFiles, folderName); > 130 | await expect(personalFiles.dataTable.getRowByName(folderName)).toBeVisible(); | ^ 131 | await personalFiles.dataTable.getRowByName(folderName).click(); 132 | await personalFiles.acaHeader.viewDetails.click(); 133 | } at navigateAndOpenInfoDrawer (/home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts:130:68) at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/info-drawer/src/tests/file-folder-properties.e2e.ts:229:5
await personalFiles.dataTable.getRowByName(folderName).click();
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++;
}
}

expect(await personalFiles.infoDrawer.getHeaderTitle()).toEqual(defaultTabsFolderName);
test('[C299162] View properties - Default tabs', async ({ personalFiles }) => {
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 }) => {
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 navigateAndOpenInfoDrawer(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 navigateAndOpenInfoDrawer(personalFiles, Folder17238);
await personalFiles.infoDrawer.tagsAccordion.click();
await expect(personalFiles.infoDrawer.tagsAccordion).toContainText(noTagsText);

await personalFiles.infoDrawer.categoriesAccordion.click();
await expect(personalFiles.infoDrawer.categoriesAccordion).toContainText(noCategoriesText);
});

test('[XAT-17239] Add a new tag to a node', async ({ personalFiles }) => {
await navigateAndOpenInfoDrawer(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(manualTagName);
await personalFiles.infoDrawer.createTagButton.click();
await expect(personalFiles.infoDrawer.tagsChips.first()).toContainText(manualTagName);
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();

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 }) => {
await fileActionsApi.waitForNodes(Folder17240, { expect: 1 });
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(noTagsText);
});

test('[XAT-17243] Cancel adding a tag to a node', async ({ personalFiles }) => {
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(manualTagName);
await personalFiles.infoDrawer.tagsAccordionCancelButton.click();
await expect(personalFiles.infoDrawer.tagsAccordionPenButton).toBeVisible();
await expect(personalFiles.infoDrawer.tagsAccordion).toContainText(noTagsText);
});

test('[XAT-17241] Add a new category to a node', async ({ personalFiles }) => {
await navigateAndOpenInfoDrawer(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(noCategoriesText);
await expect(personalFiles.infoDrawer.categoriesCreatedList.first()).toBeVisible();
});

test('[XAT-17242] Remove a category from a node', async ({ personalFiles }) => {
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(noCategoriesText);
await personalFiles.infoDrawer.categoriesAccordionPenButton.click();
await personalFiles.infoDrawer.categoriesItemRemoveButton.first().click();
await personalFiles.infoDrawer.categoriesAccordionConfirmButton.click();
await expect(personalFiles.infoDrawer.categoriesAccordion).toContainText(noCategoriesText);
});

test('[XAT-17244] Cancel adding a category to a node', async ({ personalFiles }) => {
await navigateAndOpenInfoDrawer(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(noCategoriesText);
});
});
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 @@ -63,6 +66,22 @@ 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"]');
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"]');
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
Loading