TC-DISC-12
Functional
changes data Decreasing the promotional price after it starts
Verify the allowed additional discount
! 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 lower price
Expected result
The price is updated
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_12()
337// Verify the allowed additional discount
338public function tc_disc_12(): void
339{
340 $targetId = (int) $_ENV['TARGET_ID'];
341
342 $currentDiscount = $this->ananas->getDiscounts(Carbon::now()->format('Y-m-d'), Carbon::now()->format('Y-m-d'));
343
344 if (count($currentDiscount['response']) > 0) {
345 $discountId = $currentDiscount['response'][0]['discountId'];
346 $discountPrice = $currentDiscount['response'][0]['discountPrice'];
347 } else {
348 $newDiscount = $this->ananas->setDiscounts([
349 'discounts' => [
350 [
351 'merchantInventoryId' => $targetId,
352 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
353 'discountPriceCurrency' => 'RSD',
354 'dateFrom' => Carbon::now()->format('d/m/Y'),
355 'dateTo' => Carbon::now()->format('d/m/Y'),
356 'discountType' => 'SALE',
357 ],
358 ],
359 ]);
360
361 $discountId = $newDiscount['response']['scheduleResult'][0]['data']['discountId'];
362 $discountPrice = (int) $_ENV['DISCOUNT_PRICE'];
363 }
364
365 $response = $this->ananas->updateDiscounts([
366 'discounts' => [
367 [
368 'discountId' => $discountId,
369 'newDateFrom' => Carbon::now()->format('d/m/Y'),
370 'newDateTo' => Carbon::now()->format('d/m/Y'),
371 'newDiscountPrice' => $discountPrice - 1,
372 'newDiscountPriceCurrency' => 'RSD',
373 'newDiscountType' => 'SALE',
374 ],
375 ],
376 ]);
377
378 $this->assertEquals(200, $response['statusCode']);
379 $this->assertEquals(1, $response['response']['updateResult'][0]['success']);
380 $this->assertEmpty($response['response']['updateResult'][0]['error']);
381}
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.