Skip to content
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

Merged
merged 7 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@
vendor can add product rma options (warranty included lifetime): true
vendor can add product rma options (warranty as addon): true
vendor can remove product rma options: true
vendor can add product wholesale options: true
vendor can update product wholesale options: true
vendor can remove product wholesale options: true
vendor can add product min-max options: true
vendor can update product min-max options: true
vendor can't add product min limit grater than max limit: true
vendor can remove product min-max options: true

- page: 'MyOrders'
features:
Expand Down
40 changes: 40 additions & 0 deletions tests/pw/pages/productsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Comment on lines +1568 to +1577
Copy link

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:

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);
    
    // Add error checking
    await this.toBeVisible(productsVendor.minMax.errorMessage);
    
    // Attempt to save and verify it fails
    await this.click(productsVendor.saveProduct);
    await this.toBeVisible(productsVendor.errorNotification);

    // Verify values remain unchanged
    await this.toHaveValue(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity);
    await this.toHaveValue(productsVendor.minMax.maximumQuantity, minMaxOption.minimumProductQuantity);
}

This assumes the existence of appropriate selectors for error messages and notifications. Adjust as needed based on your actual implementation.


// 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency between function name and implementation

The removeProductMinMaxOptions function name suggests it's removing min-max options, but the implementation is setting these options to specific values and then verifying they're set to '0'. This is inconsistent and potentially confusing.

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 minMaxOption parameter.

}
36 changes: 36 additions & 0 deletions tests/pw/tests/e2e/productsDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,40 @@ test.describe('Product details functionality test', () => {
test('vendor can remove product rma options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.removeProductRmaOptions(productName);
});

// wholesale options

test('vendor can add product wholesale options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductWholesaleOptions(productName1, data.product.productInfo.wholesaleOption);
});

test('vendor can update product wholesale options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductWholesaleOptions(productName, data.product.productInfo.wholesaleOption);
});

test('vendor can remove product wholesale options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.removeProductWholesaleOptions(productName);
});

// mix-max options

test('vendor can add product min-max options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductMinMaxOptions(productName1, data.product.productInfo.minMax);
});

test('vendor can update product min-max options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductMinMaxOptions(productName, data.product.productInfo.minMax);
});

test("vendor can't add product min limit grater than max limit", { tag: ['@pro', '@vendor'] }, async () => {
await vendor.cantAddGreaterMin(productName, { minimumProductQuantity: '100', maximumProductQuantity: '50' });
});

test('vendor can remove product min-max options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.removeProductMinMaxOptions(productName, { minimumProductQuantity: '', maximumProductQuantity: '' });
});

// todo: advertising
// todo: rank math seo
// todo: variation options
});
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/requestForQuoteRules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test.describe('Request for quotation Rules test', () => {
});

test('admin can edit quote rule', { tag: ['@pro', '@admin'] }, async () => {
await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle, specificProducts: false, });
await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle, specificProducts: false });
});

test('admin can trash quote rule', { tag: ['@pro', '@admin'] }, async () => {
Expand Down
Loading