-
+
{{ subitem.icon }}
@@ -107,7 +110,10 @@
fixed
app
>
-
+
{{ appBar.icon }}
@@ -132,7 +138,7 @@
-
+
fa-ellipsis-v
@@ -152,6 +158,7 @@
:disabled="item.disabled"
@click="clickMenuItem(item)"
v-bind:class="{ 'hidden-sm-and-up': item.surface }"
+ :data-cy="item.key"
>
{
+ user = res;
+ });
+});
+
+// but set the user before visiting the page
+// so the app thinks it is already authenticated
+beforeEach(function setUser() {
+ cy.visit("/", {
+ onBeforeLoad(win) {
+ // and before the page finishes loading
+ // set the user object in local storage
+ win.localStorage.setItem("user", JSON.stringify(user));
+ }
+ });
+ // the page should be opened and the user should be logged in
+});
+describe("The home page", () => {
+ it("Successfully loads the home page", () => {
+ cy.visit("/");
+ });
+});
+
+describe("JWT", () => {
+ it("makes authenticated request", () => {
+ // we can make authenticated request ourselves
+ // since we know the token
+ cy.request({
+ url: "http://localhost:7575/api/v8/User/1",
+ auth: {
+ bearer: user.token
+ }
+ })
+ .its("body")
+ .should("deep.equal", [
+ {
+ id: 1,
+ username: "test",
+ firstName: "Test",
+ lastName: "User"
+ }
+ ]);
+ });
+
+ it("is logged in", () => {
+ cy.contains("Hi Test!").should("be.visible");
+ });
+
+ it("shows loaded user", () => {
+ // this user information came from authenticated XHR call
+ cy.contains("li", "Test User").should("be.visible");
+ });
+});
diff --git a/ayanova/tests/e2e/specs/login-logout.js b/ayanova/tests/e2e/specs/login-logout.js
new file mode 100644
index 00000000..31085c05
--- /dev/null
+++ b/ayanova/tests/e2e/specs/login-logout.js
@@ -0,0 +1,29 @@
+// https://docs.cypress.io/api/introduction/api.html
+
+describe("Login", () => {
+ it("Successfully logs in navigate and log out", () => {
+ cy.visit("/login");
+
+ cy.get("input[name=username]")
+ .clear()
+ .type(Cypress.env("adminusername"));
+
+ // {enter} causes the form to submit
+ cy.get("input[name=password]")
+ .clear()
+ .type(`${Cypress.env("adminpassword")}{enter}`);
+
+ // we should be redirected to /dashboard
+ cy.url().should("include", "/home-dashboard");
+
+ //navigate and confirm
+ //open nav and home menu
+ cy.get("[data-cy=navicon]").click();
+ cy.get("[data-cy=home]").click();
+ cy.get("[data-cy='nav/home-user-settings']").click();
+ cy.url().should("include", "/home-user-settings");
+ cy.get("[data-cy=contextmenu]").click();
+ cy.get("[data-cy='app:logout']").click();
+ cy.url().should("include", "/login");
+ });
+});