-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/common error conditions order already exists #183
base: master
Are you sure you want to change the base?
Changes from 3 commits
4f09498
4095ccc
79265c1
80cdb76
09f4927
55036f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
const { FeatureHelper } = require('../../../../helpers/feature-helper'); | ||
const { GetMatch, C1, C2, B } = require('../../../../shared-behaviours'); | ||
const { itShouldReturnAnOpenBookingError } = require('../../../../shared-behaviours/errors'); | ||
const { RequestState } = require('../../../../helpers/request-state'); | ||
const { FlowHelper } = require('../../../../helpers/flow-helper'); | ||
const { generateUuid } = require('../../../../helpers/generate-uuid'); | ||
|
||
FeatureHelper.describeFeature(module, { | ||
testCategory: 'core', | ||
testFeature: 'common-error-conditions', | ||
testFeatureImplemented: true, | ||
testIdentifier: 'order-already-exists', | ||
testName: 'Expect an OrderAlreadyExistsError if an Order UUID exists but with different OrderItems', | ||
testDescription: 'Do a successful C1, C2, B run. Then, run B again for the same Order UUID, but with different OrderItems. Expect an OrderAlreadyExistsError.', | ||
// The primary opportunity criteria to use for the primary OrderItem under test | ||
testOpportunityCriteria: 'TestOpportunityBookablePaid', | ||
// The secondary opportunity criteria to use for multiple OrderItem tests | ||
controlOpportunityCriteria: 'TestOpportunityBookablePaid', | ||
numOpportunitiesUsedPerCriteria: 1, | ||
skipMultiple: true, | ||
}, | ||
(configuration, orderItemCriteria, featureIsImplemented, logger) => { | ||
describe('OrderAlreadyExistsError at B', () => { | ||
const uuid = generateUuid(); | ||
const state = new RequestState(logger, { uuid }); | ||
const flow = new FlowHelper(state); | ||
|
||
// Get All Opportunities | ||
beforeAll(async () => { | ||
await state.fetchOpportunities(orderItemCriteria); | ||
}); | ||
|
||
describe('Get Opportunity Feed Items for first run', () => { | ||
(new GetMatch({ | ||
state, flow, logger, orderItemCriteria, | ||
})) | ||
.beforeSetup() | ||
.successChecks() | ||
.validationTests(); | ||
}); | ||
|
||
// Run C1 | ||
describe('C1', () => { | ||
(new C1({ | ||
state, flow, logger, | ||
})) | ||
.beforeSetup() | ||
.successChecks() | ||
.validationTests(); | ||
}); | ||
|
||
// Run C2 | ||
describe('C2', () => { | ||
(new C2({ | ||
state, flow, logger, | ||
})) | ||
.beforeSetup() | ||
.successChecks() | ||
.validationTests(); | ||
}); | ||
|
||
describe('B first time ', function () { | ||
(new B({ | ||
state, flow, logger, | ||
})) | ||
.beforeSetup() | ||
.successChecks() | ||
.validationTests(); | ||
}); | ||
|
||
it('should get a new set of OrderItems and try booking again, but with the same UUID', async () => { | ||
// The following requests are not using the helper functions that are used above. This is because | ||
// those requests are cached (using pMemoize) and therefore would not go back to the Booking System. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @civsiv I think that these should use the helper functions because they provide useful stuff like consistent test reporting messages (and structure) as well as performing validation tests (which should always be performed on responses If you look at core/amending-order-quote/implemented/amend-c1-test.js, there is an approach there that allows it. UUID can be shared between states by including it in new RequestState |
||
|
||
// Get new OrderItems | ||
await state.getMatch(); | ||
|
||
// Try B again with same UUID specified in state | ||
await state.putOrder(); | ||
}); | ||
|
||
itShouldReturnAnOpenBookingError('OrderAlreadyExistsError', 500, () => state.bResponse); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,12 @@ const { expect } = require('chakram'); | |
const sharedValidationTests = require('./validation'); | ||
|
||
class B { | ||
/** | ||
* @param {object} args | ||
* @param {InstanceType<import('../helpers/request-state')['RequestState']>} args.state | ||
* @param {import('../helpers/flow-helper').FlowHelperType} args.flow | ||
* @param {import('../helpers/logger').BaseLoggerType} args.logger | ||
*/ | ||
Comment on lines
+5
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yasss |
||
constructor({ state, flow, logger }) { | ||
this.state = state; | ||
this.flow = flow; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fix this #184 next time we change this, so we don't need to update this in each PR