Ananas APItest bench
staging api.qa2.ananastest.com
TC-DISC-11 Negative changes data

Increasing the promotional price after it starts

Verify the price increase restriction

! 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. Promotion has started
  2. Send a higher price

Expected result

The system rejects the request

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_11()
291// Verify the price increase restriction
292public function tc_disc_11(): void
293{
294 $targetId = (int) $_ENV['TARGET_ID'];
295
296 $currentDiscount = $this->ananas->getDiscounts(Carbon::now()->format('Y-m-d'), Carbon::now()->format('Y-m-d'));
297
298 if (count($currentDiscount['response']) > 0) {
299 $discountId = $currentDiscount['response'][0]['discountId'];
300 $discountPrice = $currentDiscount['response'][0]['discountPrice'];
301 } else {
302 $newDiscount = $this->ananas->setDiscounts([
303 'discounts' => [
304 [
305 'merchantInventoryId' => $targetId,
306 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
307 'discountPriceCurrency' => 'RSD',
308 'dateFrom' => Carbon::now()->format('d/m/Y'),
309 'dateTo' => Carbon::now()->format('d/m/Y'),
310 'discountType' => 'SALE',
311 ],
312 ],
313 ]);
314
315 $discountId = $newDiscount['response']['scheduleResult'][0]['data']['discountId'];
316 $discountPrice = (int) $_ENV['DISCOUNT_PRICE'];
317 }
318
319 $response = $this->ananas->updateDiscounts([
320 'discounts' => [
321 [
322 'discountId' => $discountId,
323 'newDateFrom' => Carbon::now()->format('d/m/Y'),
324 'newDateTo' => Carbon::now()->format('d/m/Y'),
325 'newDiscountPrice' => $discountPrice + 1,
326 'newDiscountPriceCurrency' => 'RSD',
327 'newDiscountType' => 'SALE',
328 ],
329 ],
330 ]);
331
332 $this->assertEquals(200, $response['statusCode']);
333 $this->assertNotEquals(1, $response['response']['updateResult'][0]['success']);
334 $this->assertNotEmpty($response['response']['updateResult'][0]['error']);
335}

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.