mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-7160] Setup Playwright in ADF - Storybook testing (#7537)
* [AAE-7160] Setup Playwright in ADF - Storybook testing * New test cases for groups component. Reorganize the files * Add to package.json scripts - npm run playwright * Change amount of workers * Change workesr to 2
This commit is contained in:
31
e2e-playwright/page-object/components/base.component.ts
Normal file
31
e2e-playwright/page-object/components/base.component.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { PlaywrightBase } from '../playwright-base';
|
||||
|
||||
export abstract class BaseComponent extends PlaywrightBase {
|
||||
private rootElement: string;
|
||||
|
||||
constructor(page: Page,rootElement: string) {
|
||||
super(page);
|
||||
this.rootElement = rootElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which should be used across the repository, while creating
|
||||
* reference to elements, which are in root element of component.
|
||||
* @param cssLocator css selector as String. Need to be in the tree under the root element
|
||||
* @param options if you want to localize it by text, then provide an optional hasText
|
||||
* @returns Locator object
|
||||
*/
|
||||
getChild(cssLocator: string, options?: { hasText: string | RegExp }): Locator {
|
||||
return this.page.locator(`${this.rootElement} ${cssLocator}`, options);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
import { Page } from '@playwright/test';
|
||||
import { BaseComponent } from '../base.component';
|
||||
|
||||
export class ErrorComponent extends BaseComponent {
|
||||
private static rootElement = 'mat-error';
|
||||
public content = this.getChild('');
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page, ErrorComponent.rootElement);
|
||||
}
|
||||
}
|
11
e2e-playwright/page-object/components/basic/index.ts
Normal file
11
e2e-playwright/page-object/components/basic/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
export * from './error.component';
|
||||
export * from './listbox.component';
|
||||
export * from './validation.component';
|
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
import { Page } from '@playwright/test';
|
||||
import { BaseComponent } from '../base.component';
|
||||
|
||||
export class ListboxComponent extends BaseComponent {
|
||||
private static rootElement = 'div[role=listbox]';
|
||||
public allOptions = this.getChild('');
|
||||
public oneOption = this.getChild('span >> span');
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page, ListboxComponent.rootElement);
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
import { Page } from '@playwright/test';
|
||||
import { BaseComponent } from '../base.component';
|
||||
|
||||
export class TooltipComponent extends BaseComponent {
|
||||
private static rootElement = 'mat-tooltip-component';
|
||||
public content = this.getChild('div');
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page, TooltipComponent.rootElement);
|
||||
}
|
||||
}
|
10
e2e-playwright/page-object/components/index.ts
Normal file
10
e2e-playwright/page-object/components/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
export * from './basic';
|
||||
export * from './base.component';
|
10
e2e-playwright/page-object/index.ts
Normal file
10
e2e-playwright/page-object/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
export * from './components';
|
||||
export * from './stories/base.storie';
|
17
e2e-playwright/page-object/playwright-base.ts
Normal file
17
e2e-playwright/page-object/playwright-base.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
import { Page } from '@playwright/test';
|
||||
|
||||
export abstract class PlaywrightBase {
|
||||
public page: Page;
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
}
|
||||
}
|
30
e2e-playwright/page-object/stories/base.storie.ts
Normal file
30
e2e-playwright/page-object/stories/base.storie.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
import { Page } from '@playwright/test';
|
||||
import { timeouts } from '../../utils/timeouts';
|
||||
import { ComponentTitles } from '../../models/component-titles.model';
|
||||
import { PlaywrightBase } from '../playwright-base';
|
||||
|
||||
interface NavigateParameters { componentName: string; story: string };
|
||||
|
||||
export class BaseStories extends PlaywrightBase {
|
||||
private rootComponentTitle: string;
|
||||
|
||||
constructor(page: Page, rootComponentTitle: ComponentTitles) {
|
||||
super(page);
|
||||
this.rootComponentTitle = rootComponentTitle;
|
||||
}
|
||||
|
||||
async navigateTo({ componentName, story }: NavigateParameters): Promise<void> {
|
||||
await this.page.goto(`/iframe.html?id=${this.rootComponentTitle}-components-${componentName}--${story}`, {
|
||||
waitUntil: 'networkidle',
|
||||
timeout: timeouts.large
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user