Skip to content
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

Coverage/reseller and nobroker role #298

Merged
merged 14 commits into from
Feb 5, 2021
4 changes: 2 additions & 2 deletions packages/openactive-integration-tests/config/default.json
Expand Up @@ -47,9 +47,9 @@
"access-pass-image": true,
"access-pass-barcode-seller-provided": true,
"access-pass-barcode-broker-provided": null,
"reseller-broker": null,
"reseller-broker": true,
"reseller-broker-tax-calculation": null,
"no-broker": null,
"no-broker": true,
"business-to-consumer-tax-calculation-net": null,
"business-to-consumer-tax-calculation-gross": null,
"business-to-business-tax-calculation-net": null,
Expand Down
4 changes: 2 additions & 2 deletions packages/openactive-integration-tests/test/features/README.md
Expand Up @@ -52,8 +52,8 @@ The tests for these features are fully stubbed, and are not yet implemented.
| advanced-payment | DynamicPayment ([dynamic-payment](./advanced-payment/dynamic-payment/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#dynamicpayment) | Support for fully dynamic pricing, where price is not known at the point of purchase | |
| advanced-payment | Offer overrides ([offer-overrides](./advanced-payment/offer-overrides/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#offer-overrides) | Offer prices overridden to allow for business models with variable pricing | |
| authentication | Booking Partner Authentication for Multiple Seller Systems ([booking-partner-authentication](./authentication/booking-partner-authentication/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#openid-connect-booking-partner-authentication-for-multiple-seller-systems) | OAuth based authentication for Sellers | |
| broker-role | NoBroker mode ([no-broker](./broker-role/no-broker/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#nobroker) | Support for NoBroker mode, for example for operators to use the Open Booking API to power their own websites | |
| broker-role | ResellerBroker mode ([reseller-broker](./broker-role/reseller-broker/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#resellerbroker) | Support for ResellerBroker mode | |
| broker-role | NoBroker mode ([no-broker](./broker-role/no-broker/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#nobroker) | Support for NoBroker mode, for example for operators to use the Open Booking API to power their own websites | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x12 |
| broker-role | ResellerBroker mode ([reseller-broker](./broker-role/reseller-broker/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#resellerbroker) | Support for ResellerBroker mode | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x12 |
| broker-role | ResellerBroker Business-to-business Tax Calculation ([reseller-broker-tax-calculation](./broker-role/reseller-broker-tax-calculation/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#scope-of-specification) | Tax calculation for ResellerBroker (business-to-business) | |
| cancellation | latestCancellationBeforeStartDate cancellation window ([cancellation-window](./cancellation/cancellation-window/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#customer-requested-cancellation) | A defined window before the event occurs where it can be cancelled without fees | |
| cancellation | Seller Requested Cancellation ([seller-requested-cancellation](./cancellation/seller-requested-cancellation/README.md)) | [Optional](https://www.openactive.io/open-booking-api/EditorsDraft/#seller-requested-cancellation) | Cancellation triggered by the Seller through the Booking System | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x4 |
Expand Down
Expand Up @@ -7,9 +7,30 @@ Support for NoBroker mode, for example for operators to use the Open Booking API
https://www.openactive.io/open-booking-api/EditorsDraft/#nobroker

Coverage Status: **none**
### Test prerequisites
Opportunities that match the following criteria must exist in the booking system (for each configured `bookableOpportunityTypesInScope`) for the configured primary Seller in order to use `useRandomOpportunities: true`. Alternatively the following `testOpportunityCriteria` values must be supported by the [test interface](https://openactive.io/test-interface/) of the booking system for `useRandomOpportunities: false`.

[TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x12

*Note the test coverage for this feature is currently nonexistent. The test suite does not yet include non-stubbed tests for this feature.*


## 'Implemented' tests

Update `default.json` within `packages/openactive-integration-tests/config/` as follows to enable 'Implemented' testing for this feature:

```json
"implementedFeatures": {
...
"no-broker": true,
...
}
```

| Identifier | Name | Description | Prerequisites per Opportunity Type |
|------------|------|-------------|---------------|
| [broker-included-nobroker-mode](./implemented/broker-included-nobroker-mode-test.js) | Broker included in Order in NoBroker mode | Request shoud fail if broker is included in Order in NoBroker mode for C1, C2 & B request. | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x4 |
| [customer-included-nobroker-mode](./implemented/customer-included-nobroker-mode-test.js) | Customer included in Order in NoBroker mode | Request shoud succeed if broker is excluded and customer is included in Order in NoBroker mode for C1, C2 & B request. | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x4 |
| [customer-not-included-nobroker-mode](./implemented/customer-not-included-nobroker-mode-test.js) | Customer not included in Order in NoBroker mode | Request shoud fail if customer is not included in Order in NoBroker mode for C2 & B requests. | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x4 |


@@ -0,0 +1,58 @@
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { runFlowStageAndExpectIncompleteBrokerDetailsError } = require('../../../../shared-behaviours/errors');

// /**
// * @typedef {import('../../../../helpers/flow-stages/c1').C1FlowStageType} C1FlowStageType
// * @typedef {import('../../../../helpers/flow-stages/c2').C2FlowStageType} C2FlowStageType
// * @typedef {import('../../../../helpers/flow-stages/b').BFlowStageType} BFlowStageType
// */

// /**
// * @param {C1FlowStageType | C2FlowStageType | BFlowStageType} flowStage
// */
// function runFlowStageAndExpectIncompleteBrokerDetailsError(flowStage) {
// FlowStageUtils.describeRunAndCheckIsValid(flowStage, () => {
// itShouldReturnAnOpenBookingError('IncompleteBrokerDetailsError', 400, () => flowStage.getOutput().httpResponse);
// });
// }

FeatureHelper.describeFeature(module, {
testCategory: 'broker-role',
testFeature: 'no-broker',
testFeatureImplemented: true,
testIdentifier: 'broker-included-nobroker-mode',
testName: 'Broker included in Order in NoBroker mode',
testDescription: 'Request shoud fail if broker is included in Order in NoBroker mode for C1, C2 & B request.',
// The primary opportunity criteria to use for the primary OrderItem under test
testOpportunityCriteria: 'TestOpportunityBookable',
// The secondary opportunity criteria to use for multiple OrderItem tests
controlOpportunityCriteria: 'TestOpportunityBookable',
},
function (configuration, orderItemCriteriaList, featureIsImplemented, logger) {
describe('Booking should fail because Broker is included in Order in NoBroker mode', () => {
describe('at C1', () => {
// broker is included, by default, in C1 request
const { fetchOpportunities, c1 } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, { brokerRole: 'https://openactive.io/NoBroker' });
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
runFlowStageAndExpectIncompleteBrokerDetailsError(c1);
});
describe('at C2', () => {
// broker is included, by default, in C2 request
const { fetchOpportunities, c1, c2 } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, { brokerRole: 'https://openactive.io/NoBroker', c1ReqTemplateRef: 'noBroker' });
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
runFlowStageAndExpectIncompleteBrokerDetailsError(c2);
});
describe('at B', () => {
// broker is included, by default, in B request
const { fetchOpportunities, c1, c2, b } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, {
brokerRole: 'https://openactive.io/NoBroker', c1ReqTemplateRef: 'noBroker', c2ReqTemplateRef: 'noBroker',
});
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c2);
runFlowStageAndExpectIncompleteBrokerDetailsError(b);
});
});
});
@@ -0,0 +1,27 @@
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');

FeatureHelper.describeFeature(module, {
testCategory: 'broker-role',
testFeature: 'no-broker',
testFeatureImplemented: true,
testIdentifier: 'customer-included-nobroker-mode',
testName: 'Customer included in Order in NoBroker mode',
testDescription: 'Request shoud succeed if broker is excluded and customer is included in Order in NoBroker mode for C1, C2 & B request.',
// The primary opportunity criteria to use for the primary OrderItem under test
testOpportunityCriteria: 'TestOpportunityBookable',
// The secondary opportunity criteria to use for multiple OrderItem tests
controlOpportunityCriteria: 'TestOpportunityBookable',
},
function (configuration, orderItemCriteriaList, featureIsImplemented, logger) {
const { fetchOpportunities, c1, c2, b } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, {
c1ReqTemplateRef: 'noBroker', c2ReqTemplateRef: 'noBroker', bReqTemplateRef: 'noBroker', brokerRole: 'https://openactive.io/NoBroker',
});

describe('In NoBroker mode, booking should succeed if Broker is excluded if Customer is included in Order', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c2);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(b);
});
});
@@ -0,0 +1,38 @@
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { runFlowStageAndExpectIncompleteCustomerDetailsError } = require('../../../../shared-behaviours/errors');

FeatureHelper.describeFeature(module, {
testCategory: 'broker-role',
testFeature: 'no-broker',
testFeatureImplemented: true,
testIdentifier: 'customer-not-included-nobroker-mode',
testName: 'Customer not included in Order in NoBroker mode',
testDescription: 'Request shoud fail if customer is not included in Order in NoBroker mode for C2 & B requests.',
// The primary opportunity criteria to use for the primary OrderItem under test
testOpportunityCriteria: 'TestOpportunityBookable',
// The secondary opportunity criteria to use for multiple OrderItem tests
controlOpportunityCriteria: 'TestOpportunityBookable',
},
function (configuration, orderItemCriteriaList, featureIsImplemented, logger) {
describe('Booking should fail even if Customer is not included in Order, because we are in NoBroker mode', () => {
// Note that we ignore testing at C1 because C1 has no customer anyway
describe('at C2', () => {
const { fetchOpportunities, c1, c2 } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, {
c1ReqTemplateRef: 'noBroker', c2ReqTemplateRef: 'noCustomerAndNoBroker', brokerRole: 'https://openactive.io/NoBroker',
});
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
runFlowStageAndExpectIncompleteCustomerDetailsError(c2);
});
describe('at B', () => {
const { fetchOpportunities, c1, c2, b } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, {
c1ReqTemplateRef: 'noBroker', c2ReqTemplateRef: 'noBroker', bReqTemplateRef: 'noCustomerAndNoBroker', brokerRole: 'https://openactive.io/NoBroker',
});
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c2);
runFlowStageAndExpectIncompleteCustomerDetailsError(b);
});
});
});
Expand Up @@ -7,9 +7,30 @@ Support for ResellerBroker mode
https://www.openactive.io/open-booking-api/EditorsDraft/#resellerbroker

Coverage Status: **none**
### Test prerequisites
Opportunities that match the following criteria must exist in the booking system (for each configured `bookableOpportunityTypesInScope`) for the configured primary Seller in order to use `useRandomOpportunities: true`. Alternatively the following `testOpportunityCriteria` values must be supported by the [test interface](https://openactive.io/test-interface/) of the booking system for `useRandomOpportunities: false`.

[TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x12

*Note the test coverage for this feature is currently nonexistent. The test suite does not yet include non-stubbed tests for this feature.*


## 'Implemented' tests

Update `default.json` within `packages/openactive-integration-tests/config/` as follows to enable 'Implemented' testing for this feature:

```json
"implementedFeatures": {
...
"reseller-broker": true,
...
}
```

| Identifier | Name | Description | Prerequisites per Opportunity Type |
|------------|------|-------------|---------------|
| [broker-not-included-resellerbroker-mode](./implemented/broker-not-included-resellerbroker-mode-test.js) | Broker not included in Order in ResellerBroker mode | Request shoud fail if broker is not included in Order in ResellerBroke mode for B request. | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x4 |
| [customer-included-resellerbroker-mode](./implemented/customer-included-resellerbroker-mode-test.js) | Customer included in Order in ResellerBroker mode | Request shoud succeed if broker and customer are included in Order in ResellerBroke mode for B request. | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x4 |
| [customer-not-included-resellerbroker-mode](./implemented/customer-not-included-resellerbroker-mode-test.js) | Customer not included in Order in ResellerBroker mode | Request shoud succeed if customer is not included in Order in ResellerBroke mode for B request. | [TestOpportunityBookable](https://openactive.io/test-interface#TestOpportunityBookable) x4 |


@@ -0,0 +1,38 @@
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { runFlowStageAndExpectIncompleteBrokerDetailsError } = require('../../../../shared-behaviours/errors');

FeatureHelper.describeFeature(module, {
testCategory: 'broker-role',
testFeature: 'reseller-broker',
testFeatureImplemented: true,
testIdentifier: 'broker-not-included-resellerbroker-mode',
testName: 'Broker not included in Order in ResellerBroker mode',
testDescription: 'Request shoud fail if broker is not included in Order in ResellerBroke mode for B request.',
// The primary opportunity criteria to use for the primary OrderItem under test
testOpportunityCriteria: 'TestOpportunityBookable',
// The secondary opportunity criteria to use for multiple OrderItem tests
controlOpportunityCriteria: 'TestOpportunityBookable',
},
function (configuration, orderItemCriteriaList, featureIsImplemented, logger) {
describe('Booking should fail because Broker is not included in Order in ResellerBroker mode', () => {
describe('at C1', () => {
const { fetchOpportunities, c1 } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, { c1ReqTemplateRef: 'noBroker', brokerRole: 'https://openactive.io/ResellerBroker' });
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
runFlowStageAndExpectIncompleteBrokerDetailsError(c1);
});
describe('at C2', () => {
const { fetchOpportunities, c1, c2 } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, { c2ReqTemplateRef: 'noBroker', brokerRole: 'https://openactive.io/ResellerBroker' });
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
runFlowStageAndExpectIncompleteBrokerDetailsError(c2);
});
describe('at B', () => {
const { fetchOpportunities, c1, c2, b } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, { bReqTemplateRef: 'noBroker', brokerRole: 'https://openactive.io/ResellerBroker' });
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c2);
runFlowStageAndExpectIncompleteBrokerDetailsError(b);
});
});
});
@@ -0,0 +1,25 @@
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');

FeatureHelper.describeFeature(module, {
testCategory: 'broker-role',
testFeature: 'reseller-broker',
testFeatureImplemented: true,
testIdentifier: 'customer-included-resellerbroker-mode',
testName: 'Customer included in Order in ResellerBroker mode',
testDescription: 'Request shoud succeed if broker and customer are included in Order in ResellerBroke mode for B request.',
// The primary opportunity criteria to use for the primary OrderItem under test
testOpportunityCriteria: 'TestOpportunityBookable',
// The secondary opportunity criteria to use for multiple OrderItem tests
controlOpportunityCriteria: 'TestOpportunityBookable',
},
function (configuration, orderItemCriteriaList, featureIsImplemented, logger) {
const { fetchOpportunities, c1, c2, b } = FlowStageRecipes.initialiseSimpleC1C2BFlow(orderItemCriteriaList, logger, { brokerRole: 'https://openactive.io/ResellerBroker' });

describe('Booking should succeed if Broker and Customer are included in Order, because we are in ResellerBroker mode', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c1);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(c2);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(b);
});
});