diff --git a/tests/cypress/e2e/users.index.cy.js b/tests/cypress/e2e/users.index.cy.js index 13bcc5c..f9aab8b 100644 --- a/tests/cypress/e2e/users.index.cy.js +++ b/tests/cypress/e2e/users.index.cy.js @@ -35,11 +35,10 @@ describe("User Table Tests", () => { ], }, }).as("getUsers"); + cy.visitWithToken("/users"); }); it("redirects to the add user page when edit buttons are clicked", () => { - cy.visitWithToken("/users"); - cy.wait("@getUsers"); cy.get('[data-cy="btnEdit"]').should("exist"); @@ -68,4 +67,12 @@ describe("User Table Tests", () => { cy.stub(win.console, "error").as("consoleError"); }); }); + + it("should redirect to /users/add when clicked", () => { + cy.visitWithToken("/users"); + cy.get("#registerUser").should("exist"); + + cy.get("#registerUser").click(); + cy.url().should("include", "/users/add"); + }); }); diff --git a/views/users/assets/index.js b/views/users/assets/index.js index d988cb0..0277094 100644 --- a/views/users/assets/index.js +++ b/views/users/assets/index.js @@ -11,9 +11,7 @@ function createTableRow(user) { const row = document.createElement("tr"); const addressCell = createCell(user.address); - const fullNameCell = createCell( - `${user.firstName} ${user.secondName} ${user.lastname} ${user.secondLastname} `, - ); + const fullNameCell = createCell(`${user.firstName} ${user.lastName}`); const phoneCell = createCell(user.phoneNumber); const actionsCell = createActionsCell(user); @@ -95,6 +93,10 @@ async function loadUsersTable() { } } +document.getElementById("registerUser").addEventListener("click", () => { + window.location.href = "/users/add"; +}); + window.addEventListener("load", async () => { await loadUsersTable(); }); diff --git a/views/users/index.html b/views/users/index.html index 6f2b101..c3fac8d 100644 --- a/views/users/index.html +++ b/views/users/index.html @@ -3,6 +3,10 @@