-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Productpro5 #61
Productpro5 #61
Changes from all commits
705971e
82519d8
02929bb
355a4c1
ffedef8
4d5a30e
60dfed8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1545,4 +1545,44 @@ export class ProductsPage extends AdminPage { | |
await this.toHaveValue(productsVendor.wholesale.wholesalePrice, wholesaleOption.wholesalePrice); | ||
await this.toHaveValue(productsVendor.wholesale.minimumQuantity, wholesaleOption.minimumQuantity); | ||
} | ||
|
||
// remove product wholesale options | ||
async removeProductWholesaleOptions(productName: string): Promise<void> { | ||
await this.goToProductEdit(productName); | ||
await this.uncheck(productsVendor.wholesale.enableWholesale); | ||
await this.saveProduct(); | ||
await this.notToBeChecked(productsVendor.wholesale.enableWholesale); | ||
} | ||
|
||
// add product min-max options | ||
async addProductMinMaxOptions(productName: string, minMaxOption: product['productInfo']['minMax']): Promise<void> { | ||
await this.goToProductEdit(productName); | ||
await this.clearAndType(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); | ||
await this.clearAndType(productsVendor.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); | ||
await this.saveProduct(); | ||
await this.toHaveValue(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); | ||
await this.toHaveValue(productsVendor.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); | ||
} | ||
|
||
// can't add product min greater than max | ||
async cantAddGreaterMin(productName: string, minMaxOption: product['productInfo']['minMax']): Promise<void> { | ||
await this.goToProductEdit(productName); | ||
await this.clearAndType(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); | ||
await this.clearAndType(productsVendor.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); | ||
await this.press('Escape'); // to trigger validation | ||
await this.toHaveValue(productsVendor.minMax.maximumQuantity, minMaxOption.minimumProductQuantity); | ||
await this.saveProduct(); | ||
await this.toHaveValue(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); | ||
await this.toHaveValue(productsVendor.minMax.maximumQuantity, minMaxOption.minimumProductQuantity); | ||
} | ||
|
||
// remove product min-max options | ||
async removeProductMinMaxOptions(productName: string, minMaxOption: product['productInfo']['minMax']): Promise<void> { | ||
await this.goToProductEdit(productName); | ||
await this.clearAndType(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); | ||
await this.clearAndType(productsVendor.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); | ||
await this.saveProduct(); | ||
await this.toHaveValue(productsVendor.minMax.minimumQuantity, '0'); | ||
await this.toHaveValue(productsVendor.minMax.maximumQuantity, '0'); | ||
} | ||
Comment on lines
+1580
to
+1587
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistency between function name and implementation The Consider refactoring the function to align with its name: async removeProductMinMaxOptions(productName: string): Promise<void> {
await this.goToProductEdit(productName);
await this.clearAndType(productsVendor.minMax.minimumQuantity, '0');
await this.clearAndType(productsVendor.minMax.maximumQuantity, '0');
await this.saveProduct();
await this.toHaveValue(productsVendor.minMax.minimumQuantity, '0');
await this.toHaveValue(productsVendor.minMax.maximumQuantity, '0');
} This implementation directly sets both values to '0', effectively removing the min-max options, and then verifies the change. It also removes the unused |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider enhancing error validation in
cantAddGreaterMin
The function correctly tests the scenario where the minimum quantity can't be greater than the maximum. However, it doesn't explicitly verify that an error occurs or that an error message is displayed. Consider adding assertions to check for the presence of an error message or a failed save operation to make the test more robust.
You could improve the function by adding error checking, like this:
This assumes the existence of appropriate selectors for error messages and notifications. Adjust as needed based on your actual implementation.