-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Jesuitman/styling/userview
Styling/userview
- Loading branch information
Showing
11 changed files
with
250 additions
and
37 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,127 @@ | ||
describe('template spec', () => { | ||
it('passes', () => { | ||
cy.visit('https://example.cypress.io') | ||
//Need to login before testing | ||
describe('API Tests', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/'); | ||
}) | ||
}) | ||
it('Fetches and displays Wikipedia page contents', () => { | ||
cy.intercept('GET', 'https://en.wikipedia.org/w/api.php?', { | ||
statusCode: 200, | ||
fixture: 'wikipediaApiResponse', | ||
}).as('fetchContents'); | ||
cy.wait('@fetchContents').then(({ response }) => { | ||
expect(response.statusCode).to.equal(200); | ||
}); | ||
cy.contains('Loading...').should('not.exist'); | ||
cy.contains('An error occurred').should('not.exist'); | ||
}); | ||
|
||
it('Handles error when API fails', () => { | ||
cy.intercept('GET', 'https://en.wikipedia.org/w/api.php?', { | ||
statusCode: 500, | ||
body: 'Server Error', | ||
delayMs: 200, | ||
}).as('fetchError'); | ||
cy.wait('@fetchError').then(({ response }) => { | ||
expect(response.statusCode).to.equal(500); | ||
cy.contains('An error occurred').should('exist'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('App Component', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/'); | ||
}) | ||
|
||
it('Loads the app properly', () => { | ||
cy.get('.header-text').should('be.visible'); | ||
cy.get('.login-button').should('be.visible'); | ||
cy.get('.random-headline').should('be.visible'); | ||
}); | ||
|
||
it('Displays random controversies', () => { | ||
cy.get('.result-name').should('contain', ''); | ||
cy.get('.random-headline').should('contain', 'Random Controversy'); | ||
cy.get('.card').should('be.visible'); | ||
cy.get('.card') | ||
.children() | ||
.first() | ||
.within(() => { | ||
cy.contains('h2', ''); | ||
cy.contains('p', ''); | ||
cy.contains('button', '😡Save Controversy😡'); | ||
cy.contains('button', '🤬Save as favorite controversy🤬'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Can search for a Controversy', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/'); | ||
//placeholder for login flow | ||
}); | ||
|
||
it('Searches for a term, then clears input', () => { | ||
cy.get('input[type="text"]').should('be.visible'); | ||
cy.get('input[type="text"]').type('SearchTerm{enter}'); | ||
cy.get('input[type="text"]').should('have.text', ''); | ||
}); | ||
|
||
it('Displays controversies for a search result', () => { | ||
cy.get('.card').should('be.visible'); | ||
cy.get('.result-name').should('contain', ''); | ||
cy.get('.results-list') | ||
.children() | ||
.first() | ||
.within(() => { | ||
cy.contains('h2', ''); | ||
cy.contains('p', ''); | ||
cy.contains('button', '😡Save Controversy😡'); | ||
cy.contains('button', '🤬Save as favorite controversy🤬'); | ||
}); | ||
cy.get('.results-list') | ||
.children() | ||
.last() | ||
.within(() => { | ||
cy.contains('h2', ''); | ||
cy.contains('p', ''); | ||
cy.contains('button', '😡Save Controversy😡'); | ||
cy.contains('button', '🤬Save as favorite controversy🤬'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Card Component', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/'); | ||
}) | ||
|
||
it('Renders snippet properly', () => { | ||
cy.get('.card-content').should('be.visible'); | ||
cy.get('h2').should('contain', ''); | ||
cy.get('p').should('contain', ''); | ||
}); | ||
|
||
it('Handles show more/show less functionality', () => { | ||
|
||
}); | ||
}); | ||
|
||
describe('UserView Component', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/'); | ||
//login flow placeholder | ||
}) | ||
|
||
it('Loads page content properly', () => { | ||
cy.get('#profile').should('be.visible'); | ||
cy.get('#profile').click(); | ||
cy.visit('http://localhost:3000/Profile'); | ||
cy.get('.filter-buttons').should('have.descendants', 'button'); | ||
// cy.get('.article').should('be.visible'); | ||
}); | ||
|
||
it('Saves controversy properly', () => { | ||
|
||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"need": "one sample result with multiple wiki cards" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"query": { | ||
"search": [ | ||
{ | ||
"title": "Example Title 1", | ||
"snippet": "This is an example snippet for the first result." | ||
}, | ||
{ | ||
"title": "Example Title 2", | ||
"snippet": "Another example snippet for the second result." | ||
}, | ||
{ | ||
"title": "Example Title 3", | ||
"snippet": "Another example snippet for the third result." | ||
} | ||
] | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ErrorPage from '../Errors/Errors.js'; | ||
import React, { Component } from 'react'; | ||
|
||
class ErrorBoundary extends Component { | ||
constructor(error) { | ||
super(error); | ||
this.state = { | ||
hasError: false, | ||
errorMessage: '', | ||
}; | ||
} | ||
|
||
static getDerivedStateFromError(error) { | ||
if (error.message === 'Network response was not ok') { | ||
return { hasError: true, errorMessage: 'Error in SpecificComponent' }; | ||
} | ||
if(error.message === 'Error fetching Wikipedia page:') { | ||
return{ hasError: true, errorMessage: 'Cannot fetch Wikipedia page'} | ||
} | ||
return { hasError: true, errorMessage: error.toString() }; | ||
} | ||
|
||
componentsDidCatch(error, errorInfo) { | ||
console.error('ErrorBoundary caught an error:', error, errorInfo); | ||
} | ||
|
||
render() { | ||
return this.state.hasError ? <ErrorPage errorMessage={"An Error has Occurred"} /> : this.props.children; | ||
} | ||
} | ||
|
||
export default ErrorBoundary; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
|
||
const errorMessage = ({ errorMessage }) => { | ||
return ( | ||
<div className="error-page"> | ||
<h2>Error Encountered</h2> | ||
<p>{errorMessage}</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default errorMessage; |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.profile { | ||
flex-direction: column; | ||
} | ||
|
||
.filter-buttons, .profile { | ||
display: flex; | ||
} | ||
|
||
.filter-buttons { | ||
justify-content: center; | ||
} | ||
|
||
@media screen and (max-width: 500px) { | ||
.results-list { | ||
flex-direction: column; | ||
} | ||
} |
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