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

Workflow #270

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c0a25c3
added prettier -w
corrado1982 Aug 13, 2023
c22fc96
added eslint
corrado1982 Aug 13, 2023
ddc2006
added eslint in package.json
corrado1982 Aug 13, 2023
7b8aab8
added eslint fix and cache to gitignore
corrado1982 Aug 13, 2023
d9c9120
added husky
corrado1982 Aug 14, 2023
165578c
add lint-staged
corrado1982 Aug 14, 2023
7c89b9d
1.0.1
corrado1982 Aug 14, 2023
445ffb7
add error to commit
corrado1982 Aug 14, 2023
bbda637
add vscode settings
corrado1982 Aug 14, 2023
9a6f9c0
1.0.2
corrado1982 Aug 14, 2023
8198e2e
added babel and jest
corrado1982 Aug 15, 2023
64b437b
1.0.3
corrado1982 Aug 15, 2023
3d22a80
added cypress plugin
corrado1982 Aug 16, 2023
9a95bb1
added test scripts at package.json
corrado1982 Aug 17, 2023
5f2c9d7
added e2e login test
corrado1982 Aug 17, 2023
fc0ccf8
cy_it log in
corrado1982 Aug 18, 2023
1456f90
cy_it log in fake
corrado1982 Aug 18, 2023
0a445c3
login and logout it works on cypress
corrado1982 Aug 19, 2023
a261b5e
cli test failing
corrado1982 Aug 19, 2023
d5d4ae7
deleted intentional error files
corrado1982 Aug 19, 2023
4bbd91c
added cypres config
corrado1982 Aug 19, 2023
20d3373
maybe fixed the commits problems
corrado1982 Aug 19, 2023
8d04827
1.0.4
corrado1982 Aug 19, 2023
547c2ee
added unit test
corrado1982 Aug 19, 2023
a436945
1.0.5
corrado1982 Aug 19, 2023
20b7077
Revert "1.0.5"
corrado1982 Aug 19, 2023
0bccfb2
cypress test is working again
corrado1982 Aug 19, 2023
2840880
cypress test is working again commit also plugin
corrado1982 Aug 19, 2023
708c300
tested both unit and e2e and deleted todo test
corrado1982 Aug 20, 2023
5aa5a2d
added tests.yml on workflow
corrado1982 Aug 20, 2023
cb2f6ac
added tests as connor did
corrado1982 Aug 20, 2023
c2d9e81
as connor did keep the 5500 port
corrado1982 Aug 20, 2023
704a981
added action tests from the lesson
corrado1982 Aug 20, 2023
693e994
added readme file
corrado1982 Aug 20, 2023
d96e229
updated readme file
corrado1982 Aug 20, 2023
d898c8b
added e2e test as connor
corrado1982 Aug 20, 2023
af9713c
added delay on login.cy
corrado1982 Aug 20, 2023
700ea0a
using cy.visit("/")
corrado1982 Aug 20, 2023
dcf2904
added cy.visit("/") at second test e2e
corrado1982 Aug 20, 2023
1aaff48
added wait time after cy.visit("/")
corrado1982 Aug 20, 2023
9bd7c0c
Update readme.md
corrado1982 Sep 6, 2023
a013945
Update readme.md
corrado1982 Sep 6, 2023
e07ab42
if on push it will change from logout to LogOut
corrado1982 Sep 7, 2023
05bcfaf
Merge branch 'workflow' of https://github.com/corrado1982/social-medi…
corrado1982 Sep 7, 2023
41a6bf0
Logout button text ok
corrado1982 Sep 7, 2023
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
32 changes: 32 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"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" }
},
{
"files": ["**/*.cy.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": {}
}
17 changes: 17 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Automated E2E Testing
on:
pull_request:
workflow_dispatch:

jobs:
run-e2e-tests:
name: Run E2E Tests
runs-on: ubuntu-latest
steps:
- name: Checkout under $GITHUB_WORKSPACE
uses: actions/checkout@main

- name: Cypress run
uses: cypress-io/github-action@v5
with:
start: npm run dev
24 changes: 24 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Automated Unit Testing
on:
- pull_request
- workflow_dispatch

jobs:
run-unit-tests:
name: Run Unit Tests
runs-on: ubuntu-latest

steps:
- name: Checkout under $GITHUB_WORKSPACE
uses: actions/checkout@main

- name: Set up NodeJS
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install all dependencies
run: npm install

- name: Run Tests
run: npm run test-unit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/dist
/dist
.eslintcache
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
8 changes: 8 additions & 0 deletions .vscode/settings.json
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": true
},
"eslint.validate": ["javascript"]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json.default
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": true
},
"eslint.validate": ["javascript"]
}
12 changes: 12 additions & 0 deletions 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

added 52 packages, and audited 371 packages in 2s

54 packages are looking for funding
run `npm fund` for details

3 high severity vulnerabilities

To address all issues, run:
npm audit fix

Run `npm audit` for details.
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}
11 changes: 11 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
video: false,
screenshotOnRunFailure: false,
},
});
59 changes: 59 additions & 0 deletions cypress/e2e/3-testing/login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
describe("login test", () => {
it("can login and logout", () => {
// visit the page
cy.visit("/");
cy.wait(10000);

// check if the register modal exist
cy.get("#registerModal .btn").contains("Login").should("exist");
cy.wait(1000);

// move to the login modal
cy.get("#registerModal .btn").contains("Login").click();
cy.get("#loginForm .btn").contains("Login").should("exist");
cy.wait(1000);

// type email and password and submit
cy.get("#loginEmail").type("cor@stud.noroff.no");
cy.wait(1000);
cy.get("#loginPassword").type("loginpass");
cy.get("#loginForm").submit();
cy.wait(2000);

// check if it enter to che profile page
cy.url().should("include", "profile");

// check if the ures can logout
cy.get(".btn").contains("Logout").should("exist").click();
cy.wait(2000);
cy.url().should("not.include", "profile");
});

it("Should fail login with invalid credential and shown a message", () => {
// visit the login page
cy.visit("/"); // Replace 3000 with your port number
cy.wait(10000);

// check if the register modal exist
cy.get("#registerModal .btn").contains("Login").should("exist");
cy.wait(1000);

// move to the login modal
cy.get("#registerModal .btn").contains("Login").click();
cy.get("#loginForm .btn").contains("Login").should("exist");
cy.wait(1000);

// type fake email and fake password and submit
cy.get("#loginEmail").type("fakeemail@stud.noroff.no");
cy.wait(1000);
cy.get("#loginPassword").type("fakepass");
cy.get("#loginForm").submit();
cy.wait(2000);
// check if is stock on the index page
cy.url().should("not.include", "profile");
cy.wait(2000);

// check it the alert message exist
cy.window().get(".alert").should("exist");
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
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"
}
5 changes: 5 additions & 0 deletions cypress/fixtures/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": 8739,
"name": "Jane",
"email": "jane@example.com"
}
Loading
Loading