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 CA Sabina Kutniauske #260

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5cb365b
Created README.md file
saibia8 Aug 17, 2023
937abbf
Installed eslint
saibia8 Aug 17, 2023
eb1292b
Modifed README.md file
saibia8 Aug 17, 2023
a6085b9
Added lint scripts and .eslintcache to .gitignore
saibia8 Aug 17, 2023
e435b2a
1.0.1
saibia8 Aug 17, 2023
f1e6e13
Added module type to package.json
saibia8 Aug 17, 2023
a5d96e7
Installed prettier
saibia8 Aug 17, 2023
3c539ff
Inserting format script in package.json
saibia8 Aug 17, 2023
93ba176
Formated js files with prettier
saibia8 Aug 17, 2023
5c9557a
1.0.2
saibia8 Aug 17, 2023
e944ff0
Modified README.md file
saibia8 Aug 17, 2023
8ca071d
Added hooks
saibia8 Aug 17, 2023
f9f6d89
Adds husky.sh file
saibia8 Aug 17, 2023
3b0a972
Merge branch 'workflow-hooks' into workflow
saibia8 Aug 17, 2023
331c102
1.0.3
saibia8 Aug 17, 2023
be17d20
Modified README.md file
saibia8 Aug 17, 2023
7c1ef50
Installed jest
saibia8 Aug 17, 2023
9eabf3b
Added test and test-unit scripts for jest
saibia8 Aug 17, 2023
640c2c8
1.0.4
saibia8 Aug 17, 2023
573416d
Modified README.md file
saibia8 Aug 17, 2023
307a2e2
Configurated unit testing with jest
saibia8 Aug 18, 2023
0ee110e
Installed cypress
saibia8 Aug 18, 2023
c9a8102
1.0.5
saibia8 Aug 18, 2023
5f2a8ae
Updated README.md file
saibia8 Aug 18, 2023
630043b
Local storage mock class
saibia8 Aug 19, 2023
c961683
Updated localStorage.mock.js file
saibia8 Aug 19, 2023
7e4521f
Added rule no-undef off
saibia8 Aug 19, 2023
df88aaa
Test saves Token to localStorage
saibia8 Aug 19, 2023
a063c31
Testfetchs and saves Token to localStorage
saibia8 Aug 19, 2023
1fa81f1
Testremoves Token from localStorage
saibia8 Aug 19, 2023
fa1ad21
1.0.6
saibia8 Aug 19, 2023
284ff03
Modified README.md file
saibia8 Aug 19, 2023
3ef7017
Cypress login and access profile
saibia8 Aug 19, 2023
21cdae5
Creted logout and login with bad password tests
saibia8 Aug 20, 2023
cbd3f9f
Delete demo test
saibia8 Aug 20, 2023
7f49975
Create static.yml
saibia8 Aug 20, 2023
b99a432
Merge pull request #1 from saibia8/Action-create-page
saibia8 Aug 20, 2023
6d7e2be
1.0.7
saibia8 Aug 20, 2023
b75ab9c
Modified README.md file
saibia8 Aug 20, 2023
eeb28e2
Updated cypress.config.js
saibia8 Aug 20, 2023
efcca7f
Modified package.json scripts
saibia8 Aug 20, 2023
ab03837
Changed live server port
saibia8 Aug 20, 2023
31c8599
Add unit and e2e workflows
saibia8 Aug 20, 2023
c12805d
Merge pull request #2 from saibia8/workflow-automated-testing
saibia8 Aug 20, 2023
e1ce161
Modified README.md with badges
saibia8 Aug 20, 2023
3669336
Revert "Formated js files with prettier"
saibia8 Aug 31, 2023
f886ceb
Merge pull request #5 from saibia8/workflow-reverted-formating
saibia8 Aug 31, 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
34 changes: 34 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": "eslint:recommended",
"overrides": [
{
"files": ["**/*.cy.js"],
"env": { "cypress/globals": true },
"plugins": ["cypress"],
"extends": ["plugin:cypress/recommended"],
"rules": {
"cypress/no-unnecessary-waiting": "off",
"no-unused-vars": "off"
}
},
{
"files": ["**/*.test.js"],
"env": { "jest": true },
"plugins": ["jest"],
"extends": ["plugin:jest/recommended"],
"rules": { "jest/prefer-expect-assertions": "off" }
}
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"no-undef": "off"
}
}
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
47 changes: 47 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["workflow"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dependencies
run: npm i
- name: Build SASS
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
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 @@
_
30 changes: 30 additions & 0 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}

readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
exit $exitCode
fi

exit 0
fi
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
15 changes: 15 additions & 0 deletions 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

added 52 packages, and audited 371 packages in 6s

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

4 high severity vulnerabilities

To address issues that do not require attention, run:
npm audit fix

To address all issues (including breaking changes), run:
npm audit fix --force

Run `npm audit` for details.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Workflow CA

[![Automated Unit Testing](https://github.com/saibia8/social-media-client-Sabina/actions/workflows/unit-test.yml/badge.svg?branch=Testing-PR)](https://github.com/saibia8/social-media-client-Sabina/actions/workflows/unit-test.yml)

[![Automated E2E Testing](https://github.com/saibia8/social-media-client-Sabina/actions/workflows/e2e-test.yml/badge.svg?branch=Testing-PR)](https://github.com/saibia8/social-media-client-Sabina/actions/workflows/e2e-test.yml)

Installed eslint and patched version v.1.0.1
Installed prettier, formated javascript files and patched version v1.0.2
Installed pre-commit eslint hook and patched version v1.0.3
Installed jest for unit-testing and patched version v1.0.4
Installed cypress for e2e-testing and patched version v1.0.5
Created test files login.test.js and logout.test.js and patched version v1.0.6
Created test file login.cy.js and action to static pages, patched version v1.0.7
Comment on lines +1 to +13

Choose a reason for hiding this comment

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

Image description CodeRabbit

The changes made to the README.md file are generally good, providing clear information about the testing and linting tools added to the project. However, the term "patched version" is used repeatedly but it's not clear what it refers to. It would be more informative if each line that introduces a new tool or test also briefly describes its purpose or how it improves the project.

Installed eslint (for identifying and reporting on patterns in ECMAScript/JavaScript code) and updated to version v.1.0.1
Installed prettier (an opinionated code formatter), formatted javascript files and updated to version v1.0.2
Installed pre-commit eslint hook (to ensure all committed code adheres to defined coding standards) and updated to version v1.0.3
Installed jest for unit-testing (to verify the correctness of individual units of source code) and updated to version v1.0.4
Installed cypress for e2e-testing (to test whether the flow of an application is performing as designed from start to finish) and updated to version v1.0.5
Created test files login.test.js and logout.test.js (to verify login and logout functionality) and updated to version v1.0.6
Created test file login.cy.js and action to static pages, updated to version v1.0.7

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 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
video: false,
screenshotOnRunFailure: false,
},
});
27 changes: 27 additions & 0 deletions cypress/e2e/User-login-and-access-profile/login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
describe("Social media client: login and access profile, logout, try to login with invalid password", () => {
it("Login to profile account", () => {
cy.visit("http://127.0.0.1:8080/index.html");
cy.get("#registerForm > .modal-header > .btn-close").click();
cy.get(".text-end > .btn-outline-success").click({ force: true });
cy.get("#loginEmail").type("sabKut73328@stud.noroff.no", { force: true });
cy.get("#loginPassword").type("kukuku16", { force: true });
cy.get("#loginForm > .modal-footer > .btn-success").click({ force: true });
});
it("Logout from profile account", () => {
cy.visit("http://127.0.0.1:8080/index.html");
cy.get("#registerForm > .modal-header > .btn-close").click();
cy.get(".text-end > .btn-outline-success").click({ force: true });
cy.get("#loginEmail").type("sabKut73328@stud.noroff.no", { force: true });
cy.get("#loginPassword").type("kukuku16", { force: true });
cy.get("#loginForm > .modal-footer > .btn-success").click({ force: true });
cy.get(".btn-outline-warning").click();
});
it("Try to login with bad password", () => {
cy.visit("http://127.0.0.1:8080/index.html");
cy.get("#registerForm > .modal-header > .btn-close").click();
cy.get(".text-end > .btn-outline-success").click({ force: true });
cy.get("#loginEmail").type("sabKut73328@stud.noroff.no", { force: true });
cy.get("#loginPassword").type("kukuku18", { force: true });
cy.get("#loginForm > .modal-footer > .btn-success").click({ force: true });
});
});
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"
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
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) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/e2e.js
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')
Loading
Loading