Match user by id instead of email, update feature

This commit is contained in:
Matt Rider 2019-04-02 18:05:45 -03:00
parent 94288ced54
commit 80f664dd78
3 changed files with 16 additions and 7 deletions

View File

@ -104,14 +104,14 @@ export default {
addSocialMedia: async (_, { url }, { driver, user }) => { addSocialMedia: async (_, { url }, { driver, user }) => {
const session = driver.session() const session = driver.session()
const { email } = user const { id } = user
const result = await session.run( const result = await session.run(
`MATCH (user:User {email: $userEmail}) `MATCH (user:User {id: $userId})
SET user.socialMedia = user.socialMedia + $url SET user.socialMedia = user.socialMedia + $url
RETURN user {.socialMedia} RETURN user {.socialMedia}
`, `,
{ {
userEmail: email, userId: id,
url url
} }
) )
@ -119,6 +119,7 @@ export default {
const [currentUser] = result.records.map(record => { const [currentUser] = result.records.map(record => {
return record.get('user') return record.get('user')
}) })
console.log(currentUser)
return currentUser.socialMedia return currentUser.socialMedia
} }
} }

View File

@ -11,4 +11,6 @@ Feature: List Social Media Accounts
Scenario: Adding Social Media Scenario: Adding Social Media
Given I click on the "My social media" link Given I click on the "My social media" link
Then I should be on the "/settings/my-social-media" page Then I should be on the "/settings/my-social-media" page
And I should be able to add a social media link When I add a social media link
Then it gets saved successfully
And the new social media link shows up on the page

View File

@ -77,14 +77,20 @@ Then('I should be on the {string} page', page => {
.should('contain', 'My social media') .should('contain', 'My social media')
}) })
Then('I should be able to add a social media link', () => { Then('I add a social media link', () => {
cy.get("input[name='social-media']") cy.get("input[name='social-media']")
.type('https://freeradical.zone/@mattwr18') .type('https://freeradical.zone/@mattwr18')
.get('button') .get('button')
.contains('Add social media') .contains('Add social media')
.click() .click()
.get('.iziToast-message') })
Then('it gets saved successfully', () => {
cy.get('.iziToast-message')
.should('contain', 'Updated user') .should('contain', 'Updated user')
.get('a') })
Then('the new social media link shows up on the page', () => {
cy.get('a')
.contains("src='https://freeradical.zone/@mattwr18'") .contains("src='https://freeradical.zone/@mattwr18'")
}) })