Skip to content

Commit

Permalink
Fix import error preventing admin from loggin in
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbeaird committed Aug 29, 2020
1 parent 2dd5ac3 commit 51f9d0c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/routers/checkUser.router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require('express');
const router = express.Router();

const { User } = require('../models/user.model');
const User = require('../models/user.model');

// GET /api/checkuser/
router.post('/', (req, res) => {
Expand Down
2 changes: 2 additions & 0 deletions client/src/pages/AdminLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const AdminLogin = (props) => {
// aria-label="topic"
onChange={e => handleInputChange(e)}
aria-label="Email Address"
data-test="input-email"
autoComplete="none"
required="required"
/>
Expand All @@ -136,6 +137,7 @@ const AdminLogin = (props) => {
<button
onClick={e => handleLogin(e)}
className="login-button"
data-test="login-btn"
>
LOGIN
</button>
Expand Down
21 changes: 21 additions & 0 deletions cypress/integration/admin_login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
describe("Admin Login", () => {
it("User cannot leave field empty", () => {
cy.visit("/login");
cy.get("[data-test=input-email]").click().type(" ");
cy.get("[data-test=login-btn]").click();
cy.contains("Please don't leave the field blank");
});
it("User must complete email", () => {
cy.visit("/login");
cy.get("[data-test=input-email]").click().type("admin@test");
cy.get("[data-test=login-btn]").click();
cy.contains("Please format the email address correctly");
});
it("Admin can login", () => {
cy.visit("/login");
cy.get("[data-test=input-email]").click().type("[email protected]");
cy.get("[data-test=login-btn]").click();
// TODO: Add test database for full end to end testing
// cy.contains("Success");
});
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev:api": "cd backend && npm run dev",
"dev:client": "cd client && npm run start",
"dev": "dotenv -e backend/.env -e client/.env concurrently \"npm run dev:api\" \"npm run dev:client\"",
"cy:run": "dotenv -e client/.env -- cross-var cross-env CYPRESS_baseUrl=%CLIENT_URL% cypress run",
"cy:open": "dotenv -e client/.env -- cross-var cross-env CYPRESS_baseUrl=%CLIENT_URL% cypress open",
"cy:run": "dotenv -e client/.env -- cross-var cross-env CYPRESS_baseUrl=%CLIENT_URL% cypress run chrome",
"test:cy": "dotenv -e ./backend/.env -e ./client/.env cross-var start-test dev:api %BACKEND_PORT% dev:client %CLIENT_PORT% cy:run",
"test:backend": "cd backend && npm run test",
"test:client": "cd client && npm run test",
Expand Down

0 comments on commit 51f9d0c

Please sign in to comment.