-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CC-34716: Added tests for order-amendment.
- Loading branch information
Showing
11 changed files
with
319 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { SharedCheckoutScenario } from '../../../../cross-product/sapi/scenarios/checkout/shared-checkout-scenario.js'; | ||
|
||
export class CheckoutScenario extends SharedCheckoutScenario { | ||
_getPaymentProviderName() { | ||
return 'DummyPayment'; | ||
_getPaymentProviderName(isMpPaymentProvider = true) { | ||
return isMpPaymentProvider ? 'DummyPayment' : 'DummyPayment'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/cross-product/sapi/scenarios/order-amendment/shared-order-amendment-scenario.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { AbstractScenario } from '../../../../abstract-scenario.js'; | ||
import { group } from 'k6'; | ||
|
||
export class SharedOrderAmendmentScenario extends AbstractScenario { | ||
execute(customerEmail, orderId) { | ||
let self = this; | ||
group('Order Amendment', function () { | ||
self.haveOrderAmendment(customerEmail, orderId); | ||
}); | ||
} | ||
|
||
haveOrderAmendment(customerEmail, orderId) { | ||
this._ensureOrderStateState(customerEmail, orderId, 'payment pending'); | ||
|
||
const cartReorderResponse = this.http.sendPostRequest( | ||
this.http.url`${this.getStorefrontApiBaseUrl()}/cart-reorder`, | ||
JSON.stringify(this._getCartReorderAttributes(orderId)), | ||
this.cartHelper.getParamsWithAuthorization(customerEmail), | ||
false | ||
); | ||
|
||
this.assertionsHelper.assertResponseStatus(cartReorderResponse, 201); | ||
|
||
return JSON.parse(cartReorderResponse.body); | ||
} | ||
|
||
_ensureOrderStateState(customerEmail, orderId, state, maxRetries = 5) { | ||
let retries = 0; | ||
let order; | ||
|
||
do { | ||
order = this._getOrder(customerEmail, orderId); | ||
if (order.data.attributes.itemStates[0] !== state) { | ||
this.dynamicFixturesHelper.haveConsoleCommands(['console oms:check-condition', 'console oms:check-timeout']); | ||
} | ||
retries++; | ||
} while (order.data.attributes.itemStates[0] !== state && retries < maxRetries); | ||
|
||
if (retries === maxRetries) { | ||
throw new Error(`Order state is not ${state} after ${maxRetries} retries`); | ||
} | ||
} | ||
|
||
_getOrder(customerEmail, orderId) { | ||
let self = this; | ||
const orderResponse = self.http.sendGetRequest( | ||
self.http.url`${self.getStorefrontApiBaseUrl()}/orders/${orderId}`, | ||
self.cartHelper.getParamsWithAuthorization(customerEmail), | ||
false | ||
); | ||
self.assertionsHelper.assertResponseStatus(orderResponse, 200); | ||
|
||
return JSON.parse(orderResponse.body); | ||
} | ||
|
||
_getCartReorderAttributes(orderId) { | ||
return { | ||
data: { | ||
type: 'cart-reorder', | ||
attributes: { | ||
orderReference: orderId, | ||
isAmendment: true | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.