-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #342 from cofacts/strict-schema
Disable dynamic ES mapping and fix test fixtures
- Loading branch information
Showing
16 changed files
with
37 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export default { | ||
'/users/doc/test-user': { | ||
id: 'test-user', | ||
name: 'test user', | ||
email: '[email protected]', | ||
facebookId: 'secret-fb-id', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
export default { | ||
'/users/doc/test-user': { | ||
id: 'test-user', | ||
slug: 'abc123', | ||
name: 'test user', | ||
email: '[email protected]', | ||
}, | ||
'/users/doc/test-user2': { | ||
id: 'test-user2', | ||
slug: 'def456', | ||
name: 'test user2', | ||
email: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
export default { | ||
'/users/doc/error': { | ||
users: [ | ||
{ | ||
name: 'Bill', | ||
updatedAt: 0, | ||
}, | ||
], | ||
name: 'Bill', | ||
updatedAt: 0, | ||
}, | ||
'/users/doc/normal': { | ||
users: [ | ||
{ | ||
name: 'Bill', | ||
updatedAt: 0, | ||
}, | ||
], | ||
name: 'Bill', | ||
updatedAt: 0, | ||
}, | ||
'/users/doc/testUser1': { | ||
id: 'testUser1', | ||
name: 'test user 1', | ||
facebookId: 'fbid123', | ||
githubId: 'githubId123', | ||
email: '[email protected]', | ||
}, | ||
'/users/doc/testUser2': { | ||
id: 'testUser2', | ||
name: 'test user 2', | ||
githubId: 'githubId456', | ||
email: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ import client from 'util/client'; | |
import MockDate from 'mockdate'; | ||
import fixtures from '../__fixtures__/UpdateUser'; | ||
|
||
const testUser1 = fixtures['/users/doc/testUser1']; | ||
const testUser2 = fixtures['/users/doc/testUser2']; | ||
|
||
const updateUser = (variableString, userId) => | ||
|
@@ -75,77 +74,77 @@ describe('UpdateUser', () => { | |
it('should set user slug field correctly', async () => { | ||
const { data, errors } = await updateUser( | ||
`slug: "test-user-1"`, | ||
testUser1.id | ||
'testUser1' | ||
); | ||
|
||
expect(errors).toBe(undefined); | ||
expect(data).toMatchSnapshot(); | ||
|
||
expect(await getUser(testUser1.id)).toMatchSnapshot(); | ||
expect(await getUser('testUser1')).toMatchSnapshot(); | ||
}); | ||
|
||
it('cannot set duplicated slug', async () => { | ||
const { errors } = await updateUser( | ||
`slug: "${testUser2.slug}"`, | ||
testUser1.id | ||
'testUser1' | ||
); | ||
|
||
expect(errors).toMatchSnapshot(); | ||
|
||
expect(await getUser(testUser1.id)).toMatchSnapshot(); | ||
expect(await getUser('testUser1')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should set all provided fields correctly', async () => { | ||
const { data, errors } = await updateUser( | ||
`slug: "test-user-3", name: "new name", avatarType: Gravatar, bio: "blahblahblah"`, | ||
testUser1.id | ||
'testUser1' | ||
); | ||
|
||
expect(errors).toBe(undefined); | ||
expect(data).toMatchSnapshot(); | ||
|
||
expect(await getUser(testUser1.id)).toMatchSnapshot(); | ||
expect(await getUser('testUser1')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should not set unsupported fields', async () => { | ||
const { errors } = await updateUser( | ||
`email: "[email protected]"`, | ||
testUser1.id | ||
'testUser1' | ||
); | ||
|
||
expect(errors).toMatchSnapshot(); | ||
|
||
expect(await getUser(testUser1.id)).toMatchSnapshot(); | ||
expect(await getUser('testUser1')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should not unset fields', async () => { | ||
const { errors } = await updateUser(`slug: "", name: null`, testUser1.id); | ||
const { errors } = await updateUser(`slug: "", name: null`, 'testUser1'); | ||
|
||
expect(errors).toMatchSnapshot(); | ||
|
||
expect(await getUser(testUser1.id)).toMatchSnapshot(); | ||
expect(await getUser('testUser1')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should preserve avatarData field for non openpeeps avatar', async () => { | ||
let { data, errors } = await updateUser( | ||
`avatarData:"""{"key":"value"}""", avatarType: OpenPeeps`, | ||
testUser1.id | ||
'testUser1' | ||
); | ||
expect(errors).toBe(undefined); | ||
expect(data).toMatchSnapshot('openpeeps'); | ||
|
||
({ data, errors } = await updateUser(`avatarType: Facebook`, testUser1.id)); | ||
({ data, errors } = await updateUser(`avatarType: Facebook`, 'testUser1')); | ||
expect(errors).toBe(undefined); | ||
expect(data).toMatchSnapshot('facebook'); | ||
|
||
({ data, errors } = await updateUser( | ||
`avatarType: Github, avatarData:"""{"key":"123"}"""`, | ||
testUser1.id | ||
'testUser1' | ||
)); | ||
expect(errors).toBe(undefined); | ||
expect(data).toMatchSnapshot('github'); | ||
|
||
expect(await getUser(testUser1.id)).toMatchSnapshot(); | ||
expect(await getUser('testUser1')).toMatchSnapshot(); | ||
}); | ||
|
||
afterAll(() => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ Object { | |
"email": "[email protected]", | ||
"facebookId": "fbid123", | ||
"githubId": "githubId123", | ||
"id": "testUser1", | ||
"name": "test user 1", | ||
"slug": "test-user-1", | ||
"updatedAt": "2020-01-01T00:00:10.000Z", | ||
|
@@ -31,7 +30,6 @@ Object { | |
"email": "[email protected]", | ||
"facebookId": "fbid123", | ||
"githubId": "githubId123", | ||
"id": "testUser1", | ||
"name": "new name", | ||
"slug": "test-user-3", | ||
"updatedAt": "2020-01-01T00:00:30.000Z", | ||
|
@@ -51,7 +49,6 @@ Object { | |
"email": "[email protected]", | ||
"facebookId": "fbid123", | ||
"githubId": "githubId123", | ||
"id": "testUser1", | ||
"name": "new name", | ||
"slug": "test-user-3", | ||
"updatedAt": "2020-01-01T00:00:30.000Z", | ||
|
@@ -66,7 +63,6 @@ Object { | |
"email": "[email protected]", | ||
"facebookId": "fbid123", | ||
"githubId": "githubId123", | ||
"id": "testUser1", | ||
"name": "new name", | ||
"slug": "test-user-3", | ||
"updatedAt": "2020-01-01T00:01:00.000Z", | ||
|
@@ -140,7 +136,6 @@ Object { | |
"email": "[email protected]", | ||
"facebookId": "fbid123", | ||
"githubId": "githubId123", | ||
"id": "testUser1", | ||
"name": "new name", | ||
"slug": "test-user-3", | ||
"updatedAt": "2020-01-01T00:00:30.000Z", | ||
|
@@ -161,12 +156,6 @@ exports[`UpdateUser should set user name field correctly 2`] = ` | |
Object { | ||
"name": "Mark", | ||
"updatedAt": "2020-01-01T00:00:00.000Z", | ||
"users": Array [ | ||
Object { | ||
"name": "Bill", | ||
"updatedAt": 0, | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
|
@@ -190,7 +179,6 @@ Object { | |
"email": "[email protected]", | ||
"facebookId": "fbid123", | ||
"githubId": "githubId123", | ||
"id": "testUser1", | ||
"name": "test user 1", | ||
"slug": "test-user-1", | ||
"updatedAt": "2020-01-01T00:00:10.000Z", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
export default { | ||
'/users/doc/test-user': { | ||
id: 'test-user', | ||
slug: 'abc123', | ||
name: 'test user', | ||
email: '[email protected]', | ||
avatarType: 'Facebook', | ||
facebookId: 123456, | ||
}, | ||
'/users/doc/current-user': { | ||
id: 'current-user', | ||
slug: 'def456', | ||
name: 'current user', | ||
email: '[email protected]', | ||
avatarType: 'Github', | ||
githubId: 654321, | ||
}, | ||
'/users/doc/test-email-user': { | ||
id: 'test-email-user', | ||
slug: 'ghi789', | ||
name: 'test email user', | ||
email: '[email protected]', | ||
}, | ||
'/users/doc/another-user': { | ||
id: 'another-user', | ||
name: 'open peeps user', | ||
email: '[email protected]', | ||
avatarType: 'OpenPeeps', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export default { | ||
'/users/doc/test-user': { | ||
id: 'test-user', | ||
slug: 'taken', | ||
name: 'test user', | ||
email: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule rumors-db
updated
from 7935de to a5bcab
Oops, something went wrong.