Skip to content

Commit 06fe4f1

Browse files
authored
Merge pull request #102 from culturecreates/testbench-1.0
First Testbench 1.0 in branch testbench-1.0
2 parents fd14ee8 + 0b8a271 commit 06fe4f1

16 files changed

Lines changed: 1085 additions & 213 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
node-version: ${{ matrix.node-version }}
2525
- run: npm ci
2626
- run: npm run build --if-present
27-
- run: npm test
27+
- run: npm test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/node_modules
55
/.pnp
66
.pnp.js
7+
/.vscode
78

89
# testing
910
/coverage

package-lock.json

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "reconciliation-testbench",
3-
"homepage": "https://reconciliation-api.github.io/testbench",
4-
"version": "0.2.0",
3+
"homepage": "https://reconciliation-api.github.io/testbench/1.0",
4+
"version": "1.0",
55
"private": true,
66
"dependencies": {
77
"ajv": "^8.12.0",

src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function TestbenchTab({ servicesMap, onEndpointChange }) {
2929

3030
return (
3131
<div className="tabContent">
32-
<p>This form lets you test a reconciliation endpoint interactively.</p>
32+
<p>This form lets you test a reconciliation endpoint interactively. Visit <a href="/testbench/0.2/">testbench v0.2</a> to test endpoints implemented with Spec v0.2.</p>
3333
<ReconciliationServiceInput
3434
onChange={handleChange}
3535
initialService={service || { endpoint } }
@@ -95,7 +95,7 @@ export default class App extends React.Component {
9595
<p style={{float: 'right'}}><a href="https://github.com/reconciliation-api/testbench">Source repository</a></p>
9696
<ul className="nav nav-tabs">
9797
<TabLink to="/" title="Services" exact="true" />
98-
<TabLink to="/client/" title="Test bench" />
98+
<TabLink to="/client/" title="Test bench 1.0" />
9999
</ul>
100100
<Switch>
101101
<Route path="/client/:endpoint">

src/Candidate.js

Lines changed: 87 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,91 @@
1-
2-
import React from 'react';
3-
import Badge from 'react-bootstrap/lib/Badge';
4-
import ListGroupItem from 'react-bootstrap/lib/ListGroupItem';
1+
import React from "react";
2+
import Badge from "react-bootstrap/lib/Badge";
3+
import ListGroupItem from "react-bootstrap/lib/ListGroupItem";
54

65
export default class Candidate extends React.Component {
6+
get url() {
7+
let view = null;
8+
let manifest = this.props.manifest;
9+
if (
10+
"view" in manifest &&
11+
"url" in this.props.manifest.view &&
12+
"id" in this.props.candidate
13+
) {
14+
view = this.props.manifest.view.url.replace(
15+
"{{id}}",
16+
this.props.candidate.id
17+
);
18+
}
19+
return view;
20+
}
21+
22+
renderDescription() {
23+
const { candidate } = this.props;
24+
const description = candidate?.description;
25+
26+
if (!description) return null;
27+
28+
return (
29+
<div>
30+
<div className="candidateField">Description</div>
31+
<div className="candidateValue">{description}</div>
32+
</div>
33+
);
34+
}
35+
36+
renderTypes() {
37+
const types = this.props.candidate?.type;
38+
if (!types) return null;
39+
40+
return (
41+
<div>
42+
<div className="candidateField">Types</div>
43+
<div className="candidateValue">
44+
{types.map((type, idx) => [
45+
idx > 0 && ", ",
46+
`${type.name} (${type.id})`,
47+
])}
48+
</div>
49+
</div>
50+
);
51+
}
52+
53+
renderFeatures() {
54+
const features = this.props.candidate?.features;
55+
if (!features) return null;
56+
57+
return (
58+
<div>
59+
{features.map((feature, idx) => (
60+
<div key={idx}>
61+
<div className="candidateField">Feature {feature.id}</div>
62+
<div className="candidateValue">{feature.value}</div>
63+
</div>
64+
))}
65+
</div>
66+
);
67+
}
68+
69+
render() {
70+
const { candidate } = this.props;
771

8-
get url() {
9-
let view = null;
10-
let manifest = this.props.manifest;
11-
if ('view' in manifest && 'url' in this.props.manifest.view && 'id' in this.props.candidate) {
12-
view = this.props.manifest.view.url.replace('{{id}}', this.props.candidate.id);
13-
}
14-
return view;
15-
}
16-
17-
renderDescription() {
18-
let description = this.props.candidate.description;
19-
if (description !== undefined) {
20-
return (<div><div className="candidateField">Description</div><div className="candidateValue">{description}</div></div>);
21-
}
22-
}
23-
24-
renderTypes() {
25-
let types = this.props.candidate.type;
26-
if (types !== undefined) {
27-
return (<div><div className="candidateField">Types</div><div className="candidateValue">
28-
{types.map((type, idx) => [
29-
idx > 0 && ", ",
30-
type.name + ' (' + type.id + ')'
31-
])}
32-
</div></div>);
33-
}
34-
}
35-
36-
renderFeatures() {
37-
let features = this.props.candidate.features;
38-
if (features !== undefined) {
39-
return (<div>
40-
{features.map((feature, idx) =>
41-
(<div key={idx}><div className="candidateField">Feature {feature.id}</div><div className="candidateValue">{feature.value}</div></div>)
42-
)}
43-
</div>);
44-
}
45-
}
46-
47-
render() {
48-
let candidate = this.props.candidate;
49-
return (<ListGroupItem key={candidate.id} header={candidate.name} active={candidate.match}>
50-
<Badge style={{float: 'right'}}>{this.props.candidate.score}</Badge>
51-
<div>
52-
<div><div className="candidateField">ID</div><div className="candidateValue">
53-
<a href={this.url}>{candidate.id}</a></div></div>
54-
{this.renderDescription()}
55-
{this.renderTypes()}
56-
{this.renderFeatures()}
57-
</div>
58-
</ListGroupItem>);
59-
}
72+
return (
73+
<ListGroupItem
74+
key={candidate.id}
75+
header={candidate.name}
76+
active={candidate.match}
77+
>
78+
<Badge style={{ float: "right" }}>{candidate.score}</Badge>
79+
<div>
80+
<div className="candidateField">ID</div>
81+
<div className="candidateValue">
82+
<a href={this.url}>{candidate.id}</a>
83+
</div>
84+
{this.renderDescription()}
85+
{this.renderTypes()}
86+
{this.renderFeatures()}
87+
</div>
88+
</ListGroupItem>
89+
);
90+
}
6091
}

src/DataExtensionTab.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Col from 'react-bootstrap/lib/Col';
77
import ControlLabel from 'react-bootstrap/lib/ControlLabel';
88
import ListGroup from 'react-bootstrap/lib/ListGroup';
99
import GenericInput from './GenericInput.js';
10+
import PropertyPathInput from './PropertyPathInput.js';
1011
import DataExtensionValue from './DataExtensionValue.js';
1112
import JSONTree from 'react-json-tree';
1213
import {jsonTheme} from './utils.js';
@@ -156,11 +157,10 @@ export default class DataExtensionTab extends React.Component {
156157
<FormGroup controlId="dataExtensionProperty">
157158
<Col componentClass={ControlLabel} sm={2}>Property:</Col>
158159
<Col sm={10}>
159-
<GenericInput
160+
<PropertyPathInput
160161
service={this.props.service}
161-
placeholder="Property to fetch on the entity"
162+
id="data-extension-property"
162163
value={this.state.property}
163-
entityClass="property"
164164
onChange={this.onPropertyChange} />
165165
</Col>
166166
</FormGroup>

src/GenericInput.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,31 @@ export default class GenericInput extends React.Component {
8383

8484
render() {
8585
return (this.hasAutocomplete ?
86-
(<ReconcileSuggest service={this.props.service} entityClass={this.props.entityClass} onChange={this.onSuggestChange} value={this.currentValue} />)
86+
(<ReconcileSuggest
87+
service={this.props.service}
88+
entityClass={this.props.entityClass}
89+
onChange={this.onSuggestChange}
90+
value={this.currentValue}
91+
placeholder={this.props.placeholder}
92+
allowNew={this.props.allowNew}
93+
/>)
8794
: (
8895
(this.props.explicitSubmit !== undefined ?
8996
<InputGroup>
9097
<FormControl
9198
type="text"
9299
placeholder={this.placeholder}
93-
value={this.currentId || ''}
100+
value={this.currentId || ''}
94101
onChange={this.onIdChange} />
95102
<InputGroup.Button>
96103
<Button onClick={this.onSubmit} type="submit" bsStyle="primary">Submit</Button>
97104
</InputGroup.Button>
98105
</InputGroup>
99-
:
106+
:
100107
<FormControl
101108
type="text"
102109
placeholder={this.placeholder}
103-
value={this.currentId || ''}
110+
value={this.currentId || ''}
104111
onChange={this.onIdChange} />
105112

106113
)

0 commit comments

Comments
 (0)