Skip to content
This repository was archived by the owner on Oct 12, 2019. It is now read-only.

Commit f7033ba

Browse files
Merge pull request #117 from ecatch-kyst/develop
Develop
2 parents c8f1b43 + eacdbf4 commit f7033ba

File tree

9 files changed

+2423
-79
lines changed

9 files changed

+2423
-79
lines changed

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "https://ecatch-kyst-beta.firebaseapp.com/"
3+
}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/integration/spec.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
describe('Login and logout', () => {
3+
it('Visits our develop site, and login', () => {
4+
cy.visit('http://localhost:3000')
5+
cy.wait(1000)
6+
cy.contains("eCatch Kyst Pilot")
7+
cy.get('form')
8+
cy.get('input[name="email"]').type('p@p.io')
9+
cy.get('input[name="password"]').type('123456')
10+
cy.get('button[type="submit"]').click()
11+
cy.wait(500)
12+
})
13+
it('Check that we are on correct page after login', () => {
14+
cy.contains('Forhåndsett')
15+
})
16+
it('Test logut', () => {
17+
cy.wait(1000)
18+
cy.visit('http://localhost:3000/profile')
19+
cy.get('button[name="logout"]').click()
20+
cy.contains("eCatch Kyst Pilot")
21+
})
22+
})
23+
24+
describe('Test stubbed login and logout', () => {
25+
it('Test stubbed login', () => {
26+
cy.login()
27+
cy.wait(1000)
28+
})
29+
it('Check that we are on correct page after login', () => {
30+
cy.visit('http://localhost:3000/homepage')
31+
cy.wait(1000)
32+
cy.contains('Forhåndsett')
33+
})
34+
it('Test stubbed logout', () => {
35+
cy.wait(1000)
36+
cy.logout()
37+
})
38+
})
39+
40+
describe('Only correct possibilites', () => {
41+
it('Only DCA on page', () => {
42+
cy.login()
43+
cy.wait(1000)
44+
cy.visit('http://localhost:3000/homepage')
45+
cy.wait(1000)
46+
cy.contains('DCA')
47+
cy.contains('DEP').should('not.exist')
48+
cy.contains('Port call').should('not.exist')
49+
cy.wait(500)
50+
cy.logout()
51+
})
52+
})

cypress/plugins/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ***********************************************************
2+
// This example plugins/index.js can be used to load plugins
3+
//
4+
// You can change the location of this file or turn off loading
5+
// the plugins file with the 'pluginsFile' configuration option.
6+
//
7+
// You can read more here:
8+
// https://on.cypress.io/plugins-guide
9+
// ***********************************************************
10+
11+
// This function is called when a project is opened or re-opened (e.g. due to
12+
// the project's config changing)
13+
14+
module.exports = (on, config) => {
15+
// `on` is used to hook into various events Cypress emits
16+
// `config` is the resolved Cypress config
17+
}
18+
const cypressFirebasePlugin = require('cypress-firebase').plugin
19+
20+
module.exports = (on, config) => {
21+
// `on` is used to hook into various events Cypress emits
22+
// `config` is the resolved Cypress config
23+
24+
// Return extended config (with settings from .firebaserc)
25+
return cypressFirebasePlugin(config)
26+
}

cypress/support/commands.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This is will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
26+
import firebase from 'firebase/app'
27+
import 'firebase/auth'
28+
import 'firebase/database'
29+
import 'firebase/firestore'
30+
import {attachCustomCommands} from 'cypress-firebase'
31+
32+
const fbConfig = {
33+
apiKey: "AIzaSyD5l09unKGP3D3cFY_mr_BQPgcTjhkU2jc",
34+
authDomain: "ecatch-kyst.firebaseapp.com",
35+
databaseURL: "https://ecatch-kyst.firebaseio.com",
36+
projectId: "ecatch-kyst",
37+
storageBucket: "ecatch-kyst.appspot.com"
38+
}
39+
40+
window.fbInstance = firebase.initializeApp(fbConfig)
41+
42+
attachCustomCommands({Cypress, cy, firebase})
43+
Cypress.Commands.add('login', () => {
44+
return firebase
45+
.auth()
46+
.signInWithEmailAndPassword('p@p.io', '123456')
47+
})
48+
49+
Cypress.Commands.add('logout', () => {
50+
return firebase
51+
.auth()
52+
.signOut()
53+
})

cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"not op_mini all"
4949
],
5050
"devDependencies": {
51+
"cypress": "^3.2.0",
52+
"cypress-firebase": "^0.1.4",
5153
"enzyme": "^3.9.0",
5254
"enzyme-adapter-react-16": "^1.12.1",
5355
"eslint-config-prettier": "^4.2.0",

src/components/Forms/components/DropdownNative.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const DropdownNative = ({disabled, label, type, onChange, dataId, value, error,
6767
/*
6868
* BUG:, REVIEW: Better solution to match geopoints ?
6969
*/
70-
(option.value && option.value.latitude && value.latitude &&
70+
(option.value && option.value.latitude && value && value.latitude &&
7171
GEOPOINT(option.value.latitude || 0, option.value.longitude || 0)
7272
.isEqual(GEOPOINT(value.latitude, value.longitude))
7373
)

0 commit comments

Comments
 (0)