This file contains hidden or 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
describe('Projects Page', () => { | |
describe('when not authenticated', () => { | |
before(() => { | |
// Attempt to go to /projects (requires user to be logged in) | |
cy.visit('/projects') | |
}) | |
it('Redirects to Home (/)', () => { | |
cy.url().should('equal', '/') | |
}); | |
}) |
This file contains hidden or 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') | |
}) | |
This file contains hidden or 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
import firebase from 'firebase/app'; | |
import 'firebase/auth'; | |
import 'firebase/database'; | |
import 'firebase/firestore'; | |
import { attachCustomCommands } from 'cypress-firebase'; | |
const projectId = Cypress.env('FIREBASE_PROJECT_ID') | |
const env = Cypress.env('env') || 'stage' | |
const apiKey = Cypress.env('FIREBASE_API_KEY') |
This file contains hidden or 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
import { createStore, compose } from 'redux' | |
import firebase from 'firebase/app' | |
import 'firebase/auth' | |
import 'firebase/database' | |
import 'firebase/firestore' // make sure you add this for firestore | |
import { reactReduxFirebase } from 'react-redux-firebase' | |
import rootReducer from './reducer' | |
export default function configureStore(initialState, history) { | |
// Initialize firebase app if instance does not already exist |
This file contains hidden or 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 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 |
This file contains hidden or 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
/** | |
* Create a selector string from a selector value. | |
* @param {String} selectorValue - Value of the selector | |
* @example | |
* createSelector('some-btn') | |
* // => [data-test=some-btn] | |
*/ | |
export function createSelector(selectorValue) { | |
return `[data-test=${selectorValue}]` | |
} |
This file contains hidden or 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 cypressFirebasePlugin = require('cypress-firebase').plugin | |
module.exports = (on, config) => { | |
// `on` is used to hook into various events Cypress emits | |
// `config` is the resolved Cypress config | |
// Return extended config (with settings from .firebaserc) | |
return cypressFirebasePlugin(config) | |
} |
This file contains hidden or 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
"scripts": { | |
"build:testConfig": "cypress-firebase createTestEnvFile", | |
"test": "npm run build:testConfig && cypress run", | |
"test:open": "npm run build:testConfig && cypress open", | |
"test:stage": "npm run test:run -- --env envName=stage", | |
"test:open:stage": "npm run test:open -- --env envName=stage", | |
"test:open:debug": "cross-env DEBUG=cypress:* npm test:open" | |
} |
This file contains hidden or 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 path = require('path') | |
const rootDir = path.resolve(__dirname, '..') | |
module.exports = { | |
/** resolves from test to snapshot path */ | |
resolveSnapshotPath: (testPath, snapshotExtension) => { | |
return testPath.replace('src/', '__snapshots__/') + snapshotExtension | |
}, |
This file contains hidden or 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
import React, { useCallback } from 'react'; | |
import { useFirestoreCollectionData, useFirestore } from 'reactfire'; | |
function useProjects() { | |
// lazy load the Firestore SDK | |
const firestore = useFirestore() | |
const projectsRef = firestore.collection('projects') | |
// subscribe to the do throws a Promise for Suspense to catch, | |
// and then streams live updates |
OlderNewer