Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: tests

on: [pull_request]

jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: cypress run
uses: cypress-io/github-action@v2
with:
build: npm run build
start: npm start
35 changes: 25 additions & 10 deletions cypress/integration/catalogue_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,38 @@ describe('catalogue view', () => {
});

it('be able to search and add seeds to users catalogue', () => {
cy.get('.add-seed-input').type('cucumber')
cy.intercept('POST','https://planty-api.herokuapp.com/api/v1/seed_catalogs',
{
"id": 1,
"seed_id": 123,
"name": "cosmo",
"planting_date": "1 to 2 weeks before",
"planted": false
})
cy.get('.add-seed-input').type('cosmo')
.get('.add-to-catalogue-button').eq(0).click()
.get('.add-to-catalogue-button').eq(0).contains('HAS BEEN ADDED!')

.get('.search-catalogue-input').type('strawberry')
.get('.catalogue-list-button').click()
.get('.catalogue-card-container')
.get('.seed-view-button').click()
.get('.clear-button').click()
//
// .get('.search-catalogue-input').type('cucumber')
// .get('.catalogue-list-button').eq(0).click()
// .get('.catalogue-card-container')
// .get('.seed-view-button').click()
// .get('.clear-button').click()
})

it('should make a schedule for user based on catalogue', () => {
cy.intercept('PATCH','https://planty-api.herokuapp.com/api/v1/seed_catalogs/*',
{
"id": 1,
"seed_id": 123,
"name": "Super Max Hybrid Pickling Cucumber",
"planting_date": "1 to 2 weeks before",
"planted": true
})
cy.get('.account-button').click()
.get('.schedule-card-container')
.get('.plant-button-container')
.get('.plant-button').eq(0).click()
.get('.plant-button').eq(0).contains('Planted!')
.get('.plant-button').eq(5).click()
.get('.plant-button').eq(5).contains('Planted!')
})

})
1 change: 1 addition & 0 deletions src/Components/CatalogueView.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const CatalogueView= () => {
return navigate('/')
}
updateCatalogue()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return (
Expand Down
4 changes: 2 additions & 2 deletions src/Components/ScheduleCard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react'
import {UserContext} from '../Contexts/UserContext'
import {ErrorContext} from '../Contexts/ErrorContext'
import {patchPlant, getFilteredSeeds} from '../apiCalls.js'
import {patchPlant} from '../apiCalls.js'
import '../Styles/ScheduleCard.scss'

const ScheduleCard = (card) => {
Expand Down Expand Up @@ -33,7 +33,7 @@ const ScheduleCard = (card) => {
plant
</button>
</div>
)} else if (seed.planted) {
)} else {
return (
<div key={seed.id} className='plant-button-container'>
<p>{seed.name}</p>
Expand Down
3 changes: 2 additions & 1 deletion src/Components/SeedCatalogue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useContext } from 'react'
import {UserContext} from '../Contexts/UserContext'
import {ErrorContext} from '../Contexts/ErrorContext'
import CatalogueCard from './CatalogueCard'
import {getCatalogue, getFilteredSeeds, getFilteredUserSeeds} from '../apiCalls.js'
import {getFilteredSeeds, getFilteredUserSeeds} from '../apiCalls.js'
import '../Styles/SeedCatalogue.scss'

const SeedCatalogue = ({userCatalogue, setUserCatalogue, updateCatalogue}) => {
Expand All @@ -29,6 +29,7 @@ const SeedCatalogue = ({userCatalogue, setUserCatalogue, updateCatalogue}) => {
.then(data => {
displaySeedCard(data)
setHeader('seed details')
console.log(header)
})
.catch(error => setError(error))
}
Expand Down
1 change: 1 addition & 0 deletions src/Components/SeedSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const SeedSchedule = () => {
.then(data => setSeedsInCatalogue(data))
.catch(error => setError(error))
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

const formatDate = (date) => {
Expand Down
1 change: 1 addition & 0 deletions src/Components/UserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const UserInfo = () => {
if(!user.token){
navigate('/')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

const toggleClick = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Contexts/ErrorContext.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useContext, useState} from 'react'
import React, {useState} from 'react'

export const ErrorContext = React.createContext()

Expand Down
2 changes: 1 addition & 1 deletion src/Contexts/UserContext.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useContext, useState} from 'react'
import React, {useState} from 'react'
import {logoutUser} from '../apiCalls'

export const UserContext = React.createContext()
Expand Down
1 change: 1 addition & 0 deletions src/apiCalls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const handleError = (response) => {
if(!response.ok) {
// eslint-disable-next-line no-throw-literal
throw `${response.status} ${response.statusText}`
} else {
return response.json()
Expand Down