Skip to content

Commit

Permalink
Fixed flaky tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmiseev committed Feb 26, 2025
1 parent f9decfa commit 0b87940
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build:one": "webpack --env entryPattern=./src/tests/dashboard/M8_view_dashboard.test.js",
"build:one": "webpack --env entryPattern=./src/tests/order-amendment/SAPI16_order_amendment_50.test.js",
"build:all": "webpack --env entryPattern=./src/tests/**/*.test.js",
"build:S": "webpack --env entryPattern=./src/tests/**/S*.test.js",
"build:M": "webpack --env entryPattern=./src/tests/**/M*.test.js",
Expand Down
20 changes: 19 additions & 1 deletion src/fixtures/checkout.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export class CheckoutFixture extends AbstractFixture {
this.cartCount = cartCount;
this.itemCount = itemCount;
this.defaultItemPrice = defaultItemPrice;
this.emptyCartCount = 0;
this.repositoryId = EnvironmentUtil.getRepositoryId();
}

getData(customerCount = this.customerCount, cartCount = this.cartCount) {
getData(customerCount = this.customerCount, cartCount = this.cartCount, emptyCartCount = this.emptyCartCount) {
this.customerCount = customerCount;
this.cartCount = cartCount;
this.emptyCartCount = emptyCartCount;

const response = this.runDynamicFixture(this._getCustomersWithQuotesPayload());

Expand Down Expand Up @@ -255,6 +257,22 @@ export class CheckoutFixture extends AbstractFixture {
],
}));

if (this.emptyCartCount) {
const emptyQuotes = Array.from({ length: this.emptyCartCount }, (_, emptyQuoteIndex) => ({
type: 'helper',
name: 'havePersistentQuote',
key: `${customerKey}EmptyQuote${emptyQuoteIndex + 1}`,
arguments: [
{
customer: `#${customerKey}`,
items: [],
},
],
}));

quotes.push(...emptyQuotes);
}

const customer = [
{
type: 'helper',
Expand Down
3 changes: 1 addition & 2 deletions src/tests/order-amendment/SAPI16_order_amendment_50.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function setup() {
}

if (isConcurrentSetup()) {
return dynamicFixture.getData();
return dynamicFixture.getData(testConfiguration.vus, testConfiguration.iterations, 2);
}
}

Expand Down Expand Up @@ -83,7 +83,6 @@ export default function (data) {

const cartsResource = new CartsResource(bearerToken);
group('Cancel Order Amendment', () => {
cartsResource.create('default', true);
const response = cartsResource.delete(reorderedIdCart);
metrics['SAPI17_delete_carts'].add(response.timings.duration);
});
Expand Down
3 changes: 1 addition & 2 deletions src/tests/order-amendment/SAPI20_order_amendment_70.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function setup() {
}

if (isConcurrentSetup()) {
return dynamicFixture.getData();
return dynamicFixture.getData(testConfiguration.vus, testConfiguration.iterations, 2);
}
}

Expand Down Expand Up @@ -83,7 +83,6 @@ export default function (data) {

const cartsResource = new CartsResource(bearerToken);
group('Cancel Order Amendment', () => {
cartsResource.create('default', true);
const response = cartsResource.delete(reorderedIdCart);
metrics['SAPI21_delete_carts'].add(response.timings.duration);
});
Expand Down

0 comments on commit 0b87940

Please sign in to comment.