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

Feature/csf #1050

Merged
merged 30 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1f5a231
convertion of 3 tests to CSF
Oct 20, 2022
2ee7186
added missing dependencies to make the interaction testing run
Oct 24, 2022
1ee5036
converted alert trigger, asyncimage and autocomplete chroma
Oct 26, 2022
4703889
reworked stories to CSF
Oct 27, 2022
55410ef
L to M components CSF version
Oct 27, 2022
e08b450
added last doable tests
Oct 28, 2022
c550469
some tests were not converted by mistake
Oct 31, 2022
0cf2f68
fixed linting error
Oct 31, 2022
bf4eab2
added missing file
Oct 31, 2022
5788bec
removed unnecessary dependency / reworked tests syntax
Nov 1, 2022
068d5bc
fixed linting errors
Nov 2, 2022
8070de1
renamed some stories that were not named as before the conversion
Nov 2, 2022
bcbe75d
added await to userEvents
Nov 2, 2022
46a4952
added await on promises
Nov 4, 2022
26818a5
revert to user-event version pre story / removed await for type / tab…
Nov 10, 2022
7c52a81
indentation fix
Nov 10, 2022
c3914b9
merge master
Nov 10, 2022
0f58574
fix for new eslint config
Nov 10, 2022
e9c5634
removed unnecessary depedency
Nov 10, 2022
e18573a
moved story names next to their declarations
Nov 10, 2022
70e1566
reworked storyname position in certain tests
Nov 10, 2022
d57b061
removed last awaits on userEvents
Nov 10, 2022
bd47927
Replacement of the new property with a class selector
alexasselin008 Nov 10, 2022
b702758
change the way to get the last element
alexasselin008 Nov 10, 2022
2ffc6b8
move dependencies to main package.json
alexasselin008 Nov 10, 2022
50f39db
fix selector to not use lastchild
alexasselin008 Nov 10, 2022
92a1245
change to last child
alexasselin008 Nov 10, 2022
2498631
Merge branch 'master' into feature/csf
Nov 14, 2022
0e617f3
Merge branch 'feature/csf' of github.com:gsoft-inc/sg-orbit into feat…
Nov 14, 2022
4a73322
removed unnecessary chromaticPauseAnimationAtEnd
Nov 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ test("do not dismiss on outside click", async () => {
</AlertTrigger>
);

act(() => {
userEvent.click(getByTestId("trigger"));
await act(() => {
return userEvent.click(getByTestId("trigger"));
});

await waitFor(() => expect(getByTestId("alert")).toBeInTheDocument());

act(() => {
userEvent.click(document.body);
await act(() => {
return userEvent.click(document.body);
});

await waitFor(() => expect(getByTestId("alert")).toBeInTheDocument());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ test("when a query is cleared with the clear button, hide the overlay", async ()

await waitFor(() => expect(getByTestId("overlay")).toBeInTheDocument());

act(() => {
userEvent.click(container.querySelector(":scope .o-ui-search-input-clear-button"));
await act(() => {
return userEvent.click(container.querySelector(":scope .o-ui-search-input-clear-button"));
});

await waitFor(() => expect(getByTestId("autocomplete")).toHaveValue(""));
Expand Down Expand Up @@ -334,8 +334,8 @@ test("when no value is selected, leaving the autocomplete without selecting a ne

await waitFor(() => expect(getByTestId("overlay")).toBeInTheDocument());

act(() => {
userEvent.click(document.body);
await act(() => {
return userEvent.click(document.body);
});

await waitFor(() => expect(queryByTestId("overlay")).not.toBeInTheDocument());
Expand Down Expand Up @@ -407,14 +407,14 @@ test("when opened, on tab keydown, close and select the next tabbable element",
await waitFor(() => expect(getByTestId("overlay")).toBeInTheDocument());

// First tab move the focus to the clear button.
act(() => {
userEvent.tab();
await act(() => {
return userEvent.tab();
});

await waitFor(() => expect(getByTestId("overlay")).toBeInTheDocument());

act(() => {
userEvent.tab();
await act(() => {
return userEvent.tab();
});

await waitFor(() => expect(queryByTestId("overlay")).not.toBeInTheDocument());
Expand Down Expand Up @@ -475,8 +475,8 @@ test("when the clear button is clicked, the focus is moved to the input", async

await waitFor(() => expect(getByTestId("overlay")).toBeInTheDocument());

act(() => {
userEvent.click(container.querySelector(":scope .o-ui-search-input-clear-button"));
await act(() => {
return userEvent.click(container.querySelector(":scope .o-ui-search-input-clear-button"));
});

await waitFor(() => expect(getByTestId("autocomplete")).toHaveFocus());
Expand All @@ -495,8 +495,8 @@ test("when in a field, clicking on the field label focus the autocomplete", asyn
</Field>
);

act(() => {
userEvent.click(getByTestId("label"));
await act(() => {
return userEvent.click(getByTestId("label"));
});

await waitFor(() => expect(getByTestId("autocomplete")).toHaveFocus());
Expand Down
12 changes: 6 additions & 6 deletions packages/components/src/button/tests/jest/ToggleButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ test("call onChange when the button is selected", async () => {
</ToggleButton>
);

act(() => {
userEvent.click(getByTestId("toggle-button"));
await act(() => {
return userEvent.click(getByTestId("toggle-button"));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), true));
Expand All @@ -80,12 +80,12 @@ test("call onChange when the button is unselected", async () => {
</ToggleButton>
);

act(() => {
userEvent.click(getByTestId("toggle-button"));
await act(() => {
return userEvent.click(getByTestId("toggle-button"));
});

act(() => {
userEvent.click(getByTestId("toggle-button"));
await act(() => {
return userEvent.click(getByTestId("toggle-button"));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ test("call onChange when the button is selected", async () => {
</ToggleIconButton>
);

act(() => {
userEvent.click(getByTestId("toggle-icon-button"));
await act(() => {
return userEvent.click(getByTestId("toggle-icon-button"));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), true));
Expand All @@ -45,12 +45,12 @@ test("call onChange when the button is unselected", async () => {
</ToggleIconButton>
);

act(() => {
userEvent.click(getByTestId("toggle-icon-button"));
await act(() => {
return userEvent.click(getByTestId("toggle-icon-button"));
});

act(() => {
userEvent.click(getByTestId("toggle-icon-button"));
await act(() => {
return userEvent.click(getByTestId("toggle-icon-button"));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), false));
Expand Down
32 changes: 16 additions & 16 deletions packages/components/src/checkbox/tests/jest/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ test("call onChange, when the checkbox is checked", async () => {
<Checkbox onChange={handler} data-testid="checkbox">Milky Way</Checkbox>
);

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), true));
Expand All @@ -68,12 +68,12 @@ test("call onChange when the checkbox is unchecked", async () => {
<Checkbox onChange={handler} data-testid="checkbox">Milky Way</Checkbox>
);

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), false));
Expand All @@ -87,8 +87,8 @@ test("call onValueChange when the checkbox is checked", async () => {
<Checkbox onValueChange={handler} data-testid="checkbox">Milky Way</Checkbox>
);

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), true));
Expand All @@ -102,12 +102,12 @@ test("call onValueChange when the checkbox is unchecked", async () => {
<Checkbox onValueChange={handler} data-testid="checkbox">Milky Way</Checkbox>
);

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), false));
Expand All @@ -121,8 +121,8 @@ test("call onValueChange when the checkbox goes from indeterminate to checked",
<Checkbox defaultIndeterminate onValueChange={handler} data-testid="checkbox">Milky Way</Checkbox>
);

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), true));
Expand All @@ -136,8 +136,8 @@ test("dont call onValueChange when the checkbox is disabled", async () => {
<Checkbox disabled onValueChange={handler} data-testid="checkbox">Milky Way</Checkbox>
);

act(() => {
userEvent.click(getInput(getByTestId("checkbox")));
await act(() => {
return userEvent.click(getInput(getByTestId("checkbox")));
});

await waitFor(() => expect(handler).not.toHaveBeenCalled());
Expand Down
68 changes: 34 additions & 34 deletions packages/components/src/checkbox/tests/jest/CheckboxGroup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ test("when a checkbox value is not provided, the value is autogenerated", async
</CheckboxGroup>
);

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[0]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[0]));
});

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[1]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[1]));
});

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[2]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[2]));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), ["0", "1", "2"]));
Expand Down Expand Up @@ -133,8 +133,8 @@ test("call onChange when a single checkbox is selected", async () => {
</CheckboxGroup>
);

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[0]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[0]));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), ["1"]));
Expand All @@ -154,12 +154,12 @@ test("call onChange when multiple checkbox are selected", async () => {

const buttons = getAllByTestId("checkbox");

act(() => {
userEvent.click(getInput(buttons[0]));
await act(() => {
return userEvent.click(getInput(buttons[0]));
});

act(() => {
userEvent.click(getInput(buttons[2]));
await act(() => {
return userEvent.click(getInput(buttons[2]));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), ["1", "3"]));
Expand All @@ -179,16 +179,16 @@ test("call onChange when a checkbox is unselected", async () => {

const buttons = getAllByTestId("checkbox");

act(() => {
userEvent.click(getInput(buttons[0]));
await act(() => {
return userEvent.click(getInput(buttons[0]));
});

act(() => {
userEvent.click(getInput(buttons[2]));
await act(() => {
return userEvent.click(getInput(buttons[2]));
});

act(() => {
userEvent.click(getInput(buttons[0]));
await act(() => {
return userEvent.click(getInput(buttons[0]));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), ["3"]));
Expand All @@ -206,12 +206,12 @@ test("pass an empty array when no checkbox are selected", async () => {
</CheckboxGroup>
);

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[0]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[0]));
});

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[0]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[0]));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), []));
Expand All @@ -229,8 +229,8 @@ test("call the checkbox onValueChange handler when a checkbox is selected", asyn
</CheckboxGroup>
);

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[0]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[0]));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), true));
Expand All @@ -248,8 +248,8 @@ test("call the checkbox onChange handler when a checkbox is selected", async ()
</CheckboxGroup>
);

act(() => {
userEvent.click(getInput(getAllByTestId("checkbox")[0]));
await act(() => {
return userEvent.click(getInput(getAllByTestId("checkbox")[0]));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), true));
Expand Down Expand Up @@ -324,8 +324,8 @@ describe("with toggle buttons", () => {
</CheckboxGroup>
);

act(() => {
userEvent.click(getByTestId("button-1"));
await act(() => {
fraincs marked this conversation as resolved.
Show resolved Hide resolved
return userEvent.click(getByTestId("button-1"));
});

await waitFor(() => expect(getByTestId("button-1")).toHaveAttribute("aria-checked", "true"));
Expand All @@ -342,8 +342,8 @@ describe("with toggle buttons", () => {
</CheckboxGroup>
);

act(() => {
userEvent.click(getByTestId("button-1"));
await act(() => {
return userEvent.click(getByTestId("button-1"));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), ["1"]));
Expand All @@ -361,12 +361,12 @@ describe("with toggle buttons", () => {
</CheckboxGroup>
);

act(() => {
userEvent.click(getByTestId("button-1"));
await act(() => {
return userEvent.click(getByTestId("button-1"));
});

act(() => {
userEvent.click(getByTestId("button-1"));
await act(() => {
return userEvent.click(getByTestId("button-1"));
});

await waitFor(() => expect(handler).toHaveBeenLastCalledWith(expect.anything(), []));
Expand Down