Skip to content

Commit

Permalink
fix: type check to stop IDE complaint (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanpham-sw authored Dec 16, 2024
1 parent c70ae47 commit 4eab21c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/page-objects/administration/Categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class Categories implements PageObject {
this.landingPageItems = this.landingPageArea.locator('.sw-tree-item__label');
this.categoryTree = page.locator('.sw-category-tree');

this.categoryMenuItemList = page.locator('.sw-context-button__menu-popover').locator('.sw-context-menu-item');
this.categoryMenuItemList = page.locator('.sw-context-menu-item');
this.createCategoryInput = page.getByPlaceholder('Create category').getByRole('textbox');
this.confirmCategoryCreationButton = page.locator('.sw-confirm-field').locator('.sw-button--primary');
this.categoryItems = this.categoryTree.locator('.tree-link');
Expand Down
12 changes: 7 additions & 5 deletions src/tasks/shop-admin/Category/CreateLinkTypeCategory.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { test as base, Locator } from '@playwright/test';
import type { Task } from '../../../types/Task';
import type { FixtureTypes } from '../../../types/FixtureTypes';
import { CategoryData, CategoryCustomizableLinkData } from '../../../types/ShopwareTypes';

export const CreateLinkTypeCategory = base.extend<{ CreateLinkTypeCategory: Task }, FixtureTypes>({
CreateLinkTypeCategory: async ({ AdminCategories, AdminCategoryDetail, TestDataService }, use) => {

const task = (categoryData, categoryCustomizableLinkData, parentCategoryName: string) => {
const task = (categoryData: CategoryData, categoryCustomizableLinkData: CategoryCustomizableLinkData, parentCategoryName: string) => {
return async function CreateLinkTypeCategory() {
await AdminCategories.getTreeItemContextButton(parentCategoryName).click();

await AdminCategories.categoryMenuItemList.filter({ hasText: 'New category after' }).click();
await AdminCategories.page.getByText('New category after').click();
await AdminCategories.createCategoryInput.fill(categoryData.name);
await AdminCategories.confirmCategoryCreationButton.click();
await AdminCategories.fadingBar.first().waitFor({ state: 'hidden' });
Expand All @@ -28,8 +28,10 @@ export const CreateLinkTypeCategory = base.extend<{ CreateLinkTypeCategory: Task
switch (categoryCustomizableLinkData.entity) {
case 'Category':
await AdminCategories.categorySelectionList.click();
locator = await AdminCategories.getPopOverCategoryByName(categoryCustomizableLinkData.category);
await locator.getByRole('checkbox').click();
if (categoryCustomizableLinkData.category != null) {
locator = await AdminCategories.getPopOverCategoryByName(categoryCustomizableLinkData.category);
await locator.getByRole('checkbox').click();
}
break;
case 'Product':
await AdminCategories.productSelectionList.click();
Expand Down
3 changes: 2 additions & 1 deletion src/tasks/shop-admin/Customers/BulkEditCustomers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { test as base } from '@playwright/test';
import { Task } from '../../../types/Task';
import { FixtureTypes } from '../../../types/FixtureTypes';
import { AccountData, Customer, CustomFieldData, TagData } from '../../../types/ShopwareTypes';

export const BulkEditCustomers = base.extend<{ BulkEditCustomers: Task }, FixtureTypes>({
BulkEditCustomers: async ({ ShopAdmin, AdminCustomerListing, AdminCustomerBulkEdit }, use ) => {
const task = (customers, accountData?, tagData?, customFieldData?) => {
const task = (customers: Customer[], accountData?: AccountData, tagData?: TagData, customFieldData?: CustomFieldData) => {
return async function BulkEditCustomers() {
const customerCount = customers.length;
for (const customer of customers) {
Expand Down
31 changes: 31 additions & 0 deletions src/types/ShopwareTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,34 @@ export interface RuleAssignmentEntity {
ruleType: RuleType;
}

export interface CategoryData {
name: string;
categoryType: 'Link' | 'Page / List' | 'Structuring element / Entry point';
status: boolean;
}

export interface CategoryCustomizableLinkData {
linkType: 'Internal' | 'External';
entity: 'Category' | 'Product' | 'Landing page'; // Restrict entity values
category?: string;
product?: string;
landingPage?: string;
openInNewTab: boolean;
}

export interface AccountData {
customerGroup?: string;
accountStatus?: boolean;
language?: string;
replyToCustomerGroupRequest?: string;
}

export interface TagData {
changeType: 'Overwrite' | 'Clear' | 'Add' | 'Remove';
tags: string[];
}

export interface CustomFieldData {
customFieldSetName: string;
customFieldValue: string;
}

0 comments on commit 4eab21c

Please sign in to comment.