mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5923] navigation breadcrumb playwright test (#3410)
* ACS-5870-playwright test for application * fix for failing test * fix for failing test * fix for login secario test * fix for login test with newuser login * [ACS-5923] playwright breadcrumb test * Update breadcrumb.spec.ts * test fix * test fix admin * test fix admin * test fix user folder * test fix user test remove
This commit is contained in:
@@ -29,3 +29,5 @@ export * from './shared-links-api';
|
||||
export * from './favorites-api';
|
||||
export * from './user-actions';
|
||||
export * from './people-api-models';
|
||||
export * from './nodes-api';
|
||||
export * from './sites-api';
|
||||
|
123
projects/aca-playwright-shared/src/api/nodes-api.ts
Executable file
123
projects/aca-playwright-shared/src/api/nodes-api.ts
Executable file
@@ -0,0 +1,123 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { users } from '../base-config/global-variables';
|
||||
import { logger } from '@alfresco/adf-cli/scripts/logger';
|
||||
|
||||
export class NodesApi extends ApiClientFactory {
|
||||
private apiService: ApiClientFactory;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.apiService = new ApiClientFactory();
|
||||
}
|
||||
static async initialize(userProfile: keyof typeof users): Promise<NodesApi> {
|
||||
const classObj = new NodesApi();
|
||||
await classObj.apiService.setUpAcaBackend(userProfile);
|
||||
return classObj;
|
||||
}
|
||||
|
||||
async createFolder(
|
||||
name: string,
|
||||
parentId: string = '-my-',
|
||||
title: string = '',
|
||||
description: string = '',
|
||||
author: string = '',
|
||||
aspectNames: string[] = null
|
||||
): Promise<NodeEntry | null> {
|
||||
try {
|
||||
return await this.createNode('cm:folder', name, parentId, title, description, null, author, null, aspectNames);
|
||||
} catch (error) {
|
||||
logger.error(`${this.constructor.name} ${this.createFolder.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createFile(
|
||||
name: string,
|
||||
parentId: string = '-my-',
|
||||
title: string = '',
|
||||
description: string = '',
|
||||
author: string = '',
|
||||
majorVersion: boolean = true,
|
||||
aspectNames: string[] = null
|
||||
): Promise<NodeEntry> {
|
||||
try {
|
||||
return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion, aspectNames);
|
||||
} catch (error) {
|
||||
logger.error(`${this.constructor.name} ${this.createFile.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async createNode(
|
||||
nodeType: string,
|
||||
name: string,
|
||||
parentId: string = '-my-',
|
||||
title: string = '',
|
||||
description: string = '',
|
||||
imageProps: any = null,
|
||||
author: string = '',
|
||||
majorVersion: boolean = true,
|
||||
aspectNames: string[] = null
|
||||
): Promise<NodeEntry | null> {
|
||||
if (!aspectNames) {
|
||||
aspectNames = ['cm:versionable']; // workaround for REPO-4772
|
||||
}
|
||||
const nodeBody = {
|
||||
name,
|
||||
nodeType,
|
||||
relativePath: '/',
|
||||
properties: {
|
||||
'cm:title': title,
|
||||
'cm:description': description,
|
||||
'cm:author': author
|
||||
},
|
||||
aspectNames
|
||||
};
|
||||
if (imageProps) {
|
||||
nodeBody.properties = Object.assign(nodeBody.properties, imageProps);
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.apiService.nodes.createNode(parentId, nodeBody, {
|
||||
majorVersion
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(`${this.constructor.name} ${this.createNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async renameNode(nodeId: string, newName: string): Promise<NodeEntry | null> {
|
||||
try {
|
||||
return this.apiService.nodes.updateNode(nodeId, { name: newName });
|
||||
} catch (error) {
|
||||
logger.error(`${this.constructor.name} ${this.renameNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
68
projects/aca-playwright-shared/src/api/sites-api.ts
Executable file
68
projects/aca-playwright-shared/src/api/sites-api.ts
Executable file
@@ -0,0 +1,68 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { SiteBody, SiteEntry } from '@alfresco/js-api';
|
||||
import { users } from '../base-config/global-variables';
|
||||
import { logger } from '@alfresco/adf-cli/scripts/logger';
|
||||
import { SITE_VISIBILITY } from '../utils/configs';
|
||||
|
||||
export class SitesApi extends ApiClientFactory {
|
||||
private apiService: ApiClientFactory;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.apiService = new ApiClientFactory();
|
||||
}
|
||||
static async initialize(userProfile: keyof typeof users): Promise<SitesApi> {
|
||||
const classObj = new SitesApi();
|
||||
await classObj.apiService.setUpAcaBackend(userProfile);
|
||||
return classObj;
|
||||
}
|
||||
|
||||
async createSite(title: string, visibility?: string, description?: string, siteId?: string): Promise<SiteEntry | null> {
|
||||
const site = {
|
||||
title,
|
||||
visibility: visibility || SITE_VISIBILITY.PUBLIC,
|
||||
description: description,
|
||||
id: siteId || title
|
||||
} as SiteBody;
|
||||
|
||||
try {
|
||||
return await this.apiService.sites.createSite(site);
|
||||
} catch (error) {
|
||||
logger.error(`SitesApi createSite : catch : `, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getDocLibId(siteId: string): Promise<string> {
|
||||
try {
|
||||
return (await this.apiService.sites.listSiteContainers(siteId)).list.entries[0].entry.id;
|
||||
} catch (error) {
|
||||
logger.error(`SitesApi getDocLibId : catch : `, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,7 +36,9 @@ import {
|
||||
FavoritesPageApi,
|
||||
TrashPage,
|
||||
UserActions,
|
||||
LoginPage
|
||||
LoginPage,
|
||||
NodesApi,
|
||||
SitesApi
|
||||
} from '../';
|
||||
|
||||
interface Pages {
|
||||
@@ -56,6 +58,8 @@ interface Api {
|
||||
shareAction: SharedLinksApi;
|
||||
favoritesPageAction: FavoritesPageApi;
|
||||
userActions: UserActions;
|
||||
nodesApiAction: NodesApi;
|
||||
sitesApiAction: SitesApi;
|
||||
}
|
||||
|
||||
export const test = base.extend<Pages & Api>({
|
||||
@@ -99,6 +103,14 @@ export const test = base.extend<Pages & Api>({
|
||||
userActions: async ({}, use) => {
|
||||
await use(new UserActions());
|
||||
},
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
nodesApiAction: async ({}, use) => {
|
||||
await use(await NodesApi.initialize('hruser'));
|
||||
},
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
sitesApiAction: async ({}, use) => {
|
||||
await use(await SitesApi.initialize('hruser'));
|
||||
},
|
||||
myLibrariesPage: async ({ page }, use) => {
|
||||
await use(new MyLibrariesPage(page));
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { BaseComponent } from '.././base.component';
|
||||
import { Page } from '@playwright/test';
|
||||
export class Breadcrumb extends BaseComponent {
|
||||
private static rootElement = 'adf-breadcrumb';
|
||||
public items = this.getChild('.adf-breadcrumb-item');
|
||||
public currentItem = this.getChild('.adf-breadcrumb-item-current');
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page, Breadcrumb.rootElement);
|
||||
}
|
||||
|
||||
async getAllItems(): Promise<string[]> {
|
||||
const itemElements = await this.page.$$('adf-breadcrumb .adf-breadcrumb-item');
|
||||
const itemTexts = await Promise.all(
|
||||
itemElements.map(async (elem) => {
|
||||
const text = await elem.innerText();
|
||||
return text.split('\nchevron_right')[0];
|
||||
})
|
||||
);
|
||||
return itemTexts;
|
||||
}
|
||||
|
||||
async clickItem(name: string): Promise<void> {
|
||||
const elem = this.getChild(`.adf-breadcrumb-item[title=${name}]`);
|
||||
await elem.click();
|
||||
}
|
||||
}
|
@@ -35,3 +35,4 @@ export * from './adf-info-drawer.component';
|
||||
export * from './viewer.component';
|
||||
export * from './search/search-input.component';
|
||||
export * from './search/search-overlay.components';
|
||||
export * from './breadcrumb/breadcrumb.component';
|
||||
|
@@ -32,7 +32,8 @@ import {
|
||||
MatMenuComponent,
|
||||
ViewerComponent,
|
||||
ViewerOverlayDialogComponent,
|
||||
ContentNodeSelectorDialog
|
||||
ContentNodeSelectorDialog,
|
||||
Breadcrumb
|
||||
} from '../components';
|
||||
|
||||
export class MyLibrariesPage extends BasePage {
|
||||
@@ -49,6 +50,7 @@ export class MyLibrariesPage extends BasePage {
|
||||
public viewer = new ViewerComponent(this.page);
|
||||
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
|
||||
public copyMoveDialog = new ContentNodeSelectorDialog(this.page);
|
||||
public breadcrumb = new Breadcrumb(this.page);
|
||||
|
||||
async selectCreateLibrary(): Promise<void> {
|
||||
await this.acaHeader.createButton.click();
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
import { Page } from '@playwright/test';
|
||||
import { BasePage } from './base.page';
|
||||
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
|
||||
import { Breadcrumb, DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
|
||||
import { AcaHeader } from '../components/aca-header.component';
|
||||
import { AdfFolderDialogComponent, PasswordOverlayDialogComponent, ViewerOverlayDialogComponent } from '../components/dialogs';
|
||||
|
||||
@@ -42,6 +42,7 @@ export class PersonalFilesPage extends BasePage {
|
||||
public viewer = new ViewerComponent(this.page);
|
||||
public passwordDialog = new PasswordOverlayDialogComponent(this.page);
|
||||
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
|
||||
public breadcrumb = new Breadcrumb(this.page);
|
||||
|
||||
async selectCreateFolder(): Promise<void> {
|
||||
await this.acaHeader.createButton.click();
|
||||
|
29
projects/aca-playwright-shared/src/utils/configs.ts
Executable file
29
projects/aca-playwright-shared/src/utils/configs.ts
Executable file
@@ -0,0 +1,29 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export const SITE_VISIBILITY = {
|
||||
PUBLIC: 'PUBLIC',
|
||||
MODERATED: 'MODERATED',
|
||||
PRIVATE: 'PRIVATE'
|
||||
};
|
@@ -29,3 +29,4 @@ export * from './state-helper';
|
||||
export * from './folder-errors';
|
||||
export * from './utils';
|
||||
export * from './library-errors';
|
||||
export * from './configs';
|
||||
|
Reference in New Issue
Block a user