[ACS-5585] add direct api-client-factory call in tests (#3323)

This commit is contained in:
Adam Zakrzewski
2023-07-10 16:12:51 +02:00
committed by GitHub
parent e0e4dec218
commit f54ba92f77
7 changed files with 32 additions and 34 deletions

View File

@@ -35,7 +35,7 @@ const config: PlaywrightTestConfig<CustomConfig> = {
name: 'Folder Rules', name: 'Folder Rules',
testDir: './src/tests', testDir: './src/tests',
use: { use: {
users: ['admin'] users: ['hruser']
} }
} }
] ]

View File

@@ -23,10 +23,11 @@
*/ */
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
import { ActionType, getUserState, test } from '@alfresco/playwright-shared'; import { ActionType, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared';
test.use({ storageState: getUserState('admin') }); test.use({ storageState: getUserState('hruser') });
test.describe('Folder Rules Actions', () => { test.describe('Folder Rules Actions', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`; const randomFolderName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`;
const randomRuleName = `playwright-rule-${(Math.random() + 1).toString(36).substring(6)}`; const randomRuleName = `playwright-rule-${(Math.random() + 1).toString(36).substring(6)}`;
const checkInValue = 'check In Value'; const checkInValue = 'check In Value';
@@ -36,8 +37,9 @@ test.describe('Folder Rules Actions', () => {
let folderId: string; let folderId: string;
test.beforeAll(async ({ superAdminApiClient }) => { test.beforeAll(async () => {
const node = await superAdminApiClient.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder', relativePath: '/' }); await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder' });
folderId = node.entry.id; folderId = node.entry.id;
}); });
@@ -45,8 +47,8 @@ test.describe('Folder Rules Actions', () => {
await personalFiles.navigate({ waitUntil: 'domcontentloaded' }); await personalFiles.navigate({ waitUntil: 'domcontentloaded' });
}); });
test.afterAll(async ({ superAdminApiClient }) => { test.afterAll(async () => {
await superAdminApiClient.nodes.deleteNode(folderId); await apiClientFactory.nodes.deleteNode(folderId);
}); });
test('[C691637] Create a rule with actions', async ({ personalFiles, nodesPage }) => { test('[C691637] Create a rule with actions', async ({ personalFiles, nodesPage }) => {

View File

@@ -23,18 +23,20 @@
*/ */
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
import { ActionType, Comparator, Field, getUserState, test } from '@alfresco/playwright-shared'; import { ActionType, ApiClientFactory, Comparator, Field, getUserState, test } from '@alfresco/playwright-shared';
test.use({ storageState: getUserState('admin') }); test.use({ storageState: getUserState('hruser') });
test.describe('Folder Rules Conditions', () => { test.describe('Folder Rules Conditions', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`; const randomFolderName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`;
const randomRuleName = `playwright-rule-${(Math.random() + 1).toString(36).substring(6)}`; const randomRuleName = `playwright-rule-${(Math.random() + 1).toString(36).substring(6)}`;
const specialChars = '!@£$%^&*()~#/'; const specialChars = '!@£$%^&*()~#/';
let folderId: string; let folderId: string;
test.beforeAll(async ({ superAdminApiClient }) => { test.beforeAll(async () => {
const node = await superAdminApiClient.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder', relativePath: '/' }); await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder' });
folderId = node.entry.id; folderId = node.entry.id;
}); });
@@ -42,8 +44,8 @@ test.describe('Folder Rules Conditions', () => {
await personalFiles.navigate(); await personalFiles.navigate();
}); });
test.afterAll(async ({ superAdminApiClient }) => { test.afterAll(async () => {
await superAdminApiClient.nodes.deleteNode(folderId); await apiClientFactory.nodes.deleteNode(folderId);
}); });
test('[C691638] Create a rule with condition', async ({ personalFiles, nodesPage }) => { test('[C691638] Create a rule with condition', async ({ personalFiles, nodesPage }) => {

View File

@@ -22,27 +22,29 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { getUserState, test } from '@alfresco/playwright-shared'; import { ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared';
test.use({ storageState: getUserState('admin') }); test.use({ storageState: getUserState('hruser') });
test.describe('Rules - Manage Rules', () => { test.describe('Rules - Manage Rules', () => {
const apiClientFactory = new ApiClientFactory();
const randomName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`; const randomName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`;
const randomRuleName = `playwright-rule-${(Math.random() + 1).toString(36).substring(6)}`; const randomRuleName = `playwright-rule-${(Math.random() + 1).toString(36).substring(6)}`;
let folderId: string; let folderId: string;
test.beforeAll(async ({ superAdminApiClient }) => { test.beforeAll(async () => {
const node = await superAdminApiClient.nodes.createNode('-my-', { name: randomName, nodeType: 'cm:folder', relativePath: '/' }); await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomName, nodeType: 'cm:folder' });
folderId = node.entry.id; folderId = node.entry.id;
await superAdminApiClient.createRandomRule(folderId, randomRuleName); await apiClientFactory.createRandomRule(folderId, randomRuleName);
}); });
test.beforeEach(async ({ personalFiles }) => { test.beforeEach(async ({ personalFiles }) => {
await personalFiles.navigate(); await personalFiles.navigate();
}); });
test.afterAll(async ({ superAdminApiClient }) => { test.afterAll(async () => {
await superAdminApiClient.nodes.deleteNode(folderId); await apiClientFactory.nodes.deleteNode(folderId);
}); });
test('[C691651] Disable an existing rule', async ({ personalFiles, nodesPage }) => { test('[C691651] Disable an existing rule', async ({ personalFiles, nodesPage }) => {

View File

@@ -24,28 +24,18 @@
import { test as base } from '@playwright/test'; import { test as base } from '@playwright/test';
import { ApiClientFactory, NodesPage, PersonalFilesPage } from '../'; import { NodesPage, PersonalFilesPage } from '../';
interface Pages { interface Pages {
personalFiles: PersonalFilesPage; personalFiles: PersonalFilesPage;
nodesPage: NodesPage; nodesPage: NodesPage;
} }
interface Api { export const test = base.extend<Pages>({
superAdminApiClient: ApiClientFactory;
}
export const test = base.extend<Pages & Api>({
personalFiles: async ({ page }, use) => { personalFiles: async ({ page }, use) => {
await use(new PersonalFilesPage(page)); await use(new PersonalFilesPage(page));
}, },
nodesPage: async ({ page }, use) => { nodesPage: async ({ page }, use) => {
await use(new NodesPage(page)); await use(new NodesPage(page));
},
// eslint-disable-next-line no-empty-pattern
superAdminApiClient: async ({ }, use) => {
const apiClient = new ApiClientFactory();
await apiClient.setUpAcaBackend('admin');
await use(apiClient);
} }
}); });

View File

@@ -75,6 +75,7 @@ export class ActionsDropdownComponent extends BaseComponent {
await this.addActionButtonLocator.click(); await this.addActionButtonLocator.click();
} }
await this.actionDropdownLocator.nth(index).click(); await this.actionDropdownLocator.nth(index).click();
await this.spinnerWaitForReload();
const option = this.getOptionLocator(action); const option = this.getOptionLocator(action);
await option.click(); await option.click();
} }

View File

@@ -24,6 +24,7 @@
import { Locator, Page } from '@playwright/test'; import { Locator, Page } from '@playwright/test';
import { PlaywrightBase } from '../playwright-base'; import { PlaywrightBase } from '../playwright-base';
import { timeouts } from '../../utils';
export abstract class BaseComponent extends PlaywrightBase { export abstract class BaseComponent extends PlaywrightBase {
private readonly rootElement: string; private readonly rootElement: string;
@@ -55,8 +56,8 @@ export abstract class BaseComponent extends PlaywrightBase {
async spinnerWaitForReload(): Promise<void> { async spinnerWaitForReload(): Promise<void> {
try { try {
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: 2000 }); await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.short });
await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: 2000 }); await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: timeouts.normal });
} catch (e) { } catch (e) {
this.logger.info('Spinner was not present'); this.logger.info('Spinner was not present');
} }