Skip to content

Commit

Permalink
upgrade rel-engage
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Nov 17, 2020
1 parent b67ca6d commit e35c7d6
Show file tree
Hide file tree
Showing 33 changed files with 140 additions and 308 deletions.
11 changes: 4 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ orbs:
ft-snyk-orb: financial-times/ft-snyk-orb@0

references:

default_container_config: &default_container_config
docker:
# need -browsers as it bundles selenium, which bundles java, which we need
Expand All @@ -15,13 +14,11 @@ references:
TERM: xterm

environment:
NEO4J_VERSION: "3.5.0"
NEO4J_VERSION: '3.5.0'

workspace_root: &workspace_root
~/
workspace_root: &workspace_root ~/

cache_key: &cache_key
cache-v5-{{ .Branch }}-{{ checksum "./package.json" }}
cache_key: &cache_key cache-v5-{{ .Branch }}-{{ checksum "./package.json" }}

attach_workspace: &attach_workspace
attach_workspace:
Expand Down Expand Up @@ -105,7 +102,7 @@ jobs:
name: Run tests
command: make init-db test
environment:
JEST_JUNIT_OUTPUT: "junit/test-results.xml"
JEST_JUNIT_OUTPUT: 'junit/test-results.xml'
- store_test_results:
path: junit

Expand Down
6 changes: 3 additions & 3 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"baseUrl": "http://localhost:8888",
"integrationFolder": "./packages/tc-ui/src/",
"testFiles": "**/*.cyp.js"
"baseUrl": "http://localhost:8888",
"integrationFolder": "./packages/tc-ui/src/",
"testFiles": "**/*.cyp.js"
}
8 changes: 3 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ services:
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_db_temporal_timezone=Z
ports:
- "7474:7474"
- "7473:7473"
- "7687:7687"
- '7474:7474'
- '7473:7473'
- '7687:7687'
volumes:
- ./neo4j/data:/data
- ./neo4j/plugins:/plugins
- ./neo4j/logs:/logs


2 changes: 1 addition & 1 deletion example-schema/types/ChildType.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ChildType
description: Description of ChildType.
moreInformation: |
More information for ChildType
More information for ChildType
properties:
code:
type: Code
Expand Down
9 changes: 4 additions & 5 deletions example-schema/types/MVRType.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: MVRType
description: Description of MVRType.
moreInformation: |
More information for MVRType
More information for MVRType
minimumViableRecord:
- code
- children
- someString
- code
- children
- someString
properties:
code:
type: Code
Expand All @@ -26,4 +26,3 @@ properties:
description: Word description.
label: Word label
useInSummary: true

4 changes: 2 additions & 2 deletions example-schema/types/MainType.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: MainType
description: Description of MainType.
moreInformation: |
More information for MainType
More information for MainType
properties:
code:
type: Code
Expand Down Expand Up @@ -149,5 +149,5 @@ properties:
label: Cypher haha
description: Cypher hahahahaha.
type: ChildType
cypher: "MATCH (this)-[:HAS_CHILD]->(c) RETURN c"
cypher: 'MATCH (this)-[:HAS_CHILD]->(c) RETURN c'
hasMany: true
2 changes: 1 addition & 1 deletion example-schema/types/ParentType.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ParentType
description: Description of ParentType.
moreInformation: |
More information for ParentType
More information for ParentType
properties:
code:
type: Code
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@babel/preset-react": "^7.7.0",
"@babel/register": "^7.7.0",
"@financial-times/athloi": "^1.0.0-beta.29",
"@financial-times/rel-engage": "^7.4.3",
"@financial-times/rel-engage": "^8.0.2",
"@financial-times/tc-api-graphql": "file:./packages/tc-api-graphql",
"aws-sdk": "^2.611.0",
"babel-loader": "^8.0.6",
Expand Down
4 changes: 1 addition & 3 deletions packages/tc-api-express/__tests__/rest-test-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ const testSuite = (method, goodStatus) => {

describe('client headers', () => {
it(`no client-id or client-user-id returns 400`, async () => {
return request(app)
[getRequestMethod()](restUrl)
.expect(400);
return request(app)[getRequestMethod()](restUrl).expect(400);
});

it(`client-id but no client-user-id returns ${goodStatus}`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,7 @@ describe('rest document store integration', () => {
children: expect.any(Array),
});

await neo4jTest('MainType', mainCode)
.exists()
.hasRels(0);
await neo4jTest('MainType', mainCode).exists().hasRels(0);
});
});
});
24 changes: 9 additions & 15 deletions packages/tc-api-rest-handlers/__tests__/global-lock.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ describe('global field locking', () => {
expect(body).not.toMatchObject({
_lockedFields: expect.any(String),
});
await neo4jTest('MainType', mainCode)
.exists()
.match({
lockedField: 'some string',
});
await neo4jTest('MainType', mainCode).exists().match({
lockedField: 'some string',
});
});
it('fails to create if using wrong client', async () => {
await expect(
Expand Down Expand Up @@ -71,11 +69,9 @@ describe('global field locking', () => {
expect(body).not.toMatchObject({
_lockedFields: expect.any(String),
});
await neo4jTest('MainType', mainCode)
.exists()
.match({
lockedField: 'some string',
});
await neo4jTest('MainType', mainCode).exists().match({
lockedField: 'some string',
});
});
it('fails to patch if using wrong client', async () => {
await createNode('MainType', { code: mainCode });
Expand All @@ -90,11 +86,9 @@ describe('global field locking', () => {
message:
'Cannot write lockedField on MainType global-lock-main - property can only be edited by client global-lock-client',
});
await neo4jTest('MainType', mainCode)
.exists()
.notMatch({
lockedField: 'some string',
});
await neo4jTest('MainType', mainCode).exists().notMatch({
lockedField: 'some string',
});
});
});
});
14 changes: 5 additions & 9 deletions packages/tc-api-rest-handlers/__tests__/patch-create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ describe('rest PATCH create', () => {

expect(status).toBe(201);
expect(body).toMatchObject(meta.create);
await neo4jTest('MainType', mainCode)
.exists()
.match(meta.create);
await neo4jTest('MainType', mainCode).exists().match(meta.create);
});
it('sets array data', async () => {
const { body, status } = await basicHandler({
Expand Down Expand Up @@ -149,12 +147,10 @@ describe('rest PATCH create', () => {
code: mainCode,
someDate: date,
});
await neo4jTest('MainType', mainCode)
.exists()
.match({
code: mainCode,
someDate: date,
});
await neo4jTest('MainType', mainCode).exists().match({
code: mainCode,
someDate: date,
});
});

const neo4jTimePrecision = timestamp =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,7 @@ describe('rest PATCH relationship create', () => {
'Invalid property `notInSchema` on type `CuriousChild`.',
});

await neo4jTest('MainType', mainCode)
.match(meta.default)
.noRels();
await neo4jTest('MainType', mainCode).match(meta.default).noRels();
});

it('create node related to nodes with strange codes', async () => {
Expand Down
30 changes: 11 additions & 19 deletions packages/tc-api-rest-handlers/__tests__/patch-update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ describe('rest PATCH update', () => {

expect(status).toBe(200);
expect(body).toMatchObject(meta.update);
await neo4jTest('MainType', mainCode)
.exists()
.match(meta.update);
await neo4jTest('MainType', mainCode).exists().match(meta.update);
});
it('deletes a property as an update', async () => {
await createMainNode({
Expand Down Expand Up @@ -125,11 +123,9 @@ describe('rest PATCH update', () => {
code: mainCode,
someDate: date,
});
await neo4jTest('MainType', mainCode)
.exists()
.match({
someDate: date,
});
await neo4jTest('MainType', mainCode).exists().match({
someDate: date,
});
});
it('updates existing Date', async () => {
await createMainNode({
Expand All @@ -146,11 +142,9 @@ describe('rest PATCH update', () => {
expect(body).toMatchObject({
someDate: date,
});
await neo4jTest('MainType', mainCode)
.exists()
.match({
someDate: date,
});
await neo4jTest('MainType', mainCode).exists().match({
someDate: date,
});
});
it("doesn't update when effectively the same Date", async () => {
const date = '2019-01-09';
Expand Down Expand Up @@ -332,12 +326,10 @@ describe('rest PATCH update', () => {
someBoolean: false,
someInteger: 0,
});
await neo4jTest('MainType', mainCode)
.exists()
.match({
someBoolean: false,
someInteger: 0,
});
await neo4jTest('MainType', mainCode).exists().match({
someBoolean: false,
someInteger: 0,
});
});
it('no clientId, deletes the _updatedByClient property', async () => {
await createMainNode();
Expand Down
14 changes: 5 additions & 9 deletions packages/tc-api-rest-handlers/__tests__/post.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ describe('rest POST', () => {

expect(status).toBe(200);
expect(body).toMatchObject(meta.create);
await neo4jTest('MainType', mainCode)
.exists()
.match(meta.create);
await neo4jTest('MainType', mainCode).exists().match(meta.create);
});

it('sets array data', async () => {
Expand Down Expand Up @@ -115,12 +113,10 @@ describe('rest POST', () => {
code: mainCode,
someDate: date,
});
await neo4jTest('MainType', mainCode)
.exists()
.match({
code: mainCode,
someDate: date,
});
await neo4jTest('MainType', mainCode).exists().match({
code: mainCode,
someDate: date,
});
});
const neo4jTimePrecision = timestamp =>
timestamp.replace('Z', '000000Z');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const parser = getParser({

// The weird string concatenation in the markdown fixture is so that
// dev tooling doesn't tidy up the 'extraneous' whitespace
const addLineBreaks = str =>
str
.replace(/\t+/g, '\t')
.split('\n')
.join(' \n');
const addLineBreaks = str => str.replace(/\t+/g, '\t').split('\n').join(' \n');

describe('nested property definition tests', () => {
describe('single relationship case - hasMany: false', () => {
Expand Down Expand Up @@ -137,7 +133,7 @@ describe('nested property definition tests', () => {

describe('integer type conversion', () => {
const expects = {
'10.5': 10,
10.5: 10,
'-1': -1,
'1e7': 10000000,
};
Expand Down Expand Up @@ -287,7 +283,7 @@ describe('nested property definition tests', () => {

describe('float type conversion', () => {
const expects = {
'0.00001': 0.00001,
0.00001: 0.00001,
'-1.05': -1.05,
};
Object.entries(expects).forEach(([float, actual]) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/tc-markdown-parser/lib/markdown-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const stringifyBoast = require('./unist-stringifiers/stringify-boast');
const setNestedMultilineProperties = require('./tree-mutators/set-nested-multiline-properties');

/* @param schema: Treecreeper schema singleton */
const unifiedProcessor = function({
const unifiedProcessor = function ({
type,
titleFieldName = 'name',
descriptionFieldName = 'description',
Expand Down Expand Up @@ -78,11 +78,11 @@ const getParser = ({
blacklistPropertyNames,
});

markdownParser.createStream = async function() {
markdownParser.createStream = async function () {
return createStream(await this());
};

markdownParser.parseMarkdownString = async function(markdownString) {
markdownParser.parseMarkdownString = async function (markdownString) {
const processor = await this();
const vfile = await processor.process(markdownString);
try {
Expand Down
5 changes: 1 addition & 4 deletions packages/tc-markdown-parser/lib/normalize-property-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
string with no spaces so they can be matched against one another in styles
*/
module.exports = function normalizePropertyKey(key = '') {
return key
.normalize()
.toLowerCase()
.replace(/\s+/g, '');
return key.normalize().toLowerCase().replace(/\s+/g, '');
};
5 changes: 1 addition & 4 deletions packages/tc-schema-publisher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ const s3Client = new AWS.S3({ region: 'eu-west-1' });

const getVersion = schemaObject => {
const asString = JSON.stringify(schemaObject, null, 2);
return crypto
.createHash('md5')
.update(asString)
.digest('hex');
return crypto.createHash('md5').update(asString).digest('hex');
};

const sendSchemaToS3 = async (
Expand Down
2 changes: 1 addition & 1 deletion packages/tc-schema-sdk/data-accessors/relationship-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const cacheKeyGenerator = (
{ includeMetaFields = false } = {},
) => `relationships:${rootType}:${propertyName}:${includeMetaFields}`;

const getRelationshipType = function(
const getRelationshipType = function (
rootType,
propertyName,
{ includeMetaFields = false } = {},
Expand Down
Loading

0 comments on commit e35c7d6

Please sign in to comment.