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

Changing the duration after it starts

Verify that the period cannot be changed

! Documented discrepancy · errors.txt

There is no parameter named “validTo”. The attempt to change the “newDataTo” on the ongoing discount leads to success, invalidating the expected result. The only date change that leads to an error is the change to “newDataFrom”.

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. Attempt to modify validTo

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_14()
429// Verify that the period cannot be changed
430public function tc_disc_14(): void
431{
432 $targetId = (int) $_ENV['TARGET_ID'];
433
434 $currentDiscount = $this->ananas->getDiscounts(Carbon::now()->format('Y-m-d'), Carbon::now()->format('Y-m-d'));
435
436 if (count($currentDiscount['response']) > 0) {
437 $discountId = $currentDiscount['response'][0]['discountId'];
438 $discountPrice = $currentDiscount['response'][0]['discountPrice'];
439 } else {
440 $newDiscount = $this->ananas->setDiscounts([
441 'discounts' => [
442 [
443 'merchantInventoryId' => $targetId,
444 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
445 'discountPriceCurrency' => 'RSD',
446 'dateFrom' => Carbon::now()->format('d/m/Y'),
447 'dateTo' => Carbon::now()->format('d/m/Y'),
448 'discountType' => 'SALE',
449 ],
450 ],
451 ]);
452
453 $discountId = $newDiscount['response']['scheduleResult'][0]['data']['discountId'];
454 $discountPrice = (int) $_ENV['DISCOUNT_PRICE'];
455 }
456
457 $response = $this->ananas->updateDiscounts([
458 'discounts' => [
459 [
460 'discountId' => $discountId,
461 'newDateFrom' => Carbon::now()->format('d/m/Y'),
462 'newDateTo' => Carbon::now()->addDay()->format('d/m/Y'),
463 'newDiscountPrice' => $discountPrice,
464 'newDiscountPriceCurrency' => 'RSD',
465 'newDiscountType' => 'SALE',
466 ],
467 ],
468 ]);
469
470 $this->assertEquals(200, $response['statusCode']);
471 $this->assertNotEquals(1, $response['response']['updateResult'][0]['success']);
472 $this->assertNotEmpty($response['response']['updateResult'][0]['error']);
473}

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.