Skip to content

Commit

Permalink
Merge pull request #8 from Emilyrf/workflow
Browse files Browse the repository at this point in the history
Workflow
  • Loading branch information
Emilyrf authored Aug 19, 2023
2 parents 58bfec4 + 198a790 commit 69e499e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"overrides": [
{
"files": [
Expand Down Expand Up @@ -42,9 +46,5 @@
}
}
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {}
}
12 changes: 9 additions & 3 deletions cypress/e2e/testing/social-media-login-error.cy.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
describe('norrofsocialmedia.no', () => {
it('the user cannot submit the login form with invalid credentials and is shown a message', () => {
cy.visit('http://localhost:8080');
cy.wait(3000);
cy.wait(2000);
cy.get('[data-bs-target="#loginModal"]').last().click();
cy.wait(2000);
cy.get('#loginEmail').type('notauser@stud.noroff.no');
cy.get('#loginPassword').type('123456789{enter}');
cy.get("input[type='email']:visible")
.should('exist')
.type('notauser@stud.noroff.no');
cy.get("input[type='password']:visible")
.should('exist')
.type('notapassword{enter}');
cy.on('window:alert', (str) => {
expect(str).to.equal(
`Either your username was not found or your password is incorrect`,
);
cy.wait(2000);
cy.url().should('not.include', 'profile');
});
});
});
12 changes: 9 additions & 3 deletions cypress/e2e/testing/social-media-login.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
describe('norrofsocialmedia.no', () => {
it('the user can log in and access their profile', () => {
cy.visit('http://localhost:8080');
cy.wait(3000);
cy.wait(2000);
cy.get('[data-bs-target="#loginModal"]').last().click();
cy.wait(2000);
cy.get('#loginEmail').type('emily@stud.noroff.no');
cy.get('#loginPassword').type('123456789{enter}');
cy.get("input[type='email']:visible")
.should('exist')
.type('emily@stud.noroff.no');
cy.get("input[type='password']:visible")
.should('exist')
.type('123456789{enter}');
cy.wait(2000);
cy.url().should('include', 'profile');
});
});
19 changes: 13 additions & 6 deletions cypress/e2e/testing/social-media-logout.cy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
describe('norrofsocialmedia.no', () => {
it('the user can log out with the logout button', () => {
cy.visit('http://localhost:8080');
cy.wait(3000);
cy.wait(2000);
cy.get('[data-bs-target="#loginModal"]').last().click();
cy.wait(2000);
cy.get('#loginEmail').type('emily@stud.noroff.no');
cy.get('#loginPassword').type('123456789{enter}');
cy.wait(8000);
cy.get('[data-auth="logout"]').click();
cy.wait(8000);
cy.get("input[type='email']:visible")
.should('exist')
.type('emily@stud.noroff.no');
cy.get("input[type='password']:visible")
.should('exist')
.type('123456789{enter}');
cy.wait(2000);
cy.url().should('include', 'profile');
cy.wait(2000);
cy.get('[data-auth="logout"]').should('exist').click();
cy.wait(2000);
cy.url().should('not.include', 'profile');
});
});
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build": "sass src/scss:dist/css",
"start": "sass --watch src/scss:dist/css & live-server",
"lint": "eslint src/**/*.js",
"prepare": "husky install",
"test": "npm run test-unit && npm run test-e2e-cli",
"test-unit": "jest",
Expand Down
9 changes: 9 additions & 0 deletions src/js/mocks/localStorage.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ export default class LocalStorageMock {
removeItem(key) {
delete this.store[key];
}

get length() {
return Object.keys(this.store).length;
}

key(n) {
const keys = Object.keys(this.store);
return keys[n] || null;
}
}

0 comments on commit 69e499e

Please sign in to comment.