Skip to content

Commit 3776b95

Browse files
Add some fixes and create types
1 parent e1abbce commit 3776b95

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

src/data/types/product.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,31 @@ type ProductCustomizations = {
136136
};
137137

138138
type ProductDetailsBasic = {
139-
image: string
139+
image?: string
140140
name: string
141141
price: number
142-
quantity: number
142+
quantity?: number
143143
};
144144

145145
type ProductDetails = ProductDetailsBasic & {
146-
summary: string
147-
description: string
146+
summary?: string
147+
description?: string
148148
shipping?: string
149149
subtotal?: number
150+
coverImage?:string,
151+
thumbImage?:string,
152+
taxShippingDeliveryLabel?: string,
153+
shortDescription?: string,
154+
};
155+
156+
type ProductDetailsWithDiscount = ProductDetailsBasic & {
157+
discountPercentage: string,
158+
regularPrice: number,
159+
subtotal?: number,
160+
taxShippingDeliveryLabel?: string,
161+
coverImage?:string,
162+
thumbImage?:string,
163+
shortDescription?: string,
150164
};
151165

152166
type ProductDiscount = {
@@ -242,6 +256,7 @@ export type {
242256
ProductCustomization,
243257
ProductDetails,
244258
ProductDetailsBasic,
259+
ProductDetailsWithDiscount,
245260
ProductDiscount,
246261
ProductFilterMinMax,
247262
ProductHeaderSummary,

src/interfaces/FO/cart/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {FOBasePagePageInterface} from '@interfaces/FO';
2-
import type {ProductAttribute} from '@data/types/product';
2+
import type {ProductAttribute, ProductDetailsWithDiscount} from '@data/types/product';
33
import type {Page} from '@playwright/test';
44

55
export interface FoCartPageInterface extends FOBasePagePageInterface {
@@ -28,7 +28,7 @@ export interface FoCartPageInterface extends FOBasePagePageInterface {
2828
getNoItemsInYourCartMessage(page: Page): Promise<string>;
2929
getNotificationMessage(page: Page): Promise<string>;
3030
getProductAttributes(page: Page, row: number): Promise<ProductAttribute[]>;
31-
getProductDetail(page: Page, row: number): Promise<object>;
31+
getProductDetail(page: Page, row: number): Promise<ProductDetailsWithDiscount>;
3232
getProductsNumber(page: Page): Promise<number>;
3333
getSubtotalDiscountValue(page: Page): Promise<number>;
3434
isAlertWarningForMinimumPurchaseVisible(page: Page): Promise<boolean>;

src/interfaces/FO/checkout/orderConfirmation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import type {Page} from '@playwright/test';
33

44
export interface FoCheckoutOrderConfirmationPageInterface extends FOBasePagePageInterface {
55
readonly orderConfirmationCardTitle: string;
6+
readonly pageTitle: string;
67

8+
getGiftWrappingValue(page: Page): Promise<number>;
79
getOrderConfirmationCardTitle(page: Page): Promise<string>;
810
getOrderReferenceValue(page: Page): Promise<string>;
11+
getPaymentMethod(page: Page): Promise<string>;
12+
goToContactUsPage(page: Page): Promise<void>;
13+
isFinalSummaryVisible(page: Page): Promise<boolean>;
914
}

src/pages/BO/catalog/products/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import testContext from '@utils/test';
44

55
const psVersion = testContext.getPSVersion();
66

7-
/* eslint-disable global-require */
7+
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
88
function requirePage(): BOProductsPageInterface {
99
if (semver.gte(psVersion, '0.0.0')) {
10-
return require('@versions/develop/pages/BO/catalog/products');
10+
return require('@versions/develop/pages/BO/catalog/products').productsPage;
1111
}
12-
return require('@versions/develop/pages/BO/catalog/products');
12+
return require('@versions/develop/pages/BO/catalog/products').productsPage;
1313
}
14-
15-
/* eslint-enable global-require */
14+
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
1615

1716
export default requirePage();

src/versions/develop/pages/FO/classic/cart/index.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {FoCartPageInterface} from '@interfaces/FO/cart';
33
import FOBasePage from '@pages/FO/FOBasePage';
44

55
// Import data
6-
import type {ProductAttribute} from '@data/types/product';
6+
import type {ProductAttribute, ProductDetailsWithDiscount} from '@data/types/product';
77

88
import type {Page} from 'playwright';
99

@@ -216,23 +216,15 @@ class CartPage extends FOBasePage implements FoCartPageInterface {
216216
* @returns {Promise<{discountPercentage: string, image: string|null, quantity: number, totalPrice: number,
217217
* price: number, regularPrice: number, name: string}>}
218218
*/
219-
async getProductDetail(page: Page, row: number): Promise<{
220-
discountPercentage: string,
221-
image: string | null,
222-
quantity: number,
223-
totalPrice: number,
224-
price: number,
225-
regularPrice: number,
226-
name: string,
227-
}> {
219+
async getProductDetail(page: Page, row: number): Promise<ProductDetailsWithDiscount> {
228220
return {
229221
name: await this.getTextContent(page, this.productName(row)),
230222
regularPrice: await this.getPriceFromText(page, this.productRegularPrice(row)),
231223
price: await this.getPriceFromText(page, this.productPrice(row)),
232224
discountPercentage: await this.getTextContent(page, this.productDiscountPercentage(row)),
233225
image: await this.getAttributeContent(page, this.productImage(row), 'src'),
234226
quantity: parseFloat(await this.getAttributeContent(page, this.productQuantity(row), 'value') ?? ''),
235-
totalPrice: await this.getPriceFromText(page, this.productTotalPrice(row)),
227+
subtotal: await this.getPriceFromText(page, this.productTotalPrice(row)),
236228
};
237229
}
238230

0 commit comments

Comments
 (0)