Skip to content
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

Testing/no auth testing branch #42

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
87906ca
Add tests
JoeyStewart Jan 6, 2024
8419399
add error boundary
JoeyStewart Jan 6, 2024
d6fc28f
Add proptypes
JoeyStewart Jan 6, 2024
775e5af
Add error handling
JoeyStewart Jan 6, 2024
9ff1b4a
Dynamic errors
JoeyStewart Jan 6, 2024
bfc2a75
Proptypes
JoeyStewart Jan 6, 2024
0b6e232
add proptypes
JoeyStewart Jan 6, 2024
345e4da
Tests
JoeyStewart Jan 6, 2024
a3d0f2c
add fixture
JoeyStewart Jan 6, 2024
eb68024
comment out random
JoeyStewart Jan 6, 2024
e3db183
props
JoeyStewart Jan 6, 2024
ed35ad0
rework profile prop
JoeyStewart Jan 6, 2024
16f23a4
Wiki prop rework for functionality
JoeyStewart Jan 6, 2024
5834496
Merge branch 'feature/prop-cyp' of github.com:Jesuitman/m3-H8rAid
tenthwalker Jan 6, 2024
a133e94
adjust formatting and merge conflict line
tenthwalker Jan 6, 2024
6b614c3
adjust formatting and merge conflict line
tenthwalker Jan 6, 2024
149c8a8
add beforeEach hook and part of a test
tenthwalker Jan 6, 2024
918229a
test/adds assertions with placeholders for fixture data
tenthwalker Jan 6, 2024
fefbc0b
consolidate test structure
tenthwalker Jan 7, 2024
7839de7
refactor testing further
tenthwalker Jan 7, 2024
22454f8
Merge branch 'main' of https://github.com/Jesuitman/m3-H8rAid
Jesuitman Jan 7, 2024
f5cc977
removing auth for testing purposes
Jesuitman Jan 7, 2024
b5fef7e
no user auth for testing
Jesuitman Jan 7, 2024
1ed9efc
tests
JoeyStewart Jan 7, 2024
ef49717
tests
JoeyStewart Jan 7, 2024
2722926
commands
JoeyStewart Jan 7, 2024
c14dfff
fixtures
JoeyStewart Jan 7, 2024
8fd634f
add fixtures
JoeyStewart Jan 7, 2024
2145f60
new file
JoeyStewart Jan 7, 2024
cc5ce54
tests
JoeyStewart Jan 7, 2024
3a609fc
add file and tests
JoeyStewart Jan 7, 2024
b570d71
Card tests
JoeyStewart Jan 7, 2024
cfeb5a8
New test file
JoeyStewart Jan 7, 2024
116d5c8
rework
JoeyStewart Jan 7, 2024
0685c9e
New test file
JoeyStewart Jan 7, 2024
62e2837
New test
JoeyStewart Jan 7, 2024
063adbf
Add tests
JoeyStewart Jan 7, 2024
5891844
Add class names to favorite buttons
JoeyStewart Jan 7, 2024
9e0aefb
add tests
JoeyStewart Jan 7, 2024
536f74b
Add card visibility tests
JoeyStewart Jan 7, 2024
b120f45
Deleted redundant code
JoeyStewart Jan 7, 2024
796610a
add id to search
JoeyStewart Jan 7, 2024
7c2cab8
add main page tests
JoeyStewart Jan 7, 2024
f9f0204
Merge branch 'main' of github.com:Jesuitman/m3-H8rAid
tenthwalker Jan 7, 2024
e9d240a
delete commented code
JoeyStewart Jan 7, 2024
31ae60f
Merge branch 'testing/NoAuth-testingBranch' of github.com:Jesuitman/m…
tenthwalker Jan 7, 2024
b16be69
fix/formatting cleanup
tenthwalker Jan 7, 2024
208a3a8
feat/make App test more specific
tenthwalker Jan 7, 2024
386edba
feat/add show more/less test
tenthwalker Jan 7, 2024
83b7aa9
fix/adjust show more/less test
tenthwalker Jan 7, 2024
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 cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
const { defineConfig } = require("cypress");
require('dotenv').config()

module.exports = defineConfig({
env: {
auth0_username: process.env.AUTH0_USERNAME,
auth0_password: process.env.AUTH0_PASSWORD,
auth0_domain: process.env.REACT_APP_AUTH0_DOMAIN,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this auth stuff given that we arent testing it anymore?

auth0_audience: process.env.REACT_APP_AUTH0_AUDIENCE,
auth0_scope: process.env.REACT_APP_AUTH0_SCOPE,
auth0_client_id: process.env.REACT_APP_AUTH0_CLIENT_ID,
auth0_client_secret: process.env.AUTH0_CLIENT_SECRET
},
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
// on('task', {
// async "db:seed"() {

// }
// })
},
},
});
60 changes: 60 additions & 0 deletions cypress/e2e/App_spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
describe('App spec', () => {
beforeEach(() => {
cy.intercept('GET', '**/w/api.php?action=query&list=search**', { fixture: 'initialSearch.json' }).as('initialSearch');
cy.intercept('GET', '**/w/api.php?action=parse&prop=sections**', { fixture: 'sectionsRequest.json' }).as('sectionsRequest');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So glad this worked!

cy.intercept('GET', '**/w/api.php?action=parse&format=json**', { fixture: 'controversiesRequest.json' }).as('controversiesRequest');
cy.visit('http://localhost:3000/');
cy.wait('@initialSearch');
cy.wait('@sectionsRequest');
cy.wait('@controversiesRequest');
});

it('should display all content on page load', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent use of the stubs and the waiting to make it load!

cy.get('.App').should('be.visible');
cy.get('.App-header').should('be.visible');
cy.get('.logo-link').should('be.visible');
cy.get('.button__login').should('be.visible');
cy.get('.random-headline').should('be.visible');
cy.get('.result-name').should('contain', '4chan');
cy.get('.random-headline').should('contain', 'Random Controversy');
cy.get('.card').should('be.visible');
cy.get('.card')
.children()
.first()
.within(() => {
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible');
cy.get('h3').should('contain', 'Internet raids');
cy.contains('button', '😡Save Controversy😡');
cy.contains('button', '🤬Save as favorite controversy🤬');
});
cy.get('.card')
.children()
.last()
.within(() => {
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible');
cy.get('h3').should('contain', 'Internet raids');
cy.contains('button', '😡Save Controversy😡');
cy.contains('button', '🤬Save as favorite controversy🤬');
});
});
});

//Login couldn't work because Cypress couldn't session
// describe('Logged in tests', () => {
// beforeEach(() => {
// cy.intercept('GET', '**/w/api.php?action=query&list=search**', { fixture: 'initialSearch.json' }).as('initialSearch');
// cy.intercept('GET', '**/w/api.php?action=parse&prop=sections**', { fixture: 'sectionsRequest.json' }).as('sectionsRequest');
// cy.intercept('GET', '**/w/api.php?action=parse&format=json**', { fixture: 'controversiesRequest.json' }).as('controversiesRequest');
// cy.visit('http://localhost:3000/');
// cy.wait('@initialSearch');
// cy.wait('@sectionsRequest');
// cy.wait('@controversiesRequest');
// cy.loginToAuth0('[email protected]', 'JZgyS@xJi9ej@V9');
// });
// it('should display logged in content', () => {
// cy.get('#profile').should('be.visible');
// cy.get('#profile').should('contain', 'Profile');
// });
// });
27 changes: 27 additions & 0 deletions cypress/e2e/Card.spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
describe('Card Component', () => {
beforeEach(() => {
cy.intercept('GET', '**/w/api.php?action=query&list=search**', { fixture: 'initialSearch.json' }).as('initialSearch');
cy.intercept('GET', '**/w/api.php?action=parse&prop=sections**', { fixture: 'sectionsRequest.json' }).as('sectionsRequest');
cy.intercept('GET', '**/w/api.php?action=parse&format=json**', { fixture: 'controversiesRequest.json' }).as('controversiesRequest');
cy.visit('http://localhost:3000/');
cy.wait('@initialSearch');
cy.wait('@sectionsRequest');
cy.wait('@controversiesRequest');
});

it('Renders snippet properly', () => {
cy.get('.card-content').should('be.visible');
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible');
cy.get('h3').should('contain', 'Internet raids');
});

it('Handles show more/show less functionality', () => {
cy.get('.card-content').should('be.visible');
cy.get('h3').first().click();
cy.get('p').should('contain', 'According to The Washington Post, \"the site\'s users have managed to pull off some of the highest-profile collective actions in the history of the Internet.\"[1]');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job rembmering uyou can use backslashes to put quotes into strings!!!

cy.get('p').should('have.length', '36');
cy.get('h3').first().click();
cy.get('p').should('have.length', '10');
});
});
64 changes: 64 additions & 0 deletions cypress/e2e/Search.spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
describe('Can search for a Controversy', () => {
beforeEach(() => {
cy.intercept('GET', '**/w/api.php?action=query&list=search**', { fixture: 'initialSearch.json' }).as('initialSearch');
cy.intercept('GET', '**/w/api.php?action=parse&prop=sections**', { fixture: 'sectionsRequest.json' }).as('sectionsRequest');
cy.intercept('GET', '**/w/api.php?action=parse&format=json**', { fixture: 'controversiesRequest.json' }).as('controversiesRequest');

cy.visit('http://localhost:3000/');
cy.wait('@initialSearch');
cy.wait('@sectionsRequest');
cy.wait('@controversiesRequest');
});

it('Can login', () => {
cy.get('.button__login').should('be.visible')
cy.get('.button__login').click()
cy.get('#profile').should('be.visible')
cy.get('input').should('be.visible')

})
describe('Should be able to search for a controversy', () => {
beforeEach(() => {
cy.get('.button__login').click()
cy.get('.favoriteButton').first().click();
cy.get('.saveButton').last().click();
// cy.visit('http://localhost:3000/Profile');
});

it('Searches for a term, then clears input', () => {
cy.get('input[type="text"]').should('be.visible');
cy.get('input[type="text"]').type('Rush Limbaugh');
cy.get('input[type="text"]').should('have.value', 'Rush Limbaugh')
cy.get('#search-button').should('be.visible');
cy.get('#search-button').click()
cy.get('input[type="text"]').should('have.value', '')
});

it('Displays controversies for a search result', () => {
cy.get('.card').should('be.visible');
cy.get('.result-name').should('contain', '4chan');
cy.get('.results-list')
.children()
.first()
.within(() => {
cy.get('.card-content').should('be.visible');
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible')
cy.get('h3').should('contain', 'Internet raids')
cy.contains('button', '😡Save Controversy😡');
cy.contains('button', '🤬Save as favorite controversy🤬');
});
cy.get('.results-list')
.children()
.last()
.within(() => {
cy.get('.card-content').should('be.visible');
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible')
cy.get('h3').should('contain', 'Internet raids')
cy.contains('button', '😡Save Controversy😡');
cy.contains('button', '🤬Save as favorite controversy🤬');
});
});
});
})
62 changes: 62 additions & 0 deletions cypress/e2e/UserView.spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
describe('Can login and go into profile', () => {
beforeEach(() => {
cy.intercept('GET', '**/w/api.php?action=query&list=search**', { fixture: 'initialSearch.json' }).as('initialSearch');
cy.intercept('GET', '**/w/api.php?action=parse&prop=sections**', { fixture: 'sectionsRequest.json' }).as('sectionsRequest');
cy.intercept('GET', '**/w/api.php?action=parse&format=json**', { fixture: 'controversiesRequest.json' }).as('controversiesRequest');
cy.visit('http://localhost:3000/');
cy.wait('@initialSearch');
cy.wait('@sectionsRequest');
cy.wait('@controversiesRequest');
});

it('Can login', () => {
cy.get('.button__login').should('be.visible');
cy.get('.button__login').click();
cy.get('#profile').should('be.visible');
cy.get('input').should('be.visible');
})

describe('UserView Component', () => {
beforeEach(() => {
cy.get('.button__login').click();
cy.get('.favoriteButton').first().click();
cy.get('.saveButton').last().click();
cy.get('#profile').click();
});

it('Loads page content properly', () => {
cy.get('.filter-buttons').should('be.visible');
cy.get('.filter-buttons').should('have.descendants', 'button');
});

it('Shows all saved controversies on profile page load', () => {
cy.get('.card-content').should('be.visible');
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible');
cy.get('h3').should('contain', 'Internet raids');
});

it('Should show favorited cards', () => {
cy.get('.show-favorites').click();
cy.get('.card-content').should('be.visible');
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible');
cy.get('h3').should('contain', 'Internet raids');
});

it('Should return to show all saved', () => {
cy.get('.show-all').click();
cy.get('.card-content').should('be.visible');
cy.get('h2').should('contain', 'Controversies and harassment incidents[edit]');
cy.get('img').should('be.visible');
cy.get('h3').should('contain', 'Internet raids');
});

it('Should return to the main page on header click', () => {
cy.get('.header-text').should('be.visible');
cy.get('.header-text').click();
cy.get('input').should('be.visible');
cy.get('h2').should('be.visible');
})
});
});
21 changes: 16 additions & 5 deletions cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
describe('template spec', () => {
it('passes', () => {
cy.visit('https://example.cypress.io')
})
})
//code from a cypress/auth0 tutorial
// describe('Auth0', function () {
// beforeEach(function () {
// cy.task('db:seed');
// cy.intercept('POST', '/graphql').as('createUserAccount');
// cy.loginToAuth0(
// Cypress.env('auth0_username'),
// Cypress.env('auth0_password')
// )
// cy.visit('/');
// })

// it('shows onboarding', function () {
// cy.contains('Get Started').should('be.visible');
// })
// })
106 changes: 106 additions & 0 deletions cypress/fixtures/InitialSearch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"batchcomplete": "",
"continue": {
"sroffset": 10,
"continue": "-||"
},
"query": {
"searchinfo": {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good fixture

"totalhits": 998,
"suggestion": "chan",
"suggestionsnippet": "chan"
},
"search": [
{
"ns": 0,
"title": "4chan",
"pageid": 12561015,
"size": 154562,
"wordcount": 14021,
"snippet": "<span class=\"searchmatch\">4chan</span> is an anonymous English-language imageboard website. Launched by Christopher &quot;moot&quot; Poole in October 2003, the site hosts boards dedicated to a",
"timestamp": "2023-12-26T16:33:14Z"
},
{
"ns": 0,
"title": "/pol/",
"pageid": 47045163,
"size": 72220,
"wordcount": 6783,
"snippet": "&quot;Politically Incorrect&quot;, is an anonymous political discussion imageboard on <span class=\"searchmatch\">4chan</span>. As of 2022, it is the most active board on the site. It has had a substantial",
"timestamp": "2023-12-18T12:01:41Z"
},
{
"ns": 0,
"title": "Christopher Poole",
"pageid": 18395608,
"size": 18449,
"wordcount": 1438,
"snippet": "entrepreneur and developer. He founded the anonymous English-language imageboard <span class=\"searchmatch\">4chan</span> in October 2003, when he was still a teenager; he served as the site's head",
"timestamp": "2024-01-03T18:57:46Z"
},
{
"ns": 0,
"title": "Pepe the Frog",
"pageid": 49002118,
"size": 80165,
"wordcount": 6547,
"snippet": "such as Myspace, Gaia Online, and <span class=\"searchmatch\">4chan</span> in 2008. By 2015, he had become one of the most popular memes used on <span class=\"searchmatch\">4chan</span> and Tumblr. Different types of Pepe",
"timestamp": "2023-12-22T23:28:41Z"
},
{
"ns": 0,
"title": "Imageboard",
"pageid": 18985311,
"size": 24387,
"wordcount": 2366,
"snippet": "from trains to current news. The most popular English language imageboard, <span class=\"searchmatch\">4chan</span>, similarly has a large variety of topics. Imageboards are also different",
"timestamp": "2023-12-20T13:08:44Z"
},
{
"ns": 0,
"title": "Hiroyuki Nishimura",
"pageid": 217798,
"size": 28458,
"wordcount": 2832,
"snippet": "accessed Japanese message board, 2channel, and current administrator of <span class=\"searchmatch\">4chan</span>. He is also a self-help author and TV personality.: PT38  He is often known",
"timestamp": "2023-12-15T05:02:32Z"
},
{
"ns": 0,
"title": "/b/",
"pageid": 61171989,
"size": 14116,
"wordcount": 1326,
"snippet": "/b/, also called random, is an anonymous imageboard on <span class=\"searchmatch\">4chan</span>. It was the first board created during the establishment of the platform in 2003, and it",
"timestamp": "2023-12-30T02:38:35Z"
},
{
"ns": 0,
"title": "2chan",
"pageid": 509815,
"size": 2483,
"wordcount": 374,
"snippet": "fork of <span class=\"searchmatch\">4chan</span>, created by American software developer Fredrick Brennan and currently owned by Jim Watkins 420chan, an imageboard based on <span class=\"searchmatch\">4chan</span> and dedicated",
"timestamp": "2023-12-14T18:47:38Z"
},
{
"ns": 0,
"title": "Wojak",
"pageid": 58818336,
"size": 20088,
"wordcount": 1878,
"snippet": "image aggregation website. The meme subsequently grew in popularity on <span class=\"searchmatch\">4chan</span>, where the character became associated with the phrases formerly used by",
"timestamp": "2024-01-05T09:18:03Z"
},
{
"ns": 0,
"title": "Kill All Normies",
"pageid": 58996995,
"size": 9714,
"wordcount": 915,
"snippet": "Kill All Normies: Online Culture Wars from <span class=\"searchmatch\">4chan</span> and Tumblr to Trump and the Alt-Right is a 2017 non-fiction book by Angela Nagle published by Zero Books",
"timestamp": "2024-01-03T04:44:09Z"
}
]
}
}
1,512 changes: 1,512 additions & 0 deletions cypress/fixtures/controversiesRequest.json

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

Loading