-
Notifications
You must be signed in to change notification settings - Fork 204
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
Fix flaky tests #2411
Fix flaky tests #2411
Changes from all commits
ad2eb39
695419a
30cc41b
2077633
c15d018
08eb31b
c638d0e
4e04cc9
13abb76
85534a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,8 @@ setup.describe('setup woocommerce settings', () => { | |
// create shipping zone, location and method | ||
const [, zoneId] = await apiUtils.createShippingZone(payloads.createShippingZone); | ||
await apiUtils.addShippingZoneLocation(zoneId, payloads.addShippingZoneLocation); | ||
await apiUtils.addShippingZoneMethod(zoneId, payloads.addShippingMethodFlatRate); | ||
const [, methodId] = await apiUtils.addShippingZoneMethod(zoneId, payloads.addShippingMethodFlatRate); | ||
await apiUtils.updateShippingZoneMethod(zoneId, methodId, payloads.addShippingMethodFlatRateCost); | ||
await apiUtils.addShippingZoneMethod(zoneId, payloads.addShippingMethodFreeShipping); | ||
Comment on lines
46
to
49
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. 🛠️ Refactor suggestion Consider adding explicit assertions for critical setup operations. The shipping zone method setup lacks explicit assertions to verify the success of the operations. Consider adding expect statements to verify:
This will make test failures more descriptive and ensure critical setup steps complete successfully. Example: const [, methodId] = await apiUtils.addShippingZoneMethod(zoneId, payloads.addShippingMethodFlatRate);
+expect(methodId).toBeTruthy();
await apiUtils.updateShippingZoneMethod(zoneId, methodId, payloads.addShippingMethodFlatRateCost);
+const updatedMethod = await apiUtils.getShippingZoneMethod(zoneId, methodId);
+expect(updatedMethod.settings.cost.value).toBe(payloads.addShippingMethodFlatRateCost.settings.cost);
|
||
|
||
if (DOKAN_PRO) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ test.describe('Coupons test', () => { | |
}); | ||
|
||
test('vendor can view marketPlace coupons', { tag: ['@pro', '@exploratory', '@vendor'] }, async () => { | ||
test.skip(true, 'Has dokan issues') | ||
await vendor.viewMarketPlaceCoupons(marketplaceCouponCode); | ||
Comment on lines
+54
to
55
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. Document the skip reason and create tracking issue. The skip reason "Has dokan issues" is too vague. Please provide more context about the specific issues and create a tracking item. Consider updating the skip message with more details: -test.skip(true, 'Has dokan issues')
+test.skip(true, 'FIXME: Marketplace coupons view is unstable due to [specific reason]. Track: [issue-url]') Would you like me to help create a GitHub issue to track this skipped test?
|
||
}); | ||
|
||
|
@@ -79,6 +80,7 @@ test.describe('Coupons test', () => { | |
}); | ||
|
||
test('customer can buy product with coupon', { tag: ['@pro', '@customer'] }, async () => { | ||
test.slow() | ||
await customer.buyProductWithCoupon(data.predefined.simpleProduct.product1.name, data.predefined.coupon.couponCode); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -434,6 +434,7 @@ test.describe('Product details functionality test', () => { | |
// todo: duplicate test from product addons also has new tests | ||
|
||
test('vendor can add product addon', { tag: ['@pro', '@vendor'] }, async () => { | ||
test.slow(); | ||
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. 🛠️ Refactor suggestion Consider optimizing the test to avoid using The use of |
||
await vendor.addProductAddon(productName1, data.product.productInfo.addon); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2094,18 +2094,37 @@ export class ApiUtils { | |||||||||||||||||||||
return responseBody; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// shipping method exist or not | ||||||||||||||||||||||
async shippingMethodExistOrNot(zoneId: string, methodName: string, auth?: auth): Promise<responseBody> { | ||||||||||||||||||||||
const allShippingMethods = (await this.getAllShippingZoneMethods(zoneId, auth)).map((a: { method_id: string }) => a.method_id); | ||||||||||||||||||||||
return allShippingMethods.includes(methodName); | ||||||||||||||||||||||
// get single shipping zone method | ||||||||||||||||||||||
async getSingleShippingZoneMethod(zoneId: string, methodId: string, auth?: auth): Promise<responseBody> { | ||||||||||||||||||||||
const [, responseBody] = await this.get(endPoints.wc.getSingleShippingZoneMethod(zoneId, methodId), { headers: auth }); | ||||||||||||||||||||||
return responseBody; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// add shipping zone method | ||||||||||||||||||||||
async addShippingZoneMethod(zoneId: string, zoneMethod: object, auth?: auth): Promise<responseBody> { | ||||||||||||||||||||||
async addShippingZoneMethod(zoneId: string, zoneMethod: object, auth?: auth): Promise<[responseBody, string]> { | ||||||||||||||||||||||
const [, responseBody] = await this.post(endPoints.wc.addShippingZoneMethod(zoneId), { data: zoneMethod, headers: auth }); | ||||||||||||||||||||||
const methodId = String(responseBody?.id); | ||||||||||||||||||||||
return [responseBody, methodId]; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// update shipping zone method | ||||||||||||||||||||||
async updateShippingZoneMethod(zoneId: string, methodId: string, zoneMethod: object, auth?: auth): Promise<responseBody> { | ||||||||||||||||||||||
const [, responseBody] = await this.post(endPoints.wc.updateShippingZoneMethod(zoneId, methodId), { data: zoneMethod, headers: auth }); | ||||||||||||||||||||||
return responseBody; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// delete shipping zone method | ||||||||||||||||||||||
async deleteShippingZoneMethod(zoneId: string, methodId: string, auth?: auth): Promise<responseBody> { | ||||||||||||||||||||||
const [, responseBody] = await this.post(endPoints.wc.deleteShippingZoneMethod(zoneId, methodId), { params: payloads.paramsForceDelete, headers: auth }); | ||||||||||||||||||||||
return responseBody; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// shipping method exist or not | ||||||||||||||||||||||
async shippingMethodExistOrNot(zoneId: string, methodName: string, auth?: auth): Promise<responseBody> { | ||||||||||||||||||||||
const allShippingMethods = (await this.getAllShippingZoneMethods(zoneId, auth)).map((a: { method_id: string }) => a.method_id); | ||||||||||||||||||||||
return allShippingMethods.includes(methodName); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+2122
to
+2126
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. 🛠️ Refactor suggestion Consider renaming and simplifying this method. The current method name
-async shippingMethodExistOrNot(zoneId: string, methodName: string, auth?: auth): Promise<responseBody> {
- const allShippingMethods = (await this.getAllShippingZoneMethods(zoneId, auth)).map((a: { method_id: string }) => a.method_id);
- return allShippingMethods.includes(methodName);
+async hasShippingMethod(zoneId: string, methodName: string, auth?: auth): Promise<boolean> {
+ const methods = await this.getAllShippingZoneMethods(zoneId, auth);
+ return methods.some(method => method.method_id === methodName);
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
// get all shipping classes | ||||||||||||||||||||||
async getAllShippingClasses(auth?: auth): Promise<responseBody> { | ||||||||||||||||||||||
const [, responseBody] = await this.get(endPoints.wc.getAllShippingClasses, { headers: auth }, false); | ||||||||||||||||||||||
|
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 alternative approaches to handle hover menu flakiness.
While removing the class attribute does fix the flakiness, modifying the DOM during tests can mask UI issues and make tests less representative of real user interactions. Consider these alternatives: