From 9e01fe7e41bb34b23473c493a0b0354201cffecd Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 21 Nov 2024 15:42:21 +0100 Subject: [PATCH] refactor(api): improve scenario simulator acceptance test suite --- .../scenario-simulator-controller_test.js | 55 +++++++------------ 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js b/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js index 5731e2fab0f..9b1bb68bb9f 100644 --- a/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js +++ b/api/tests/acceptance/application/scenario-simulator/scenario-simulator-controller_test.js @@ -146,42 +146,25 @@ describe('Acceptance | Controller | scenario-simulator-controller', function () }; }); - describe('when a number of challenges to pass is specified', function () { - it('should return a payload with the same number of simulation scenario results', async function () { - // given - options.headers.authorization = adminAuthorization; - options.payload = validPayload; - - // when - const response = await server.inject(options); - - // then - expect(response).to.have.property('statusCode', 200); - const parsedResponse = parseJsonStream(response); - expect(parsedResponse[0].simulationReport).to.have.lengthOf(2); - expect(parsedResponse[0].simulationReport[0].challengeId).to.exist; - expect(parsedResponse[0].simulationReport[0].capacity).to.exist; - expect(parsedResponse[0].simulationReport[0].difficulty).to.exist; - expect(parsedResponse[0].simulationReport[0].discriminant).to.exist; - expect(parsedResponse[0].simulationReport[0].reward).to.exist; - expect(parsedResponse[0].simulationReport[0].errorRate).to.exist; - expect(parsedResponse[0].simulationReport[0].answerStatus).to.exist; - }); - }); - - describe('when the scenario is capacity', function () { - it('should return a payload with simulation the capacity scenario results', async function () { - // given - options.headers.authorization = adminAuthorization; - options.payload = validPayload; - - // when - const response = await server.inject(options); - - // then - const parsedResponse = parseJsonStream(response); - expect(parsedResponse[0].simulationReport).to.have.lengthOf(2); - }); + it('should return a report with the same number of simulation scenario reports as the number of challenges in the configuration', async function () { + // given + options.headers.authorization = adminAuthorization; + options.payload = validPayload; + + // when + const response = await server.inject(options); + + // then + expect(response).to.have.property('statusCode', 200); + const parsedResponse = parseJsonStream(response); + expect(parsedResponse[0].simulationReport).to.have.lengthOf(2); + expect(parsedResponse[0].simulationReport[0].challengeId).to.exist; + expect(parsedResponse[0].simulationReport[0].capacity).to.exist; + expect(parsedResponse[0].simulationReport[0].difficulty).to.exist; + expect(parsedResponse[0].simulationReport[0].discriminant).to.exist; + expect(parsedResponse[0].simulationReport[0].reward).to.exist; + expect(parsedResponse[0].simulationReport[0].errorRate).to.exist; + expect(parsedResponse[0].simulationReport[0].answerStatus).to.exist; }); describe('when there is no connected user', function () {