Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5038: Enhance test case querySelector/querySelectorAll reliability with ensuring element existance #29

Merged
merged 24 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
df7a973
✨ Added a utility function to ensure element existence with querySele…
Aug 19, 2024
0ddb892
♻️🧪 Refactor year_picker_test's querySelector/querySelectorAll with s…
Aug 19, 2024
25f08e8
♻️🧪 Refactor year_dropdown_test's querySelector/querySelectorAll with…
Aug 19, 2024
5e387a7
♻️🧪 Refactor year_dropdown_options_test's querySelector/querySelector…
Aug 19, 2024
ecb1506
♻️🧪 Refactor month_dropdown_test's querySelector/querySelectorAll wit…
Aug 19, 2024
1ed38f3
♻️🧪 Refactor month_year_dropdown_test's querySelector/querySelectorAl…
Aug 19, 2024
b8c98f6
♻️🧪 Refactor week_picker_test's querySelector/querySelectorAll with s…
Aug 19, 2024
a2602dd
♻️🧪 Refactor week_test's querySelector/querySelectorAll with safeQuer…
Aug 19, 2024
3b6d494
♻️🧪 Refactor week_number_test's querySelector/querySelectorAll with s…
Aug 19, 2024
7daa8a8
♻️🧪 Refactor day_test's querySelector/querySelectorAll with safeQuery…
Aug 19, 2024
f6a4c8d
♻️🧪 Refactor time_input_test's querySelector/querySelectorAll with sa…
Aug 19, 2024
d85f031
♻️🧪 Refactor show_time_test's querySelector/querySelectorAll with saf…
Aug 19, 2024
2dd59fb
♻️🧪 Refactor min_time_test's querySelector/querySelectorAll with safe…
Aug 19, 2024
7e72bda
♻️🧪 Refactor timepicker_test's querySelector/querySelectorAll with sa…
Aug 19, 2024
6e99604
♻️🧪 Refactor calendar_icon's querySelector/querySelectorAll with safe…
Aug 19, 2024
9d1fa8f
♻️🧪 Refactor calendar_test's querySelector/querySelectorAll with safe…
Aug 19, 2024
26eec62
♻️🧪 Refactor datepicker_test's querySelector/querySelectorAll with sa…
Aug 19, 2024
ee22340
♻️ Remove the redundant check of the safeQuerySelector result to not …
Aug 25, 2024
72cc390
♻️ Refactor safeQuerySelector not toBe null test block to notThrow as…
Aug 25, 2024
e5d0568
♻️ Update the safeQuerySelectorAll helper to throw an error if the fo…
Aug 25, 2024
3723386
♻️ Refactor the usage of safeQuerySelectorAll to also pass the requir…
Aug 25, 2024
b98b908
✨ Add SafeElementWrapper utility to support safe query selection chai…
Aug 26, 2024
26c63bd
♻️ Update a calendar_test test case to use SafeQuerySelector chain to…
Aug 26, 2024
767c3b9
🧪✅ Add test cases for safeQuerySelector, safeQuerySelectorAll, and Sa…
Aug 26, 2024
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
21 changes: 13 additions & 8 deletions src/test/calendar_icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from "react";
import CalendarIcon from "../calendar_icon";

import { IconParkSolidApplication } from "./helper_components/calendar_icon";
import { safeQuerySelector } from "./test_utils";

describe("CalendarIcon", () => {
let onClickMock: jest.Mock;
Expand Down Expand Up @@ -38,9 +39,11 @@ describe("CalendarIcon", () => {
it("should fire onClick event when the icon is clicked", () => {
const { container } = render(<CalendarIcon onClick={onClickMock} />);

const icon = container.querySelector("svg.react-datepicker__calendar-icon");
expect(icon).not.toBeNull();
fireEvent.click(icon ?? new Element());
const icon = safeQuerySelector(
container,
"svg.react-datepicker__calendar-icon",
);
fireEvent.click(icon);

expect(onClickMock).toHaveBeenCalledTimes(1);
});
Expand All @@ -50,9 +53,8 @@ describe("CalendarIcon", () => {
<CalendarIcon icon="fa-example-icon" onClick={onClickMock} />,
);

const icon = container.querySelector("i.fa-example-icon");
expect(icon).not.toBeNull();
fireEvent.click(icon ?? new Element());
const icon = safeQuerySelector(container, "i.fa-example-icon");
fireEvent.click(icon);

expect(onClickMock).toHaveBeenCalledTimes(1);
});
Expand All @@ -75,8 +77,11 @@ describe("CalendarIcon", () => {
/>,
);

const icon = container.querySelector("svg.react-datepicker__calendar-icon");
fireEvent.click(icon ?? new Element());
const icon = safeQuerySelector(
container,
"svg.react-datepicker__calendar-icon",
);
fireEvent.click(icon);

expect(onClickMock).toHaveBeenCalledTimes(1);
expect(onClickCustomIcon).toHaveBeenCalledTimes(1);
Expand Down
Loading
Loading