Ananas APItest bench
staging api.qa2.ananastest.com
TC-DISC-04 Positive changes data

Valid SEASONAL_SALE in the winter period

Verify the winter 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

  1. Send a SEASONAL_SALE starting between Dec 25–Jan 10

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

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_04()
88// Verify the winter start window
89public function tc_disc_04(): void
90{
91 $targetId = (int) $_ENV['TARGET_ID'];
92
93 $response = $this->ananas->setDiscounts([
94 'discounts' => [
95 [
96 'merchantInventoryId' => $targetId,
97 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
98 'discountPriceCurrency' => 'RSD',
99 'dateFrom' => Carbon::create(Carbon::now()->year + 1, 12, 25)->format('d/m/Y'),
100 'dateTo' => Carbon::create(Carbon::now()->year + 2, 1, 10)->format('d/m/Y'),
101 'discountType' => 'SEASONAL_SALE',
102 ],
103 ],
104 ]);
105
106 $this->assertEquals(200, $response['statusCode']);
107 $this->assertEquals(1, $response['response']['scheduleResult'][0]['success']);
108
109 $discountId = $response['response']['scheduleResult'][0]['data']['discountId'];
110 $this->ananas->cancelDiscount($discountId);
111}

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.