Skip to content

Instantly share code, notes, and snippets.

@prescottprue
Last active December 1, 2018 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prescottprue/62063229114fb3eb6c09443a199b35a2 to your computer and use it in GitHub Desktop.
Save prescottprue/62063229114fb3eb6c09443a199b35a2 to your computer and use it in GitHub Desktop.
Cypress test of Firebase app route that requires auth
const TEST_PROJECT_PATH = 'projects/123abc'
const fakeProject = {
name: 'My Project'
}
describe('Project Detail Page', () => {
beforeEach(() => {
// Login using custom token
cy.login()
// Go to projects page
cy.visit('/projects')
// Settings to add createdBy and createdAt
const settings = { withMeta: true }
// Seed database with fake project that contains createdAt and createdBy (meta)
cy.callRtdb('set', TEST_PROJECT_PATH , fakeProject, settings)
})
afterEach(() => {
// Reset the displayName in the user's profile to "Test User"
cy.callRtdb('remove', TEST_PROJECT_PATH)
})
it('User can visit the detail page of a project they own', () => {
// Go to transaction detail page
cy.url().visit(TEST_PROJECT_PATH)
// Confirm that user was not redirected (still on project detail page)
cy.url().should('equal', TEST_PROJECT_PATH)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment