Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions tests/cypress/e2e/users.index.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
});
});
8 changes: 5 additions & 3 deletions views/users/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -95,6 +93,10 @@ async function loadUsersTable() {
}
}

document.getElementById("registerUser").addEventListener("click", () => {
window.location.href = "/users/add";
});

window.addEventListener("load", async () => {
await loadUsersTable();
});
6 changes: 5 additions & 1 deletion views/users/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<div class="col-md-10">
<h3 class="text-center">Lista de Usuarios</h3>

<button id="registerUser" class="btn btn-primary mb-3">
Registrar Nuevo Usuario
</button>

<table class="table table-bordered table-striped">
<thead class="table-white">
<tr>
Expand All @@ -17,4 +21,4 @@ <h3 class="text-center">Lista de Usuarios</h3>
</div>
</div>
</div>
<script src="/users/assets/index.js" defer></script>
<script src="/users/assets/index.js"></script>
Loading