mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
authentication feature
fixed a problem in login component
This commit is contained in:
parent
169b220aa1
commit
c52dceddf2
@ -8,19 +8,16 @@ Feature: Authentication
|
||||
|
||||
Scenario: Log in
|
||||
When I visit the "login" page
|
||||
And I fill in my email and password combination
|
||||
And I fill in my credentials
|
||||
And I click submit
|
||||
And I wait for 50000 milliseconds
|
||||
Then I can click on my profile picture in the top right corner
|
||||
And I wait for 50000 milliseconds
|
||||
And I can see my name "Peter Lustig" in the dropdown menu
|
||||
Then I am logged in as "Peter Pan"
|
||||
|
||||
Scenario: Refresh and stay logged in
|
||||
Given I am logged in
|
||||
When I refresh the page
|
||||
Then I am still logged in
|
||||
Then I am logged in as "Peter Pan"
|
||||
|
||||
Scenario: Log out
|
||||
Given I am logged in
|
||||
When I log out through the menu in the top right corner
|
||||
Then I see the login screen again
|
||||
When I log out
|
||||
Then I am on page "login"
|
||||
|
||||
13
cypress/integration/Authentication/given_I_am_logged_in.js
Normal file
13
cypress/integration/Authentication/given_I_am_logged_in.js
Normal file
@ -0,0 +1,13 @@
|
||||
import { Given } from "cypress-cucumber-preprocessor/steps";
|
||||
import narrator from "../data/narrator";
|
||||
|
||||
Given("I am logged in", () => {
|
||||
cy.neode()
|
||||
.first("User", { name: narrator.name })
|
||||
.then(user => {
|
||||
return new Cypress.Promise((resolve, reject) => {
|
||||
return user.toJson().then((user) => resolve(user))
|
||||
})
|
||||
})
|
||||
.then(user => cy.login(user))
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { Given } from "cypress-cucumber-preprocessor/steps";
|
||||
import narrator from '../data/narrator'
|
||||
import loginCredentials from '../data/loginCredentials'
|
||||
|
||||
Given("I have an user account", () => {
|
||||
cy.factory().build("user", narrator, loginCredentials);
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I am logged in as {string}", name => {
|
||||
cy.get(".avatar-menu").click();
|
||||
cy.get(".avatar-menu-popover").contains(name);
|
||||
});
|
||||
@ -0,0 +1,5 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I am on page {string}", page => {
|
||||
cy.location("pathname").should("contain", page);
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When("I click submit", () => {
|
||||
cy.get("button[name=submit]")
|
||||
.click();
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
import loginCredentials from '../data/loginCredentials'
|
||||
|
||||
When("I fill in my credentials", () => {
|
||||
cy.get("input[name=email]")
|
||||
.trigger("focus")
|
||||
.type(loginCredentials.email)
|
||||
.get("input[name=password]")
|
||||
.trigger("focus")
|
||||
.type(loginCredentials.password);
|
||||
});
|
||||
8
cypress/integration/Authentication/when_I_log_out.js
Normal file
8
cypress/integration/Authentication/when_I_log_out.js
Normal file
@ -0,0 +1,8 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When("I log out", () => {
|
||||
cy.get(".avatar-menu").click();
|
||||
cy.get(".avatar-menu-popover")
|
||||
.find('a[href="/logout"]')
|
||||
.click();
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When('I refresh the page', () => {
|
||||
cy.visit('/')
|
||||
.reload();
|
||||
});
|
||||
@ -23,19 +23,6 @@ const annoyingParams = {
|
||||
password: "1234",
|
||||
};
|
||||
|
||||
Given("I am logged in", () => {
|
||||
cy.neode()
|
||||
.first("User", {
|
||||
name: narratorParams.name
|
||||
})
|
||||
.then(user => {
|
||||
return new Cypress.Promise((resolve, reject) => {
|
||||
return user.toJson().then((user) => resolve(user))
|
||||
})
|
||||
})
|
||||
.then(user => cy.login(user))
|
||||
});
|
||||
|
||||
Given("I log in as {string}", name => {
|
||||
cy.logout()
|
||||
cy.neode()
|
||||
@ -143,31 +130,6 @@ Given("I am on the {string} page", page => {
|
||||
cy.openPage(page);
|
||||
});
|
||||
|
||||
When(/(?:when )?I refresh the page/, () => {
|
||||
cy.visit('/')
|
||||
.reload();
|
||||
});
|
||||
|
||||
When("I log out through the menu in the top right corner", () => {
|
||||
cy.get(".avatar-menu").click();
|
||||
cy.get(".avatar-menu-popover")
|
||||
.find('a[href="/logout"]')
|
||||
.click();
|
||||
});
|
||||
|
||||
Then("I can see my name {string} in the dropdown menu", () => {
|
||||
cy.get(".avatar-menu-popover").should("contain", narratorParams.name);
|
||||
});
|
||||
|
||||
Then("I see the login screen again", () => {
|
||||
cy.location("pathname").should("contain", "/login");
|
||||
});
|
||||
|
||||
Then("I am still logged in", () => {
|
||||
cy.get(".avatar-menu").click();
|
||||
cy.get(".avatar-menu-popover").contains(narratorParams.name);
|
||||
});
|
||||
|
||||
When("I select {string} in the language menu", name => {
|
||||
cy.switchLanguage(name, true);
|
||||
});
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When("I wait for {int} milliseconds", ms => {
|
||||
cy.wait(ms)
|
||||
});
|
||||
6
cypress/integration/data/loginCredentials.js
Normal file
6
cypress/integration/data/loginCredentials.js
Normal file
@ -0,0 +1,6 @@
|
||||
const loginCredentials = {
|
||||
email: "peterpan@example.org",
|
||||
password: "1234"
|
||||
}
|
||||
|
||||
export default loginCredentials
|
||||
7
cypress/integration/data/narrator.js
Normal file
7
cypress/integration/data/narrator.js
Normal file
@ -0,0 +1,7 @@
|
||||
const narrator = {
|
||||
id: 'id-of-peter-pan',
|
||||
name: "Peter Pan",
|
||||
slug: "peter-pan",
|
||||
}
|
||||
|
||||
export default narrator
|
||||
@ -53,7 +53,7 @@ Cypress.Commands.add("switchLanguage", (name, force) => {
|
||||
|
||||
Cypress.Commands.add("login", user => {
|
||||
const token = encode(user)
|
||||
cy.setCookie('human-connection-token', token)
|
||||
cy.setCookie('ocelot-social-token', token)
|
||||
.visit("/")
|
||||
});
|
||||
|
||||
|
||||
@ -25,9 +25,17 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSuccess() {
|
||||
async handleSuccess() {
|
||||
this.$i18n.set(this.user.locale || 'en')
|
||||
this.$router.replace(this.$route.query.path || '/')
|
||||
|
||||
try {
|
||||
await this.$router.replace(this.$route.query.path || '/')
|
||||
} catch (err) {
|
||||
//throw new Error(`Problem handling something: ${err}.`);
|
||||
// TODO this is causing trouble - most likely due to double redirect on terms&conditions
|
||||
console.log(`Problem handling something: ${err}.`)
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user