TC-DISC-03
Positive
changes data Valid SEASONAL_SALE in the summer period
Verify the allowed start window
! 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
- Send a SEASONAL_SALE starting between July 1–15
Expected result
HTTP 200; promotion accepted
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_03()
63// Verify the allowed start window
64public function tc_disc_03(): void
65{
66 $targetId = (int) $_ENV['TARGET_ID'];
67
68 $response = $this->ananas->setDiscounts([
69 'discounts' => [
70 [
71 'merchantInventoryId' => $targetId,
72 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
73 'discountPriceCurrency' => 'RSD',
74 'dateFrom' => Carbon::create(Carbon::now()->year + 1, 7, 1)->format('d/m/Y'),
75 'dateTo' => Carbon::create(Carbon::now()->year + 1, 7, 15)->format('d/m/Y'),
76 'discountType' => 'SEASONAL_SALE',
77 ],
78 ],
79 ]);
80
81 $this->assertEquals(200, $response['statusCode']);
82 $this->assertEquals(1, $response['response']['scheduleResult'][0]['success']);
83
84 $discountId = $response['response']['scheduleResult'][0]['data']['discountId'];
85 $this->ananas->cancelDiscount($discountId);
86}
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.