Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/upgrade-puppeteer' into …
Browse files Browse the repository at this point in the history
…feature/docker-and-package-upgrades-new
  • Loading branch information
lukehesluke committed Oct 9, 2023
2 parents 1b64547 + 9b6ff78 commit 4c5603c
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { omit } = require('lodash');
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { Common } = require('../../../../shared-behaviours');

FeatureHelper.describeFeature(module, {
testCategory: 'payment',
Expand Down Expand Up @@ -28,6 +29,8 @@ FeatureHelper.describeFeature(module, {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(bookRecipe);
describe('idempotent repeat B', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB, () => {
Common.itIdempotentBShouldHaveOutputEqualToFirstB(bookRecipe.b, idempotentRepeatB);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { omit } = require('lodash');
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { Common } = require('../../../../shared-behaviours');

FeatureHelper.describeFeature(module, {
testCategory: 'payment',
Expand Down Expand Up @@ -29,6 +30,8 @@ FeatureHelper.describeFeature(module, {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(bookRecipe);
describe('idempotent repeat B', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB, () => {
Common.itIdempotentBShouldHaveOutputEqualToFirstB(bookRecipe.b, idempotentRepeatB);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { omit } = require('lodash');
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { Common } = require('../../../../shared-behaviours');

FeatureHelper.describeFeature(module, {
testCategory: 'payment',
Expand Down Expand Up @@ -31,6 +32,8 @@ FeatureHelper.describeFeature(module, {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(bookRecipe);
describe('idempotent repeat B', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB, () => {
Common.itIdempotentBShouldHaveOutputEqualToFirstB(bookRecipe.b, idempotentRepeatB);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { omit } = require('lodash');
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { Common } = require('../../../../shared-behaviours');

const { IMPLEMENTED_FEATURES } = global;

Expand Down Expand Up @@ -39,6 +40,8 @@ FeatureHelper.describeFeature(module, {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(bookRecipe);
describe('idempotent repeat B', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB, () => {
Common.itIdempotentBShouldHaveOutputEqualToFirstB(bookRecipe.b, idempotentRepeatB);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { omit } = require('lodash');
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { Common } = require('../../../../shared-behaviours');

FeatureHelper.describeFeature(module, {
testCategory: 'tax',
Expand Down Expand Up @@ -30,6 +31,8 @@ FeatureHelper.describeFeature(module, {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(bookRecipe);
describe('idempotent repeat B', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB, () => {
Common.itIdempotentBShouldHaveOutputEqualToFirstB(bookRecipe.b, idempotentRepeatB);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { expect } = require('chai');

/**
* @typedef {import('chakram').ChakramResponse} ChakramResponse
*/
Expand All @@ -24,7 +26,26 @@ function isResponse(response) {
return statusCode >= 200 && statusCode < 600;
}

/**
* @param {ChakramResponse} firstResponse
* @param {ChakramResponse} idempotentSecondResponse
* @param {string} [message]
*/
function expectSuccessfulIdempotentRequestResponsesToBeDeepEqual(firstResponse, idempotentSecondResponse, message) {
/**
* @param {ChakramResponse} response
*/
const prune = response => ({
response: {
statusCode: response.response.statusCode,
},
body: response.body,
});
expect(prune(idempotentSecondResponse)).to.deep.equal(prune(firstResponse), message);
}

module.exports = {
isResponse20x,
isResponse,
expectSuccessfulIdempotentRequestResponsesToBeDeepEqual,
};
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class BookRecipe {
getAssertOpportunityCapacityAfterBook() { return this._assertOpportunityCapacityAfterBook; }
}

/**
* @typedef {InstanceType<typeof BookRecipe>} BookRecipeType
*/

module.exports = {
BookRecipe,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { utils: { getRemainingCapacity } } = require('@openactive/test-interface-criteria');
const { expect } = require('chai');
const { BFlowStage } = require('../helpers/flow-stages/b');
const { expectSuccessfulIdempotentRequestResponsesToBeDeepEqual } = require('../helpers/chakram-response-utils');

/**
* @typedef {import('chakram').ChakramResponse} ChakramResponse
Expand Down Expand Up @@ -152,6 +154,25 @@ class Common {
expect(apiResponseCapacity).to.equal(feedCapacity);
});
}

/**
* When an idempotent B request has been made after a successful booking, the response to both
* requests should be identical.
*
* @param {BFlowStage} firstB
* @param {BFlowStage | import('../helpers/flow-stages/book-recipe').BookRecipeType} idempotentB
*/
static itIdempotentBShouldHaveOutputEqualToFirstB(firstB, idempotentB) {
it('should get a same response as with the first B', () => {
const actualIdempotentB = (idempotentB instanceof BFlowStage)
? idempotentB
: idempotentB.b;
expectSuccessfulIdempotentRequestResponsesToBeDeepEqual(
firstB.getOutput().httpResponse,
actualIdempotentB.getOutput().httpResponse,
);
});
}
}

/**
Expand Down

0 comments on commit 4c5603c

Please sign in to comment.