fix: update test cases to match new UI labels

- Update RepeatEvent.test.tsx to use correct selectors and text matching
- Update EventDisplay.test.tsx to use 'Notification' instead of 'Alarm'
- Update EventModal.test.tsx to use new label names and fix description input tests
- Update Calendar.test.tsx to use new placeholder text 'Start typing a name or email'
- Fix EventDisplay.tsx to use 'Notification' label consistently
This commit is contained in:
lenhanphung
2025-10-02 14:18:32 +07:00
parent 3261479874
commit 4eb2c86771
9 changed files with 186 additions and 183 deletions
+2 -2
View File
@@ -217,7 +217,7 @@ describe("calendar Availability search", () => {
renderWithProviders(<CalendarTestWrapper />, preloadedState);
const input = screen.getByPlaceholderText(/search user/i);
const input = screen.getByPlaceholderText(/start typing a name or email/i);
userEvent.type(input, "New");
const option = await screen.findByText("New User");
@@ -242,7 +242,7 @@ describe("calendar Availability search", () => {
});
renderWithProviders(<CalendarTestWrapper />, preloadedState);
const input = screen.getByPlaceholderText(/search user/i);
const input = screen.getByPlaceholderText(/start typing a name or email/i);
userEvent.type(input, "Alice");
const option = await screen.findByText("Alice");
+7 -5
View File
@@ -118,7 +118,7 @@ async function setupEventPopover(
fireEvent.click(showMoreButton);
}
});
const select = screen.getByLabelText(/repetition/i);
const select = screen.getByLabelText(/repeat/i);
userEvent.click(select);
return jest.spyOn(apiUtils, "api");
@@ -155,13 +155,15 @@ async function expectRRule(expected: any) {
describe("RepeatEvent", () => {
it("renders with no repetition by default", () => {
setupRepeatEvent();
expect(screen.getByLabelText(/repetition/i)).toBeInTheDocument();
expect(screen.queryByText(/daily/i)).not.toBeInTheDocument();
expect(screen.getByText(/Repeat every/i)).toBeInTheDocument();
// Check that the select exists and has default value
const select = screen.getByRole("combobox");
expect(select).toBeInTheDocument();
});
it("allows selecting repetition frequency", async () => {
const { setRepetition } = setupRepeatEvent();
const select = screen.getByLabelText(/repetition/i);
const select = screen.getByRole("combobox");
act(() => {
userEvent.click(select);
});
@@ -176,7 +178,7 @@ describe("RepeatEvent", () => {
it("renders interval input when frequency is selected", () => {
setupRepeatEvent({ freq: "daily", interval: 2 });
expect(screen.getByText(/interval/i)).toBeInTheDocument();
expect(screen.getByText(/Repeat every/i)).toBeInTheDocument();
expect(screen.getByDisplayValue("2")).toBeInTheDocument();
});
@@ -1039,9 +1039,9 @@ describe("Event Full Display", () => {
});
await waitFor(() => {
expect(screen.getByLabelText(/Alarm/i)).toBeInTheDocument();
expect(screen.getByLabelText(/Repetition/i)).toBeInTheDocument();
expect(screen.getByLabelText(/Visibility/i)).toBeInTheDocument();
expect(screen.getByLabelText(/Notification/i)).toBeInTheDocument();
expect(screen.getByLabelText(/Repeat/i)).toBeInTheDocument();
expect(screen.getByText(/Visible to/i)).toBeInTheDocument();
});
fireEvent.click(screen.getByText("Show Less"));
});
+12 -8
View File
@@ -116,10 +116,9 @@ describe("EventPopover", () => {
const titleInput = screen.getByRole("textbox", { name: /title/i });
expect(titleInput).toBeInTheDocument();
const descriptionInput = screen.getByRole("textbox", {
name: /description/i,
});
expect(descriptionInput).toBeInTheDocument();
// Description input is only visible after clicking "Add description" button
const addDescriptionButton = screen.getByText("Add description");
expect(addDescriptionButton).toBeInTheDocument();
const calendarSelect = screen.getByRole("combobox", { name: /calendar/i });
expect(calendarSelect).toBeInTheDocument();
@@ -135,9 +134,9 @@ describe("EventPopover", () => {
// Extended labels appear
expect(screen.getAllByText("Repeat")).toHaveLength(1);
expect(screen.getAllByText("Alarm")).toHaveLength(1);
expect(screen.getAllByText("Visibility")).toHaveLength(1);
expect(screen.getAllByText("Show as")).toHaveLength(1);
expect(screen.getAllByText("Notification")).toHaveLength(1);
expect(screen.getAllByText("Visible to")).toHaveLength(1);
expect(screen.getAllByText("Show me as")).toHaveLength(1);
});
it("fills start from selectedRange", () => {
@@ -160,6 +159,9 @@ describe("EventPopover", () => {
});
expect(screen.getByLabelText("Title")).toHaveValue("My Event");
// Click "Add description" button first
fireEvent.click(screen.getByText("Add description"));
fireEvent.change(screen.getByLabelText("Description"), {
target: { value: "Event Description" },
});
@@ -190,7 +192,7 @@ describe("EventPopover", () => {
fireEvent.change(screen.getByLabelText("Title"), {
target: { value: "newEvent" },
});
const select = screen.getByLabelText("Search user");
const select = screen.getByLabelText("Start typing a name or email");
act(() => {
select.focus();
@@ -275,6 +277,8 @@ describe("EventPopover", () => {
target: { value: newEvent.end.split("T")[0] },
});
// Click "Add description" button first
fireEvent.click(screen.getByText("Add description"));
fireEvent.change(screen.getByLabelText("Description"), {
target: { value: newEvent.description },
});