Skip to content

Commit

Permalink
feat(integration-tests): Make ShapeExpressions config-toggleable (#588)
Browse files Browse the repository at this point in the history
As it is an experimental feature

---------

Co-authored-by: Nick Evans <[email protected]>
  • Loading branch information
lukehesluke and nickevansuk authored Feb 22, 2024
1 parent 691f78f commit f80a4f3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
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).

## 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 @@ -36,8 +36,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

0 comments on commit f80a4f3

Please sign in to comment.