Skip to content

Commit

Permalink
fix: add 6.7 locators (#263)
Browse files Browse the repository at this point in the history
* fix: add 6.7 locators

* fix: add review feedback
  • Loading branch information
GitEvil authored Jan 15, 2025
1 parent ed3e795 commit 03d2dc4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/page-objects/AdministrationPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ export const test = base.extend<FixtureTypes>({
await use(new RuleCreate(AdminPage));
},

AdminRuleDetail: async ({ AdminPage }, use) => {
await use(new RuleDetail(AdminPage));
AdminRuleDetail: async ({ AdminPage, InstanceMeta }, use) => {
await use(new RuleDetail(AdminPage, InstanceMeta));
},

AdminRuleListing: async ({ AdminPage }, use) => {
Expand Down
15 changes: 13 additions & 2 deletions src/page-objects/administration/RuleDetail.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Page, Locator } from '@playwright/test';
import type { PageObject } from '../../types/PageObject';
import { RuleCreate } from './RuleCreate';
import { HelperFixtureTypes } from '../../fixtures/HelperFixtures';
import { satisfies } from 'compare-versions';

export class RuleDetail extends RuleCreate implements PageObject {

Expand All @@ -20,14 +22,17 @@ export class RuleDetail extends RuleCreate implements PageObject {
public readonly promotionCustomerRulesCardEmptyState: Locator;
public readonly promotionCartRulesCard: Locator;
public readonly promotionCartRulesCardEmptyState: Locator;
public readonly assignmentModalAddButton: Locator;
public readonly assignmentModalSearchField: Locator;

constructor(public readonly page: Page) {

constructor(public readonly page: Page, public readonly instanceMeta: HelperFixtureTypes['InstanceMeta']) {
super(page);
this.shippingMethodAvailabilityRulesCard = page.locator('.sw-settings-rule-detail-assignments__card-shipping_method_availability_rule');
this.shippingMethodAvailabilityRulesCardLink = this.shippingMethodAvailabilityRulesCard.getByRole('link');
this.shippingMethodAvailabilityRulesCardTable = page.locator('.sw-settings-rule-detail-assignments__entity-listing-shipping_method_availability_rule');
this.shippingMethodAvailabilityRulesCardEmptyState = this.shippingMethodAvailabilityRulesCard.getByRole('alert');
this.shippingMethodAvailabilityRulesCardSearchField = this.shippingMethodAvailabilityRulesCard.getByPlaceholder('Search...');
this.shippingMethodAvailabilityRulesCardSearchField = this.shippingMethodAvailabilityRulesCard.getByRole('textbox');
this.taxProviderRulesCard = page.locator('.sw-settings-rule-detail-assignments__card-tax_provider');
this.taxProviderRulesCardEmptyState = this.taxProviderRulesCard.getByRole('alert');
this.paymentMethodsAvailabilityRulesCard = page.locator('.sw-settings-rule-detail-assignments__card-payment_method');
Expand All @@ -39,6 +44,12 @@ export class RuleDetail extends RuleCreate implements PageObject {
this.promotionCustomerRulesCardEmptyState = this.promotionCustomerRulesCard.getByRole('alert');
this.promotionCartRulesCard = page.locator('.sw-settings-rule-detail-assignments__card-promotion_cart_rule');
this.promotionCartRulesCardEmptyState = this.promotionCartRulesCard.getByRole('alert');
this.assignmentModalSearchField = page.locator('.sw-settings-rule-add-assignment-modal').getByRole('textbox');
if (satisfies(instanceMeta.version, '<6.7')) {
this.assignmentModalAddButton = page.locator('.sw-button--primary').getByText('Add');
} else {
this.assignmentModalAddButton = page.locator('.mt-button--primary').getByText('Add');
}
}

async getEntityCard(cardLocator: Locator): Promise<Record<string, Locator>> {
Expand Down
4 changes: 2 additions & 2 deletions src/tasks/shop-admin/Rule/AssignEntitiesToRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export const AssignEntitiesToRule = base.extend<{ AssignEntitiesToRule: Task },
async function entityAssignment(entityName: string, card: Locator) {
const entityCard = await AdminRuleDetail.getEntityCard(card);
await entityCard.addAssignmentButton.click();
await AdminRuleDetail.page.locator('.sw-settings-rule-add-assignment-modal').getByPlaceholder('Search...').fill(entityName);
await AdminRuleDetail.assignmentModalSearchField.fill(entityName);
await AdminRuleDetail.page.locator('.sw-data-grid__row').filter({hasText: entityName}).getByRole('checkbox').click();
await AdminRuleDetail.page.locator('.sw-button--primary').getByText('Add').click();
await AdminRuleDetail.assignmentModalAddButton.click();
}
for (const assignableEntity of assignableEntities) {
switch (assignableEntity.ruleType) {
Expand Down

0 comments on commit 03d2dc4

Please sign in to comment.