-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding cypress * adding test route * updated test route * Adding build status & license to readme * adding badges for readme * remove frontend test badge until we fix lint errors on frontend? * running cypress * added cypress * updated readme to reflect cypress stuff * added prod url to main readme * changed link to prod * ok fixed frontend linting * ok added frontend badge to readme and fixed frontend lint
- Loading branch information
1 parent
0ae25a2
commit da9820c
Showing
16 changed files
with
2,384 additions
and
1,250 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
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,22 @@ | ||
import express from 'express' | ||
import Note from '../models/Note.js' | ||
import User from '../models/User.js' | ||
|
||
/** | ||
* Express router for handling test-related HTTP requests. | ||
* DONT EXPOSE ON PROD PLS :) | ||
* @type {express.Router} | ||
*/ | ||
const TestingRouter = express.Router() | ||
|
||
/** | ||
* Route to delete everything out the db. | ||
*/ | ||
TestingRouter.get('/reset', async (req, res) => { | ||
await Note.deleteMany({}) | ||
await User.deleteMany({}) | ||
|
||
res.status(204).end() | ||
}) | ||
|
||
export default TestingRouter |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
cypress/screenshots/ | ||
src/coverage | ||
coverage | ||
coverage |
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,9 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
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,60 @@ | ||
describe('Notes App', function() { | ||
// Before each function, we should hard reset everything in the database | ||
beforeEach(function() { | ||
cy.request('GET','http://localhost:8420/v1/test/reset') | ||
const user = { | ||
name: 'test_user', | ||
username: 'test_user', | ||
password: 'test_password' | ||
} | ||
cy.request('POST', 'http://localhost:8420/v1/users', user) | ||
cy.visit('http://localhost:5173') | ||
}) | ||
|
||
// Front page should be the log in page at this point | ||
it('front page can be opened', function() { | ||
cy.contains('Sign up') | ||
}) | ||
|
||
it('login form can be opened', function() { | ||
cy.get('input:first').type('test_user') | ||
cy.get('input:last').type('test_password') | ||
cy.contains('Login').click() | ||
|
||
// if we see the 'ADD' button, that means we've logged in. | ||
cy.contains('Add') | ||
}) | ||
|
||
describe('when logged in', function() { | ||
beforeEach(function() { | ||
cy.login({ username: 'test_user', password: 'test_password' }) | ||
}) | ||
|
||
it('a new note can be created', function() { | ||
cy.get('input:first').type('jobava london is fun') | ||
cy.contains('Add').click() | ||
cy.contains('jobava london is fun') | ||
}) | ||
|
||
describe('and a note exists', function () { | ||
beforeEach(function () { | ||
cy.createNote({ content: 'Kings indian samisch variation is fun', important: false}) | ||
cy.createNote({ content: 'Modern scandi is fun', important: false}) | ||
cy.createNote({ content: 'portugese / icelandic gambit is fun', important: false}) | ||
}) | ||
|
||
it('one of those can be made important', function () { | ||
cy.contains('samisch').parent().trigger('mouseover') | ||
cy.get('#pin_button').click() | ||
}) | ||
}) | ||
}) | ||
|
||
// it('login fails with wrong password', function() { | ||
// cy.get('input:first').type('test_user') | ||
// cy.get('input:last').type('test_ass_word') | ||
// cy.contains('Login').click() | ||
|
||
// // We dont have an error message yet 🥲 | ||
// }) | ||
}) |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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,47 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
|
||
Cypress.Commands.add('login', ({ username, password }) => { | ||
cy.request('POST', 'http://localhost:8420/v1/login', { | ||
username, password | ||
}).then(({ body }) => { | ||
localStorage.setItem('token', body.token) | ||
cy.visit('http://localhost:5173/home') | ||
}) | ||
}) | ||
|
||
Cypress.Commands.add('createNote', ({ content, important }) => { | ||
cy.request({ | ||
url: 'http://localhost:8420/v1/notes', | ||
method: 'POST', | ||
body: { content, important }, | ||
headers: { | ||
'Authorization': `Bearer ${localStorage.token}` | ||
} | ||
}) | ||
|
||
cy.visit('http://localhost:5173/home') | ||
}) |
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,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
Oops, something went wrong.