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

feat(integration-tests): Make ShapeExpressions config-toggleable #588

Merged
merged 7 commits into from
Feb 22, 2024
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
}
}
}
}
},
"useShapeExpressions": false
},
"sellers": {
"primary": {
Expand Down
14 changes: 14 additions & 0 deletions packages/openactive-integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ The value can be any string, such as `uat-ci`, or `alex-dev`.

Test results are written to `*.md` within the directory specified by `outputPath` in Markdown format.

### `useShapeExpressions`

Whether or not to use the experimental Shape Expressions feature (introduced in this [Test Interface issue](https://github.com/openactive/test-interface/issues/1)) to improve the process of requesting data matching a specific criteria.

This is off by default as it is currently an experimental feature which has not yet been included in the [Test Interface](https://openactive.io/test-interface/) specification.

If turned on, you may be able to build a simpler and more extensible:

* [Create Opportunity API](https://openactive.io/test-interface/#post-test-interfacedatasetstestdatasetidentifieropportunities) (for [controlled mode](#userandomopportunities)).
* Script for adding test data to your booking system's database from the output of the [test-data-generator script](./test-data-generator/) (for [random mode](#userandomopportunities)).

```json
"useShapeExpressions": false
```

## Reading test results

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Command line tool to generate a distribution definition of test data based on th

Test data is outputted to `./test-data/test-data.json` by default.

The data outputted by this tool can be used by a script to add sufficient test data into your [Open Booking API](https://openactive.io/open-booking-api/EditorsDraft/) implementation's database for testing when using [random mode](../README.md#userandomopportunities).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created this issue to expand on this: #589


## Usage

```bash
Expand Down
1 change: 1 addition & 0 deletions packages/openactive-integration-tests/test/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ declare global {
BOOKING_FLOWS_IN_SCOPE: { [bookingFlow in BookingFlow]: boolean }
IMPLEMENTED_FEATURES: { [featureIdentifier: string]: boolean | null };
USE_RANDOM_OPPORTUNITIES: boolean;
USE_SHAPE_EXPRESSIONS: boolean;
// Created in packages/openactive-integration-tests/documentation/generator.js
documentationGenerationMode?: boolean;
// Created in packages/openactive-integration-tests/test/setup.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { getTestDataShapeExpressions } = require('@openactive/test-interface-crit
* @typedef {import('../types/OpportunityCriteria').BookingFlow} BookingFlow
*/

const { HARVEST_START_TIME } = global;
const { HARVEST_START_TIME, USE_SHAPE_EXPRESSIONS } = global;

/**
* Create opportunity data for sending to https://openactive.io/test-interface/#post-test-interfacedatasetstestdatasetidentifieropportunities
Expand Down Expand Up @@ -39,8 +39,10 @@ function createTestInterfaceOpportunity({ opportunityType, testOpportunityCriter
'test:testOpportunityCriteria': `https://openactive.io/test-interface#${testOpportunityCriteria}`,
// e.g. OpenBookingApprovalFlow -> https://openactive.io/test-interface#OpenBookingApprovalFlow
'test:testOpenBookingFlow': `https://openactive.io/test-interface#${bookingFlow}`,
'test:testOpportunityDataShapeExpression': testDataShapeExpressions['test:testOpportunityDataShapeExpression'],
'test:testOfferDataShapeExpression': testDataShapeExpressions['test:testOfferDataShapeExpression'],
...(USE_SHAPE_EXPRESSIONS ? {
'test:testOpportunityDataShapeExpression': testDataShapeExpressions['test:testOpportunityDataShapeExpression'],
'test:testOfferDataShapeExpression': testDataShapeExpressions['test:testOfferDataShapeExpression'],
} : {}),
};
const seller = sellerId ? {
'@type': sellerType,
Expand Down
2 changes: 2 additions & 0 deletions packages/openactive-integration-tests/test/testEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const BOOKABLE_OPPORTUNITY_TYPES_IN_SCOPE = getConfigVarOrThrow('integrationTest
const BOOKING_FLOWS_IN_SCOPE = getConfigVarOrThrow('integrationTests', 'bookingFlowsInScope');
const IMPLEMENTED_FEATURES = getConfigVarOrThrow('integrationTests', 'implementedFeatures');
const USE_RANDOM_OPPORTUNITIES = getConfigVarOrThrow('integrationTests', 'useRandomOpportunities');
const USE_SHAPE_EXPRESSIONS = getConfigVarOrThrow('integrationTests', 'useShapeExpressions');

// Set NODE_TLS_REJECT_UNAUTHORIZED = '0' and suppress associated warning
const { silentlyAllowInsecureConnections } = require('./helpers/suppress-unauthorized-warning');
Expand Down Expand Up @@ -42,6 +43,7 @@ class TestEnvironment extends NodeEnvironment {
this.global.BOOKING_FLOWS_IN_SCOPE = BOOKING_FLOWS_IN_SCOPE;
this.global.IMPLEMENTED_FEATURES = IMPLEMENTED_FEATURES;
this.global.USE_RANDOM_OPPORTUNITIES = USE_RANDOM_OPPORTUNITIES;
this.global.USE_SHAPE_EXPRESSIONS = USE_SHAPE_EXPRESSIONS;
}

async teardown() {
Expand Down