Skip to content

Commit

Permalink
fix: alter TeamMembers tests for new mock member
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Sep 20, 2024
1 parent 470055b commit 4b77b8b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("when a user fills in the 'add a new editor' form correctly but the use
});

it("shows an appropriate error message", async () => {
const addNewEditorModal = await screen.findByTestId("dialog-create-user");
const addNewEditorModal = await screen.findByTestId("dialog-add-user");

expect(
await within(addNewEditorModal).findByText(/User already exists/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("when a user fills in the 'add a new editor' form correctly", () => {

it("closes the modal", async () => {
await waitFor(() => {
expect(screen.queryByTestId("modal-create-user")).not.toBeInTheDocument();
expect(screen.queryByTestId("modal-add-user")).not.toBeInTheDocument();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ describe("when a user presses 'edit button'", () => {
const lastNameInput = await screen.findByLabelText("Last name");
const emailInput = await screen.findByLabelText("Email address");
// Sorted based on first letter of first name Bill > Donella in Mocks
expect(firstNameInput).toHaveDisplayValue("Bill");
expect(lastNameInput).toHaveDisplayValue("Sharpe");
expect(emailInput).toHaveDisplayValue("bill@example.com");
expect(firstNameInput).toHaveDisplayValue("Bilbo");
expect(lastNameInput).toHaveDisplayValue("Baggins");
expect(emailInput).toHaveDisplayValue("bil.bags@email.com");
});
it("disables the update user button", async () => {
// find whole modal
Expand Down Expand Up @@ -70,7 +70,7 @@ describe("when a user deletes an input value", () => {

const modal = await screen.findByRole("dialog");
const firstNameInput = await screen.findByLabelText("First name");
expect(firstNameInput).toHaveDisplayValue(mockTeamMembersData[1].firstName);
expect(firstNameInput).toHaveDisplayValue(mockTeamMembersData[2].firstName);

await user.clear(firstNameInput);

Expand Down Expand Up @@ -112,7 +112,7 @@ describe("when a user updates a field correctly", () => {
it("updates the field", async () => {
const firstNameInput = await screen.findByLabelText("First name");
expect(firstNameInput).toHaveDisplayValue(
mockTeamMembersData[1].firstName + "bo",
mockTeamMembersData[2].firstName + "bo",
);
});
it("enables the update user button", async () => {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe("when a user correctly updates an Editor", () => {
it("updates the member table with new details", async () => {
const membersTable = await screen.findByTestId("members-table-add-editor");
await waitFor(() => {
expect(within(membersTable).getByText(/Billbo/)).toBeInTheDocument();
expect(within(membersTable).getByText(/Bilbobo/)).toBeInTheDocument();
});
expect(
await screen.findByText(/Successfully updated a user/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ export const mockTeamMembersData: TeamMember[] = [
id: 1,
role: "teamEditor",
},
{
firstName: "Bilbo",
lastName: "Baggins",
email: "[email protected]",
id: 3,
role: "teamEditor",
},
{
firstName: "Bill",
lastName: "Sharpe",
email: "[email protected]",
id: 2,
role: "platformAdmin",
},
{
firstName: "Bilbo",
lastName: "Baggins",
email: "[email protected]",
id: 3,
role: "teamEditor",
},
];

0 comments on commit 4b77b8b

Please sign in to comment.