Skip to content

Commit

Permalink
Merge branch 'master' into feature/markdown-to-html-for-results
Browse files Browse the repository at this point in the history
  • Loading branch information
civsiv authored Feb 27, 2024
2 parents f715dba + f80a4f3 commit a203d43
Show file tree
Hide file tree
Showing 69 changed files with 5,405 additions and 1,296 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@
"NODE_APP_INSTANCE": "dev"
},
},
{
"name": "test-interface-criteria - unit tests",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/test-interface-criteria/",
"runtimeArgs": [
"--inspect-brk",
"node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "validate-feeds",
"type": "node",
Expand Down
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
6 changes: 3 additions & 3 deletions packages/openactive-broker-microservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ Config, which [Integration Tests](../openactive-integration-tests/) uses to conf

* Broker Microservice config
* Derived Broker Microservice config e.g. `bookingApiBaseUrl` is parsed from the [Dataset Site JSON](https://openactive.io/dataset-api-discovery/EditorsDraft/#embedded-json) that was loaded from the Dataset Site defined by the [`datasetSiteUrl` configuration property](#datasetsiteurl).
* Config from the `OpenActiveTestAuthKeyManager` that Broker Microservice sets up. See [openactive-openid-test-client](../openactive-openid-test-client/) for more info.
* Config from the `OpenActiveTestAuthKeyManager` that Broker Microservice sets up. See [openactive-openid-client](../openactive-openid-client/) for more info.

Here is an annotated example:

Expand Down Expand Up @@ -697,7 +697,7 @@ This is used by some [Non-Implemented tests](../openactive-integration-tests/REA

## Browser Automation for Auth Endpoints

Broker Microservice also exposes endpoints created from the `setupBrowserAutomationRoutes(..)` function from [openactive-openid-test-client](../openactive-openid-test-client/).
Broker Microservice also exposes endpoints created from the `setupBrowserAutomationRoutes(..)` function from [openactive-openid-browser-automation](../openactive-openid-browser-automation/).
These endpoints are used by [Integration Tests](../openactive-integration-tests/) for tests which check the [OpenID Connect](https://openid.net/developers/how-connect-works/) authentication flow.

## Concepts
Expand All @@ -710,7 +710,7 @@ Broker Microservice sets up and maintains auth credentials for access to the [Bo

These credentials are set up according to the auth strategy defined in the [`bookingPartners` configuration property](#bookingpartners).

To do this, Broker Microservice uses the [openactive-openid-test-client](../openactive-openid-test-client/) library.
To do this, Broker Microservice uses the [openactive-openid-client](../openactive-openid-client/) library.

### Booking System under Test

Expand Down
6 changes: 6 additions & 0 deletions packages/openactive-broker-microservice/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
7 changes: 7 additions & 0 deletions packages/openactive-integration-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
2 changes: 2 additions & 0 deletions packages/test-interface-criteria/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
extends: 'airbnb-base',
plugins: ['jest'],
env: {
node: true,
'jest/globals': true,
},
globals: {
expectAsync: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type DateTime = any;
export type Opportunity = import('../types/Opportunity').Opportunity;
export type Offer = import('../types/Offer').Offer;
export type Options = import('../types/Options').Options;
Expand Down Expand Up @@ -76,7 +75,7 @@ export function remainingCapacityMustBeAtLeastTwo(opportunity: import("../types/
export function mustRequireAttendeeDetails(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function mustNotRequireAttendeeDetails(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function mustAllowProposalAmendment(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function startDateMustBe2HrsInAdvance(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function startDateMustBeOver2HrsInAdvance(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function endDateMustBeInThePast(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function eventStatusMustNotBeCancelledOrPostponed(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function mustNotBeOpenBookingInAdvanceUnavailable(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
Expand Down Expand Up @@ -112,3 +111,4 @@ export function extendTestDataShape(baseTestDataShape: TestDataShape, extraTestD
* @returns {Criteria['offerConstraints'][number]}
*/
export function createCriteriaOfferConstraint(name: string, constraint: OfferConstraint): Criteria['offerConstraints'][number];
import { DateTime } from "luxon/src/datetime";
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@ export namespace shapeConstraintRecipes {
'schema:price': import("./types/TestDataShape").NumericNodeConstraint;
'oa:openBookingPrepayment': import("./types/TestDataShape").OptionNodeConstraint<import("./types/TestDataShape").RequiredStatusType, "oa:RequiredStatusType">;
};
function startDateMustBe2HrsInAdvance(options: import("./types/Options").Options): {
'schema:startDate': import("./types/TestDataShape").DateRangeNodeConstraint;
};
function eventStatusMustNotBeCancelledOrPostponed(): {
'schema:eventStatus': import("./types/TestDataShape").OptionNodeConstraint<import("./types/TestDataShape").EventStatusType, "schema:EventStatusType">;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export type ValueType =
| 'schema:EventStatusType'
| 'schema:EventAttendanceModeEnumeration';

/**
* Specifies a value that must be one of a set of options.
* For example, an `eventStatus` field would be set up to only have
* one of the `schema:EventStatusType` options (e.g.
* `https://schema.org/EventCancelled`, etc)
*/
export interface OptionNodeConstraint<
/** TypeScript union of the types that this option can take */
TOptionType,
Expand All @@ -70,6 +76,10 @@ export interface OptionNodeConstraint<
allowNull?: true;
}

/**
* Similar to OptionNodeConstraint, but where the value must be an
* array. Each item in the array must be from the same set of options.
*/
export interface ArrayConstraint<
TArrayOf,
TValueType extends ValueType
Expand Down Expand Up @@ -106,6 +116,7 @@ export type TestDataNodeConstraint =

export type TestDataShapeOpportunityConstraints = {
'schema:startDate'?: DateRangeNodeConstraint;
'schema:endDate'?: DateRangeNodeConstraint;
/**
* "placeholder:remainingCapacity" is a stand-in for either remainingAttendeeCapacity (sessions)
* or remainingUses (facilities)
Expand All @@ -120,6 +131,9 @@ export type TestDataShapeOpportunityConstraints = {
'oa:taxMode'?: OptionNodeConstraint<TaxMode, 'oa:TaxMode'>;
'oa:isOpenBookingAllowed'?: BooleanNodeConstraint;
'schema:eventAttendanceMode'?: OptionNodeConstraint<EventAttendanceMode, 'schema:EventAttendanceModeEnumeration'>;
// note that the type isn't specified yet (it's a '@type': 'Terms' object) as
// we don't use includes/excludes rules for this field, so it's irrelevant.
'schema:termsOfService'?: ArrayConstraint<unknown, 'oa:Terms'>;
};

/**
Expand All @@ -138,12 +152,20 @@ export type TestDataShape = {
* can be null.
*/
'oa:validFromBeforeStartDate'?: DateRangeNodeConstraint;
/**
* Refers to the date calculated as `startDate - validThroughBeforeStartDate`.
* For this particular DateRangeNodeConstraint, `allowNull` refers to whether `validThroughBeforeStartDate`
* can be null.
*/
'oa:validThroughBeforeStartDate'?: DateRangeNodeConstraint;
'oa:openBookingInAdvance'?: OptionNodeConstraint<RequiredStatusType, 'oa:RequiredStatusType'>;
'oa:openBookingFlowRequirement'?: ArrayConstraint<OpenBookingFlowRequirement, 'oa:OpenBookingFlowRequirement'>;
/**
* Refers to the date calculated as `startDate - latestCancellationBeforeStartDate`.
* For this particular DateRangeNodeConstraint, `allowNull` refers to whether `latestCancellationBeforeStartDate`
* can be null.
*/
'oa:latestCancellationBeforeStartDate'?: NullNodeConstraint | DateRangeNodeConstraint;
'oa:allowCustomerCancellationFullRefund'?: BooleanNodeConstraint;
// note that the type isn't specified yet (it's a '@type': 'Terms' object) as
// we don't use includes/excludes rules for this field, so it's irrelevant.
'schema:termsOfService'?: ArrayConstraint<unknown, 'oa:Terms'>;
};
}
10 changes: 0 additions & 10 deletions packages/test-interface-criteria/built-types/utils/objUtils.d.ts

This file was deleted.

5 changes: 5 additions & 0 deletions packages/test-interface-criteria/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
testMatch: [
"**/test/**/*.js"
]
};
Loading

0 comments on commit a203d43

Please sign in to comment.