Skip to content

Commit

Permalink
feat: Improve robustness of coverage for FacilityUse (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
NemanjaStefanovic committed Sep 27, 2020
1 parent cfd8b4a commit 07f80ff
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/reference-implementation.yml
Expand Up @@ -58,7 +58,7 @@ jobs:
env:
FORCE_COLOR: 1
NODE_CONFIG: |
{"outputPath": "../../publish/example-output/random/", "datasetSiteUrl": "https://localhost:5001/openactive", "sellers": { "primary": { "@type": "Organization", "@id": "https://localhost:5001/api/identifiers/sellers/1", "requestHeaders": { "X-OpenActive-Test-Client-Id": "test", "X-OpenActive-Test-Seller-Id": "https://localhost:5001/api/identifiers/sellers/1" } }, "secondary": { "@type": "Person", "@id": "https://localhost:5001/api/identifiers/sellers/2" } }, "useRandomOpportunities": true, "generateConformanceCertificate": true, "conformanceCertificateId": "https://openactive.io/openactive-test-suite/example-output/random/certification/" }
{"outputPath": "../../publish/example-output/random/", "datasetSiteUrl": "https://localhost:5001/openactive", "sellers": { "primary": { "@type": "Organization", "@id": "https://localhost:5001/api/identifiers/sellers/1", "requestHeaders": { "X-OpenActive-Test-Client-Id": "test", "X-OpenActive-Test-Seller-Id": "https://localhost:5001/api/identifiers/sellers/1" } }, "secondary": { "@type": "Organization", "@id": "https://localhost:5001/api/identifiers/sellers/3" } }, "useRandomOpportunities": true, "generateConformanceCertificate": true, "conformanceCertificateId": "https://openactive.io/openactive-test-suite/example-output/random/certification/" }
NODE_ENV:
working-directory: tests
- name: Upload test output for Random Mode as artifact
Expand All @@ -73,7 +73,7 @@ jobs:
env:
FORCE_COLOR: 1
NODE_CONFIG: |
{"outputPath": "../../publish/example-output/controlled/", "datasetSiteUrl": "https://localhost:5001/openactive", "sellers": { "primary": { "@type": "Organization", "@id": "https://localhost:5001/api/identifiers/sellers/1", "requestHeaders": { "X-OpenActive-Test-Client-Id": "test", "X-OpenActive-Test-Seller-Id": "https://localhost:5001/api/identifiers/sellers/1" } }, "secondary": { "@type": "Person", "@id": "https://localhost:5001/api/identifiers/sellers/2" } }, "useRandomOpportunities": false, "generateConformanceCertificate": true, "conformanceCertificateId": "https://openactive.io/openactive-test-suite/example-output/controlled/certification/" }
{"outputPath": "../../publish/example-output/controlled/", "datasetSiteUrl": "https://localhost:5001/openactive", "sellers": { "primary": { "@type": "Organization", "@id": "https://localhost:5001/api/identifiers/sellers/1", "requestHeaders": { "X-OpenActive-Test-Client-Id": "test", "X-OpenActive-Test-Seller-Id": "https://localhost:5001/api/identifiers/sellers/1" } }, "secondary": { "@type": "Organization", "@id": "https://localhost:5001/api/identifiers/sellers/3" } }, "useRandomOpportunities": false, "generateConformanceCertificate": true, "conformanceCertificateId": "https://openactive.io/openactive-test-suite/example-output/controlled/certification/" }
NODE_ENV:
working-directory: tests
- name: Upload test output for Controlled Mode as artifact
Expand Down
2 changes: 0 additions & 2 deletions .vscode/launch.json
Expand Up @@ -15,7 +15,6 @@
"test/features/cancellation/customer-requested-cancellation/implemented/unknown-order-test.js"
],
"runtimeExecutable": "npm",
"runtimeVersion": "12.18.2",
"skipFiles": [
"<node_internals>/**"
],
Expand All @@ -30,7 +29,6 @@
"request": "launch",
"cwd": "${workspaceFolder}/packages/openactive-integration-tests",
"runtimeExecutable": "npm",
"runtimeVersion": "12.18.2",
"runtimeArgs": ["run-script", "debug"],
"port": 9229
},
Expand Down
6 changes: 3 additions & 3 deletions packages/openactive-integration-tests/config/default.json
Expand Up @@ -5,7 +5,7 @@
"conformanceCertificateId": "https://www.example.com/",
"bookableOpportunityTypesInScope": {
"ScheduledSession": true,
"FacilityUseSlot": false,
"FacilityUseSlot": true,
"IndividualFacilityUseSlot": false,
"CourseInstance": false,
"CourseInstanceSubEvent": false,
Expand Down Expand Up @@ -77,8 +77,8 @@
}
},
"secondary": {
"@type": "Person",
"@id": "https://openactive-reference-implementation.azurewebsites.net/api/identifiers/sellers/2"
"@type": "Organization",
"@id": "https://openactive-reference-implementation.azurewebsites.net/api/identifiers/sellers/3"
}
}
}
6 changes: 3 additions & 3 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.

4 changes: 2 additions & 2 deletions packages/openactive-integration-tests/package.json
Expand Up @@ -16,8 +16,8 @@
"license": "MIT",
"eslintConfig": {},
"dependencies": {
"@openactive/data-model-validator": "^2.0.27",
"@openactive/data-models": "^2.0.118",
"@openactive/data-model-validator": "^2.0.37",
"@openactive/data-models": "^2.0.139",
"@openactive/test-interface-criteria": "file:../test-interface-criteria",
"axios": "^0.19.0",
"chai": "^4.2.0",
Expand Down
Expand Up @@ -35,9 +35,15 @@ function (configuration, orderItemCriteria, featureIsImplemented, logger, state,
Common.itForOrderItem(orderItemCriteria, state, stage, () => responseAccessor().body,
'availability should match open data feed',
(feedOrderItem, responseOrderItem) => {
chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingAttendeeCapacity': feedOrderItem.orderedItem.remainingAttendeeCapacity,
});
if (feedOrderItem.orderedItem['@type'] === 'Slot') {
chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingUses': feedOrderItem.orderedItem.remainingUses,
});
} else {
chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingAttendeeCapacity': feedOrderItem.orderedItem.remainingAttendeeCapacity,
});
}
});
};

Expand Down
Expand Up @@ -50,17 +50,29 @@ function (configuration, orderItemCriteria, featureIsImplemented, logger, state,
(feedOrderItem, responseOrderItem, responseOrderItemErrorTypes) => {
chai.expect(responseOrderItemErrorTypes).to.include('OpportunityIsFullError');

chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingAttendeeCapacity': 0,
});
if (responseOrderItem.orderedItem['@type'] === 'Slot') {
chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingUses': 0,
});
} else {
chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingAttendeeCapacity': 0,
});
}
},
'should not include an OpportunityIsFullError',
(feedOrderItem, responseOrderItem, responseOrderItemErrorTypes) => {
chai.expect(responseOrderItemErrorTypes).not.to.include('OpportunityIsFullError');

chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingAttendeeCapacity': feedOrderItem.orderedItem.remainingAttendeeCapacity,
});
if (responseOrderItem.orderedItem['@type'] === 'Slot') {
chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingUses': feedOrderItem.orderedItem.remainingUses,
});
} else {
chai.expect(responseOrderItem).to.nested.include({
'orderedItem.remainingAttendeeCapacity': feedOrderItem.orderedItem.remainingAttendeeCapacity,
});
}
});
};

Expand Down
Expand Up @@ -133,7 +133,7 @@ class RequestHelper {
'@type': 'Slot',
facilityUse: {
'@type': 'FacilityUse',
organizer: {
provider: {
'@type': sellerType,
'@id': sellerId,
},
Expand All @@ -145,7 +145,7 @@ class RequestHelper {
'@type': 'Slot',
facilityUse: {
'@type': 'IndividualFacility',
organizer: {
provider: {
'@type': sellerType,
'@id': sellerId,
},
Expand Down
Expand Up @@ -19,9 +19,9 @@ Feature Implemented: {{{ implemented }}}

### {{stage}} Request
{{{request.method}}} {{{ request.url }}}
{{#if request.params}}
{{#if request.jsonBody}}
```json
{{{ json request.params }}}
{{{ json request.jsonBody }}}
```
{{/if}}
{{#if isPending}}
Expand Down

0 comments on commit 07f80ff

Please sign in to comment.