-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Styling/userview #44
Merged
Merged
Styling/userview #44
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
87906ca
Add tests
JoeyStewart 8419399
add error boundary
JoeyStewart d6fc28f
Add proptypes
JoeyStewart 775e5af
Add error handling
JoeyStewart 9ff1b4a
Dynamic errors
JoeyStewart bfc2a75
Proptypes
JoeyStewart 0b6e232
add proptypes
JoeyStewart 345e4da
Tests
JoeyStewart a3d0f2c
add fixture
JoeyStewart eb68024
comment out random
JoeyStewart e3db183
props
JoeyStewart ed35ad0
rework profile prop
JoeyStewart 16f23a4
Wiki prop rework for functionality
JoeyStewart 5834496
Merge branch 'feature/prop-cyp' of github.com:Jesuitman/m3-H8rAid
tenthwalker a133e94
adjust formatting and merge conflict line
tenthwalker 6b614c3
adjust formatting and merge conflict line
tenthwalker 149c8a8
add beforeEach hook and part of a test
tenthwalker 918229a
test/adds assertions with placeholders for fixture data
tenthwalker fefbc0b
consolidate test structure
tenthwalker 7839de7
refactor testing further
tenthwalker 22454f8
Merge branch 'main' of https://github.com/Jesuitman/m3-H8rAid
Jesuitman 10e12d3
styling for userview
Jesuitman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. She cute |
||
} | ||
|
||
.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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice