Last active
December 1, 2018 09:58
-
-
Save prescottprue/6958e0c3fb12e5e7d898cb695288aa1c to your computer and use it in GitHub Desktop.
Cypress test for verifying app writes valid data to database
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
const USER_PROFILE_PATH = `users/${Cypress.env('TEST_UID')}` | |
describe('Account Page', () => { | |
beforeEach(() => { | |
// Login using custom token | |
cy.login() | |
// Go to account page | |
cy.visit('/account') | |
}) | |
afterEach(() => { | |
// Reset the displayName in the user's profile to "Test User" | |
cy.callRtdb('update', USER_PROFILE_PATH, { displayName: 'Test User' }) | |
}) | |
it('User can update their account', () => { | |
const newDisplayName = 'New Name' | |
cy.get('[data-test=displayName]').type(newDisplayName) | |
// Click to create new transaction | |
cy.get('[data-test=save-account]')).click() | |
// Get user profile data for value comparison | |
cy.callRtdb('get', USER_PROFILE_PATH) | |
.then((account) => { | |
// Confirm profile contains updated displayName | |
cy.wrap(account) | |
.its('displayName') | |
.should('equal', newDisplayName) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment