diff --git a/.eslintcache b/.eslintcache new file mode 100644 index 0000000000..7122e85e7b --- /dev/null +++ b/.eslintcache @@ -0,0 +1 @@ +[{"C:\\FRONTEND noroff\\social-media-client\\cypress.config.js":"1","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\1-getting-started\\todo.cy.js":"2","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\actions.cy.js":"3","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\aliasing.cy.js":"4","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\assertions.cy.js":"5","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\connectors.cy.js":"6","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\cookies.cy.js":"7","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\cypress_api.cy.js":"8","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\files.cy.js":"9","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\location.cy.js":"10","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\misc.cy.js":"11","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\navigation.cy.js":"12","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\network_requests.cy.js":"13","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\querying.cy.js":"14","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\spies_stubs_clocks.cy.js":"15","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\storage.cy.js":"16","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\traversal.cy.js":"17","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\utilities.cy.js":"18","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\viewport.cy.js":"19","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\waiting.cy.js":"20","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\window.cy.js":"21","C:\\FRONTEND noroff\\social-media-client\\cypress\\support\\commands.js":"22","C:\\FRONTEND noroff\\social-media-client\\cypress\\support\\e2e.js":"23","C:\\FRONTEND noroff\\social-media-client\\src\\js\\api\\auth\\login.test.js":"24","C:\\FRONTEND noroff\\social-media-client\\src\\js\\api\\auth\\logout.test.js":"25","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\failed_login.cy.js":"26","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\login.cy.js":"27","C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\logout.cy.js":"28","C:\\FRONTEND noroff\\social-media-client\\src\\js\\api\\auth\\localStorage.mock.js":"29"},{"size":191,"mtime":1713171870483,"results":"30","hashOfConfig":"31"},{"size":6220,"mtime":1713171470783,"results":"32","hashOfConfig":"31"},{"size":12345,"mtime":1713171470784,"results":"33","hashOfConfig":"31"},{"size":1147,"mtime":1713171470785,"results":"34","hashOfConfig":"31"},{"size":5810,"mtime":1713171470793,"results":"35","hashOfConfig":"31"},{"size":3008,"mtime":1713171470794,"results":"36","hashOfConfig":"31"},{"size":3967,"mtime":1713171470795,"results":"37","hashOfConfig":"31"},{"size":5747,"mtime":1713171470796,"results":"38","hashOfConfig":"31"},{"size":2775,"mtime":1713171470797,"results":"39","hashOfConfig":"31"},{"size":1107,"mtime":1713171470798,"results":"40","hashOfConfig":"31"},{"size":2783,"mtime":1713171470799,"results":"41","hashOfConfig":"31"},{"size":1660,"mtime":1713171470799,"results":"42","hashOfConfig":"31"},{"size":6294,"mtime":1713171470800,"results":"43","hashOfConfig":"31"},{"size":3681,"mtime":1713171470801,"results":"44","hashOfConfig":"31"},{"size":6056,"mtime":1713171470802,"results":"45","hashOfConfig":"31"},{"size":4303,"mtime":1713171470803,"results":"46","hashOfConfig":"31"},{"size":3781,"mtime":1713171470804,"results":"47","hashOfConfig":"31"},{"size":3299,"mtime":1713171470805,"results":"48","hashOfConfig":"31"},{"size":1776,"mtime":1713171470806,"results":"49","hashOfConfig":"31"},{"size":1021,"mtime":1713171470807,"results":"50","hashOfConfig":"31"},{"size":624,"mtime":1713171470809,"results":"51","hashOfConfig":"31"},{"size":861,"mtime":1713171470812,"results":"52","hashOfConfig":"31"},{"size":686,"mtime":1713171470814,"results":"53","hashOfConfig":"31"},{"size":788,"mtime":1713174782181,"results":"54","hashOfConfig":"31"},{"size":390,"mtime":1713342357309,"results":"55","hashOfConfig":"31"},{"size":564,"mtime":1713344575258,"results":"56","hashOfConfig":"31"},{"size":814,"mtime":1713253009259,"results":"57","hashOfConfig":"31"},{"size":662,"mtime":1713252544453,"results":"58","hashOfConfig":"31"},{"size":461,"mtime":1713342384265,"results":"59","hashOfConfig":"31"},{"filePath":"60","messages":"61","suppressedMessages":"62","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"gun504",{"filePath":"63","messages":"64","suppressedMessages":"65","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","suppressedMessages":"68","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","suppressedMessages":"71","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","suppressedMessages":"74","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"75","messages":"76","suppressedMessages":"77","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"78","messages":"79","suppressedMessages":"80","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"81","messages":"82","suppressedMessages":"83","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"84","messages":"85","suppressedMessages":"86","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"87","messages":"88","suppressedMessages":"89","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"90","messages":"91","suppressedMessages":"92","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"93","messages":"94","suppressedMessages":"95","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"96","messages":"97","suppressedMessages":"98","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"99","messages":"100","suppressedMessages":"101","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"102","messages":"103","suppressedMessages":"104","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"105","messages":"106","suppressedMessages":"107","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"108","messages":"109","suppressedMessages":"110","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"111","messages":"112","suppressedMessages":"113","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"114","messages":"115","suppressedMessages":"116","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"117","messages":"118","suppressedMessages":"119","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"120","messages":"121","suppressedMessages":"122","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"123","messages":"124","suppressedMessages":"125","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"126","messages":"127","suppressedMessages":"128","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"129","messages":"130","suppressedMessages":"131","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"132","messages":"133","suppressedMessages":"134","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"135","messages":"136","suppressedMessages":"137","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"138","messages":"139","suppressedMessages":"140","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"141","messages":"142","suppressedMessages":"143","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"144","messages":"145","suppressedMessages":"146","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\FRONTEND noroff\\social-media-client\\cypress.config.js",["147","148"],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\1-getting-started\\todo.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\actions.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\aliasing.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\assertions.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\connectors.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\cookies.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\cypress_api.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\files.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\location.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\misc.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\navigation.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\network_requests.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\querying.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\spies_stubs_clocks.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\storage.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\traversal.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\utilities.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\viewport.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\waiting.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\2-advanced-examples\\window.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\support\\commands.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\support\\e2e.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\src\\js\\api\\auth\\login.test.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\src\\js\\api\\auth\\logout.test.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\failed_login.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\login.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\cypress\\e2e\\logout.cy.js",[],[],"C:\\FRONTEND noroff\\social-media-client\\src\\js\\api\\auth\\localStorage.mock.js",[],[],{"ruleId":"149","severity":1,"message":"150","line":5,"column":21,"nodeType":"151","messageId":"152","endLine":5,"endColumn":23},{"ruleId":"149","severity":1,"message":"153","line":5,"column":25,"nodeType":"151","messageId":"152","endLine":5,"endColumn":31},"no-unused-vars","'on' is defined but never used.","Identifier","unusedVar","'config' is defined but never used."] \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..402f8df220 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,54 @@ +{ + "env": { + "browser": true, + "es2021": true, + "node": 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", + "**/*.mock.js" + ], + "env": { + "jest": true + }, + "plugins": [ + "jest" + ], + "extends": [ + "plugin:jest/recommended" + ], + "rules": { + "jest/prefer-expect-assertions": "off" + } + } + ], + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "no-undef": "off", + "no-unused-vars": "warn" + } +} \ No newline at end of file diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000000..31354ec138 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000000..36af219892 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged diff --git a/6 b/6 new file mode 100644 index 0000000000..5fb112b159 --- /dev/null +++ b/6 @@ -0,0 +1,15 @@ + +added 61 packages, and audited 1021 packages in 6s + +141 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. diff --git a/README.md b/README.md new file mode 100644 index 0000000000..c5cc3300ff --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +WORKFLOW CA- social media client + +Prerequisites Git Node JS VS-code/other compiler + +Dependencies Bootstrap Dark 5: Styling application SASS : Extention and pre-processor for CSS ESLint: Code linting Prettier: Code formatting Lint-Staged: Linting staged files Husky: Git hooks on save and commit Jest: Unit testing Cypress: E2E-testing + +Installing Clone the repo and open in code editor + +git clone + +Install dev-dependencies and other dependencies npm install --save-dev npm install + +Running the tests Run unit test & E2E-test: + +npm run test-unit Run unit test + +npm run test Run E2E-tests + +Authors Rukaiya Tahsin diff --git a/babel.config.json b/babel.config.json new file mode 100644 index 0000000000..590f470629 --- /dev/null +++ b/babel.config.json @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "current" + } + } + ] + ] +} \ No newline at end of file diff --git a/cypress.config.js b/cypress.config.js new file mode 100644 index 0000000000..97f47c4127 --- /dev/null +++ b/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require("cypress"); + +module.exports = defineConfig({ + e2e: { + setupNodeEvents(on, config) { + // implement node event listeners here + }, + }, +}); diff --git a/cypress/e2e/1-getting-started/todo.cy.js b/cypress/e2e/1-getting-started/todo.cy.js new file mode 100644 index 0000000000..623893c707 --- /dev/null +++ b/cypress/e2e/1-getting-started/todo.cy.js @@ -0,0 +1,143 @@ +/// + +// Welcome to Cypress! +// +// This spec file contains a variety of sample tests +// for a todo list app that are designed to demonstrate +// the power of writing tests in Cypress. +// +// To learn more about how Cypress works and +// what makes it such an awesome testing tool, +// please read our getting started guide: +// https://on.cypress.io/introduction-to-cypress + +describe("example to-do app", () => { + beforeEach(() => { + // Cypress starts out with a blank slate for each test + // so we must tell it to visit our website with the `cy.visit()` command. + // Since we want to visit the same URL at the start of all our tests, + // we include it in our beforeEach function so that it runs before each test + cy.visit("https://example.cypress.io/todo"); + }); + + it("displays two todo items by default", () => { + // We use the `cy.get()` command to get all elements that match the selector. + // Then, we use `should` to assert that there are two matched items, + // which are the two default items. + cy.get(".todo-list li").should("have.length", 2); + + // We can go even further and check that the default todos each contain + // the correct text. We use the `first` and `last` functions + // to get just the first and last matched elements individually, + // and then perform an assertion with `should`. + cy.get(".todo-list li").first().should("have.text", "Pay electric bill"); + cy.get(".todo-list li").last().should("have.text", "Walk the dog"); + }); + + it("can add new todo items", () => { + // We'll store our item text in a variable so we can reuse it + const newItem = "Feed the cat"; + + // Let's get the input element and use the `type` command to + // input our new list item. After typing the content of our item, + // we need to type the enter key as well in order to submit the input. + // This input has a data-test attribute so we'll use that to select the + // element in accordance with best practices: + // https://on.cypress.io/selecting-elements + cy.get("[data-test=new-todo]").type(`${newItem}{enter}`); + + // Now that we've typed our new item, let's check that it actually was added to the list. + // Since it's the newest item, it should exist as the last element in the list. + // In addition, with the two default items, we should have a total of 3 elements in the list. + // Since assertions yield the element that was asserted on, + // we can chain both of these assertions together into a single statement. + cy.get(".todo-list li") + .should("have.length", 3) + .last() + .should("have.text", newItem); + }); + + it("can check off an item as completed", () => { + // In addition to using the `get` command to get an element by selector, + // we can also use the `contains` command to get an element by its contents. + // However, this will yield the