-
Notifications
You must be signed in to change notification settings - Fork 435
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
Workflow #459
Open
KariannNor
wants to merge
30
commits into
NoroffFEU:master
Choose a base branch
from
KariannNor:workflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Workflow #459
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
45c13ed
testing
KariannNor 67ff0db
Adds README
KariannNor 41b4d4d
adds dependencies
KariannNor 36add93
adds lint staged and husky
KariannNor 4f8dec4
adds hooks
KariannNor 32776c9
adds type to package
KariannNor c578652
adds Jest
KariannNor bd101b5
Adds Babel
KariannNor 303bd25
installs Cypress
KariannNor 6d734db
cionfigs cypress e2e-testing
KariannNor f73a35c
edited readme
KariannNor bdfe8f4
edits name and version
KariannNor fd487da
adds unit testing
KariannNor 6fe4b84
adds a midification to the logout unit test
KariannNor 6b02bc2
adds cypress script to package.json
KariannNor d97872a
ready to test cypress on login and logout
KariannNor 0842ec3
cypress test - allows valid user to log in successfully
KariannNor 03e2a2e
Cypress tests completed
KariannNor 16f9736
README d
KariannNor 44e12c8
edits logout.cy.js + README.md
KariannNor bad44fb
Edits readme.md
KariannNor bb49ca6
Edits cy. test after feedback
KariannNor d6c3cd6
Edits jest and cypress testing after feedback
KariannNor 239e45c
edits the readme
KariannNor 8160959
Merge branch 'workflow-test-branch'
KariannNor 342c25a
status badge added
KariannNor 63f4bce
edits cypress test on login and pages.yml on push to workflow branch
KariannNor fd3983d
Merge branch 'workflow-test-branch'
KariannNor cc536cd
badge applied
KariannNor 42b34bd
updates a passing status badge
KariannNor 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"overrides": [ | ||
{ | ||
"files": ["**/*.test.js"], | ||
"env": { "jest": true }, | ||
"plugins": ["jest"], | ||
"extends": ["plugin:jest/recommended"], | ||
"rules": { | ||
"jest/prefer-expect-assertions": "off", | ||
"no-undef": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["**/*.cy.js", "cypress.config.js"], | ||
"env": { "cypress/globals": true }, | ||
"plugins": ["cypress"], | ||
"extends": ["plugin:cypress/recommended"], | ||
"rules": { | ||
"cypress/no-unnecessary-waiting": "off", | ||
"no-unused-vars": "off" | ||
} | ||
} | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"rules": {} | ||
} |
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,2 +1,4 @@ | ||
/node_modules | ||
/dist | ||
/dist | ||
.DS_Store | ||
.eslintcache |
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 @@ | ||
_ |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
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 @@ | ||
{ | ||
"singleQuote": false | ||
} |
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,8 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"eslint.validate": ["javascript"] | ||
} |
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,66 @@ | ||
# Workflow Course Assignment | ||
|
||
[![Deploy static content to Pages](https://github.com/KariannNor/workflow-ca/actions/workflows/pages.yml/badge.svg?branch=workflow)](https://github.com/KariannNor/workflow-ca/actions/workflows/pages.yml) | ||
|
||
## Description | ||
|
||
This CA is focused on how to use the skills and knowledge from this course to improve the quality of a package by establishing helpful workflows that make the development process more efficient. | ||
|
||
## Built with: | ||
|
||
- HTML | ||
- CSS | ||
- SASS | ||
- Bootstrap | ||
- JavaScript | ||
|
||
## Packages used | ||
|
||
- NPM package manager | ||
- Prettier | ||
- ESLint | ||
- Husky | ||
- Jest | ||
- Babel | ||
- Cypress | ||
|
||
## Getting started | ||
|
||
### Installing | ||
|
||
1. Clone the repo | ||
|
||
``` | ||
git clone https://github.com/KariannNor/workflow-ca | ||
``` | ||
|
||
2. Install dependencies | ||
|
||
``` | ||
npm i | ||
``` | ||
|
||
3. Build production files | ||
|
||
``` | ||
npm run build | ||
``` | ||
|
||
4. Other useful commands and formatting: | ||
|
||
``` | ||
// sass and live server: | ||
npm run start | ||
|
||
// testing with Cypress: | ||
npm run test-e2e | ||
|
||
// unit tests with jest: | ||
npm run test-unit | ||
|
||
// prettier: | ||
npm run format | ||
|
||
// eslint: | ||
npm run lint-fix | ||
``` |
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 @@ | ||
{ | ||
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]] | ||
} |
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,16 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
env: { | ||
validEmail: "benny123@noroff.no", | ||
validPassword: "11111111", | ||
wrongEmail: "wrong@email.com", | ||
wrongPassword: "wrongPassword", | ||
}, | ||
|
||
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,38 @@ | ||
describe("login", () => { | ||
beforeEach(() => { | ||
cy.visit("/"); | ||
}); | ||
|
||
it("Should deny an invalid user to log in and show error message", () => { | ||
cy.wait(500); | ||
cy.get("#registerForm .btn-close").click(); | ||
cy.get(`header button[data-bs-target="#loginModal"]`).click(); | ||
cy.wait(500); | ||
cy.get("#loginForm").should("be.visible"); | ||
cy.get("#loginForm #loginEmail").type(Cypress.env("wrongEmail")); | ||
cy.get("#loginForm #loginPassword").type(Cypress.env("wrongPassword")); | ||
cy.get("button[type=submit]").contains("Login").click(); | ||
cy.wait(500); | ||
cy.on("window:alert", (text) => { | ||
expect(text).to.include( | ||
"Either your username was not found or your password is incorrect", | ||
); | ||
}); | ||
cy.window() | ||
.its("localStorage") | ||
.invoke("getItem", "token") | ||
.should("be.null"); | ||
}); | ||
|
||
it("should allow a valid user to log in", () => { | ||
cy.wait(500); | ||
cy.get("#registerForm .btn-close").click(); | ||
cy.get(`header button[data-bs-target="#loginModal"]`).click(); | ||
cy.wait(500); | ||
cy.get("#loginForm").should("be.visible"); | ||
cy.get("#loginForm #loginEmail").type(Cypress.env("validEmail")); | ||
cy.get("#loginForm #loginPassword").type(Cypress.env("validPassword")); | ||
cy.get("button[type=submit]").contains("Login").click(); | ||
cy.get(`header button[data-auth="logout"]`).should("be.visible"); | ||
}); | ||
}); |
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,29 @@ | ||
describe("logout", () => { | ||
it("should allow a valid user to log out", () => { | ||
cy.visit("/"); | ||
cy.wait(500); | ||
|
||
cy.get("#registerModal").contains("Login").click(); | ||
cy.wait(500); | ||
|
||
cy.get("#loginForm").should("be.visible"); | ||
cy.get("#loginForm #loginEmail").type(Cypress.env("validEmail")); | ||
cy.get("#loginForm #loginPassword").type(Cypress.env("validPassword")); | ||
cy.get("button[type=submit]").contains("Login").click(); | ||
cy.wait(1000); | ||
|
||
cy.window().then((window) => { | ||
const token = window.localStorage.getItem("token"); | ||
expect(token).to.be.a("string"); | ||
cy.wait(500); | ||
|
||
cy.get(`header button[data-auth="logout"]`).contains("Logout").click(); | ||
cy.wait(500); | ||
|
||
cy.window().then((window) => { | ||
const tokenAfterLogout = window.localStorage.getItem("token"); | ||
expect(tokenAfterLogout).to.be.null; | ||
}); | ||
}); | ||
}); | ||
}); |
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": "hello@cypress.io", | ||
"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,25 @@ | ||
// *********************************************** | ||
// 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) => { ... }) |
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.
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.
It would be nice to see a local storage check here
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.
Thanks for the feedback Oliver. I'll take a look at it.