TC-DISC-13
Negative
changes data Changing the promotion type after it starts
Verify that the type cannot be changed
! 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
- Promotion has started
- Send a different type
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
A dry run builds every request without sending it; responses come from a local stub.
Test code
mirrors tests/DiscountsTest.php::tc_disc_13()
383// Verify that the type cannot be changed
384public function tc_disc_13(): void
385{
386 $targetId = (int) $_ENV['TARGET_ID'];
387
388 $currentDiscount = $this->ananas->getDiscounts(Carbon::now()->format('Y-m-d'), Carbon::now()->format('Y-m-d'));
389
390 if (count($currentDiscount['response']) > 0) {
391 $discountId = $currentDiscount['response'][0]['discountId'];
392 $discountPrice = $currentDiscount['response'][0]['discountPrice'];
393 } else {
394 $newDiscount = $this->ananas->setDiscounts([
395 'discounts' => [
396 [
397 'merchantInventoryId' => $targetId,
398 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
399 'discountPriceCurrency' => 'RSD',
400 'dateFrom' => Carbon::now()->format('d/m/Y'),
401 'dateTo' => Carbon::now()->format('d/m/Y'),
402 'discountType' => 'SALE',
403 ],
404 ],
405 ]);
406
407 $discountId = $newDiscount['response']['scheduleResult'][0]['data']['discountId'];
408 $discountPrice = (int) $_ENV['DISCOUNT_PRICE'];
409 }
410
411 $response = $this->ananas->updateDiscounts([
412 'discounts' => [
413 [
414 'discountId' => $discountId,
415 'newDateFrom' => Carbon::now()->format('d/m/Y'),
416 'newDateTo' => Carbon::now()->format('d/m/Y'),
417 'newDiscountPrice' => $discountPrice,
418 'newDiscountPriceCurrency' => 'RSD',
419 'newDiscountType' => 'CLEARANCE_SALE',
420 ],
421 ],
422 ]);
423
424 $this->assertEquals(200, $response['statusCode']);
425 $this->assertNotEquals(1, $response['response']['updateResult'][0]['success']);
426 $this->assertNotEmpty($response['response']['updateResult'][0]['error']);
427}
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.