diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx index cc5118c439..89724f01ea 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx @@ -56,15 +56,64 @@ export const MembersTable = ({ if (members.length === 0) { return ( - - - - - No members found - - - -
+ <> + + + + + No members found + + + + {showAddMemberButton && ( + + + setShowModal(true)}> + Add a new editor + + + + )} +
+ {showAddMemberButton && ( + + + Successfully added a user + + + )} + {showAddMemberButton && ( + + + Failed to add new user, please try again + + + )} + {showModal && ( + + )} + ); } diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.addNewEditor.noExistingMembers.test.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.addNewEditor.noExistingMembers.test.tsx new file mode 100644 index 0000000000..c3f5e64a4d --- /dev/null +++ b/editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.addNewEditor.noExistingMembers.test.tsx @@ -0,0 +1,30 @@ +import { screen, within } from "@testing-library/react"; +import { useStore } from "pages/FlowEditor/lib/store"; + +import { TeamMember } from "../types"; +import { setupTeamMembersScreen } from "./helpers/setupTeamMembersScreen"; + +const mockTeamMembersDataWithNoTeamEditors: TeamMember[] = [ + { + firstName: "Donella", + lastName: "Meadows", + email: "donella@example.com", + id: 1, + role: "platformAdmin", + }, +]; + +describe("when a user views the 'Team members' screen but there are no existing team editors listed", () => { + beforeEach(async () => { + useStore.setState({ teamMembers: mockTeamMembersDataWithNoTeamEditors }); + const { getByText } = await setupTeamMembersScreen(); + getByText("No members found"); + }); + + it("shows the 'add a new editor' button", async () => { + const teamEditorsTable = screen.getByTestId("team-editors"); + expect( + await within(teamEditorsTable).findByText("Add a new editor"), + ).toBeVisible(); + }); +});