Skip to content

Commit

Permalink
feat: add flow builder templates page object
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Meyer authored and GitEvil committed Jan 24, 2025
1 parent b699542 commit 1281219
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/page-objects/AdministrationPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { CustomerGroupDetail } from './administration/CustomerGroupDetail';
import { FirstRunWizard } from './administration/FirstRunWizard';
import { FlowBuilderCreate } from './administration/FlowBuilderCreate';
import { FlowBuilderListing } from './administration/FlowBuilderListing';
import { FlowBuilderTemplates } from './administration/FlowBuilderTemplates';
import { FlowBuilderDetail } from './administration/FlowBuilderDetail';
import { DataSharing } from './administration/DataSharing';
import { Dashboard } from './administration/Dashboard';
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface AdministrationPageTypes {
AdminFirstRunWizard: FirstRunWizard;
AdminFlowBuilderCreate: FlowBuilderCreate;
AdminFlowBuilderListing: FlowBuilderListing;
AdminFlowBuilderTemplates: FlowBuilderTemplates
AdminFlowBuilderDetail: FlowBuilderDetail;
AdminDataSharing: DataSharing;
AdminDashboard: Dashboard;
Expand Down Expand Up @@ -80,6 +82,7 @@ export const AdminPageObjects = {
FirstRunWizard,
FlowBuilderCreate,
FlowBuilderListing,
FlowBuilderTemplates,
FlowBuilderDetail,
Dashboard,
DataSharing,
Expand Down Expand Up @@ -146,6 +149,10 @@ export const test = base.extend<FixtureTypes>({
await use(new FlowBuilderListing(AdminPage));
},

AdminFlowBuilderTemplates: async ({ AdminPage }, use) => {
await use(new FlowBuilderTemplates(AdminPage));
},

AdminFlowBuilderDetail: async ({ AdminPage }, use) => {
await use(new FlowBuilderDetail(AdminPage));
},
Expand Down
15 changes: 13 additions & 2 deletions src/page-objects/administration/FlowBuilderCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ export class FlowBuilderCreate implements PageObject {

public readonly saveButton: Locator;
public readonly header: Locator;
public readonly nameField: Locator;
public readonly flowTab: Locator;
public readonly triggerSelectField: Locator;
public readonly addActionField: Locator;
public readonly smartBarHeader: Locator;


constructor(public readonly page: Page) {
this.saveButton = page.locator('.sw-flow-detail__save');
this.header = page.locator('h2');
this.nameField = page.locator('.sw-flow-detail-general__general-name').getByLabel('Name');
this.flowTab = page.locator('.sw-tabs__content').locator('.sw-flow-detail__tab-flow');
this.triggerSelectField = page.locator('.sw-flow-detail-flow__trigger-card').getByRole('textbox');
this.addActionField = page.locator('.sw-flow-sequence-action__content').locator('.sw-single-select__selection');
this.smartBarHeader = page.locator('.smart-bar__header');
}

url() {
return '#/sw/flow/create/general';
url(flowId: string, tabName = 'general') {
return `#/sw/flow/create//${flowId}/${tabName}`;
}
}
10 changes: 9 additions & 1 deletion src/page-objects/administration/FlowBuilderDetail.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import type { Page, Locator } from '@playwright/test';
import type { PageObject } from '../../types/PageObject';
import { FlowBuilderCreate } from './FlowBuilderCreate';

export class FlowBuilderDetail implements PageObject {
export class FlowBuilderDetail extends FlowBuilderCreate implements PageObject {

public readonly saveButton: Locator;
public readonly generalTab: Locator;
public readonly flowTab: Locator;
public readonly flowName: Locator;
public readonly alertWarning: Locator;
public readonly templateName: Locator;

constructor(public readonly page: Page) {
super(page);
this.saveButton = page.locator('.sw-flow-detail__save');
this.generalTab = page.locator('.sw-flow-detail__tab-general');
this.flowTab = page.locator('.sw-flow-detail__tab-flow');
this.flowName = page.getByTestId('sw-field--flow-name');
this.alertWarning = page.getByRole('alert').first();
this.templateName = page.getByLabel(('Name'));
}

url(flowId: string, tabName = 'general') {
Expand Down
4 changes: 4 additions & 0 deletions src/page-objects/administration/FlowBuilderListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class FlowBuilderListing implements PageObject {
public readonly flowDeleteButton: Locator;
public readonly successAlert: Locator;
public readonly successAlertMessage: Locator;
public readonly searchBar: Locator;


constructor(public readonly page: Page) {
this.createFlowButton = page.locator('.sw-flow-list__create');
Expand All @@ -33,6 +35,8 @@ export class FlowBuilderListing implements PageObject {
this.downloadFlowButton = page.getByRole('button', { name: 'Download flow' });
this.successAlert = page.locator('.sw-alert__body');
this.successAlertMessage = page.locator('.sw-alert__message');
this.searchBar = page.locator('.sw-search-bar').getByPlaceholder('Search flows...');

}

url() {
Expand Down
28 changes: 28 additions & 0 deletions src/page-objects/administration/FlowBuilderTemplates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Page, Locator } from '@playwright/test';
import type { PageObject } from '../../types/PageObject';
import { FlowBuilderListing } from './FlowBuilderListing';

export class FlowBuilderTemplates extends FlowBuilderListing implements PageObject {

public readonly searchBar: Locator;

constructor(public readonly page: Page) {
super(page);
this.searchBar = page.locator('.sw-search-bar').getByPlaceholder('Search flows...');
}
url() {
return `#/sw/flow/index/templates`;
}

async getLineItemByFlowName(flowName: string): Promise<Record<string, Locator>> {
const lineItem = this.page.locator('.sw-data-grid__row').filter({ hasText: flowName });
const createFlowLink = lineItem.getByRole('link').getByTestId('sw-icon__regular-long-arrow-right');
const templateDetailLink = lineItem.getByRole('link').getByText(flowName);

return {
createFlowLink: createFlowLink,
lineItem: lineItem,
templateDetailLink: templateDetailLink,
}
}
}
2 changes: 1 addition & 1 deletion src/page-objects/administration/RuleDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export class RuleDetail extends RuleCreate implements PageObject {
url(ruleId?: string, tabName = 'base') {
return `#/sw/settings/rule/detail/${ruleId}/${tabName}`
}
}
}
28 changes: 28 additions & 0 deletions src/tasks/shop-admin/Flow/AssertFlowStructure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Locator, test as base } from '@playwright/test';

Check warning on line 1 in src/tasks/shop-admin/Flow/AssertFlowStructure.ts

View workflow job for this annotation

GitHub Actions / eslint

'Locator' is defined but never used

Check warning on line 1 in src/tasks/shop-admin/Flow/AssertFlowStructure.ts

View workflow job for this annotation

GitHub Actions / eslint

'Locator' is defined but never used
import type { Task } from '../../../types/Task';
import type { FixtureTypes } from '../../../types/FixtureTypes';


export const AssertFlowStructure = base.extend<{ AssertFlowStructure: Task }, FixtureTypes>({
AssertFlowStructure: async ({ AdminFlowBuilderDetail, ShopAdmin }, use ) => {
const task = () => {
return async function AssertFlowStructure() {

await ShopAdmin.expects(AdminFlowBuilderDetail.triggerSelectField).toBeVisible();
await AdminFlowBuilderDetail.triggerSelectField.hover();
const tooltip = await AdminFlowBuilderDetail.page.waitForSelector('.sw-tooltip');

Check warning on line 13 in src/tasks/shop-admin/Flow/AssertFlowStructure.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected use of page.waitForSelector()
const tooltipText = await tooltip.innerText(); // Get text from the tooltip
await ShopAdmin.expects(tooltipText).toEqual('Checkout / Order / Placed');
await ShopAdmin.expects(AdminFlowBuilderDetail.page.locator('.sw-flow-sequence-action__content').locator('.sw-single-select__selection')).toBeVisible();
// asserts there are no other containers
await ShopAdmin.expects(AdminFlowBuilderDetail.page.locator('.sw-flow-sequence-condition__container')).not.toBeVisible();
await ShopAdmin.expects(AdminFlowBuilderDetail.page.locator('.sw-flow-delay-action__delay_card')).not.toBeVisible();
// asserts email action (only partially available during test)
await ShopAdmin.expects(AdminFlowBuilderDetail.page.locator('.sw-flow-sequence-action__content').locator('.sw-single-select__selection')).toBeVisible();
await ShopAdmin.expects(AdminFlowBuilderDetail.page.locator('.sw-flow-sequence-action__content').getByRole('button').first()).toContainText('Template: Order confirmation');

}
}
await use(task);
},
});
10 changes: 5 additions & 5 deletions src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Locator, test as base} from '@playwright/test';
import type {Task} from '../../../types/Task';
import type {FixtureTypes} from '../../../types/FixtureTypes';
import {RuleType} from '../../../types/ShopwareTypes';
import {RuleAssignmentEntity} from '../../../types/ShopwareTypes';
import { Locator, test as base } from '@playwright/test';
import type { Task } from '../../../types/Task';
import type { FixtureTypes } from '../../../types/FixtureTypes';
import { RuleType } from '../../../types/ShopwareTypes';
import { RuleAssignmentEntity } from '../../../types/ShopwareTypes';

export const AssignEntitiesToRule = base.extend<{ AssignEntitiesToRule: Task }, FixtureTypes>({
AssignEntitiesToRule: async ({ AdminRuleDetail }, use ) => {
Expand Down

0 comments on commit 1281219

Please sign in to comment.