From 4eab21c21236b652618789b982cf608b14f8533f Mon Sep 17 00:00:00 2001 From: vanpham-sw Date: Mon, 16 Dec 2024 14:26:08 +0700 Subject: [PATCH] fix: type check to stop IDE complaint (#228) --- src/page-objects/administration/Categories.ts | 2 +- .../Category/CreateLinkTypeCategory.ts | 12 ++++--- .../shop-admin/Customers/BulkEditCustomers.ts | 3 +- src/types/ShopwareTypes.ts | 31 +++++++++++++++++++ 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/page-objects/administration/Categories.ts b/src/page-objects/administration/Categories.ts index 6e6b9e7..ce6e3c3 100644 --- a/src/page-objects/administration/Categories.ts +++ b/src/page-objects/administration/Categories.ts @@ -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'); diff --git a/src/tasks/shop-admin/Category/CreateLinkTypeCategory.ts b/src/tasks/shop-admin/Category/CreateLinkTypeCategory.ts index 29249a3..6bc6540 100644 --- a/src/tasks/shop-admin/Category/CreateLinkTypeCategory.ts +++ b/src/tasks/shop-admin/Category/CreateLinkTypeCategory.ts @@ -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' }); @@ -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(); diff --git a/src/tasks/shop-admin/Customers/BulkEditCustomers.ts b/src/tasks/shop-admin/Customers/BulkEditCustomers.ts index d5d096a..54fbe60 100644 --- a/src/tasks/shop-admin/Customers/BulkEditCustomers.ts +++ b/src/tasks/shop-admin/Customers/BulkEditCustomers.ts @@ -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) { diff --git a/src/types/ShopwareTypes.ts b/src/types/ShopwareTypes.ts index aea153c..08643cb 100644 --- a/src/types/ShopwareTypes.ts +++ b/src/types/ShopwareTypes.ts @@ -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; +} \ No newline at end of file