Ananas APItest bench
staging api.qa2.ananastest.com
TC-DISC-10 Functional changes data

Modifying a promotion before it starts

Verify modification before the start

! Documented discrepancy · errors.txt

All tests in this section: The discount tests are tricky because they involve persistent changes to the real data. To mitigate this problem and automate the tests, every discount is cancelled after the test. The ongoing promotion cannot be cancelled, and therefore have to be reused for these tests.

Specification · xlsx

Steps

  1. Set up a promotion
  2. Send a modification before it starts

Expected result

The system accepts the changes

Endpoints

POST · PUT · GET /payment/api/v1/merchant-integration/discountsPUT /payment/api/v1/merchant-integration/discounts/{id}/cancellations

Run

API_URL
https://api.qa2.ananastest.com
TARGET_ID
2555660
DISCOUNT_PRICE
10000

Change parameters

A dry run builds every request without sending it; responses come from a local stub.

Test code

mirrors tests/DiscountsTest.php::tc_disc_10()
249// Verify modification before the start
250public function tc_disc_10(): void
251{
252 $targetId = (int) $_ENV['TARGET_ID'];
253
254 $responseOne = $this->ananas->setDiscounts([
255 'discounts' => [
256 [
257 'merchantInventoryId' => $targetId,
258 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
259 'discountPriceCurrency' => 'RSD',
260 'dateFrom' => Carbon::now()->addDays(10)->format('d/m/Y'),
261 'dateTo' => Carbon::now()->addDays(11)->format('d/m/Y'),
262 'discountType' => 'SALE',
263 ],
264 ],
265 ]);
266
267 $this->assertEquals(200, $responseOne['statusCode']);
268 $this->assertEquals(1, $responseOne['response']['scheduleResult'][0]['success']);
269
270 $discountId = $responseOne['response']['scheduleResult'][0]['data']['discountId'];
271
272 $responseTwo = $this->ananas->updateDiscounts([
273 'discounts' => [
274 [
275 'discountId' => $discountId,
276 'newDateFrom' => Carbon::now()->addDays(11)->format('d/m/Y'),
277 'newDateTo' => Carbon::now()->addDays(12)->format('d/m/Y'),
278 'newDiscountPrice' => (int) $_ENV['DISCOUNT_PRICE'] + 1,
279 'newDiscountPriceCurrency' => 'RSD',
280 'newDiscountType' => 'SALE',
281 ],
282 ],
283 ]);
284
285 $this->assertEquals(200, $responseTwo['statusCode']);
286 $this->assertEquals(1, $responseTwo['response']['updateResult'][0]['success']);
287
288 $this->ananas->cancelDiscount($discountId);
289}

web/app/Scenarios/DiscountsScenarios.php · line numbers refer to this file

Not run yet. Run it against the API, or do a dry run to see the requests it would send.