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

add tests for the Tabs component #401

Merged

Conversation

harisbikovic
Copy link
Contributor

Related: #390
This PR adds tests for the Tabs component.

@harisbikovic harisbikovic marked this pull request as ready for review October 30, 2023 13:48
@harisbikovic harisbikovic marked this pull request as draft November 9, 2023 11:41
@harisbikovic harisbikovic marked this pull request as ready for review November 13, 2023 11:56
@harisbikovic harisbikovic marked this pull request as draft November 13, 2023 11:56
@harisbikovic harisbikovic force-pushed the tabs_test_branch branch 3 times, most recently from 11ef2bb to c83ee65 Compare November 15, 2023 08:28
@harisbikovic harisbikovic marked this pull request as ready for review November 15, 2023 08:31
@harisbikovic harisbikovic force-pushed the tabs_test_branch branch 4 times, most recently from 9e82f8d to 540b989 Compare November 16, 2023 09:53
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Show resolved Hide resolved
@harisbikovic harisbikovic force-pushed the tabs_test_branch branch 2 times, most recently from e9b3da6 to ebf4250 Compare December 15, 2023 14:51
frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
frontend/src/components/Tabs.test.tsx Show resolved Hide resolved
);

expect(screen.getByTestId("tab1-content")).toBeVisible();
expect(screen.queryByTestId("tab2-content")).not.toBeInTheDocument();
Copy link
Contributor

@szakhlypa szakhlypa Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test repeat renders the content of the active tab only test?

Copy link
Contributor Author

@harisbikovic harisbikovic Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we test what happens when there is no defaultActiveKey specified whereas in the above mentioned renders the content of the active tab only test we specify the defaultActiveKey. So we're testing the same behaviour but in different scenarious(when defaultActiveKey is given and when it's not given). This was my idea when writing the tests, but of course if it is redundant I can delete one of the tests. Let me know your opinion?

frontend/src/components/Tabs.test.tsx Outdated Show resolved Hide resolved
expect(screen.getByTestId("tab1-content")).toBeVisible();
expect(screen.queryByTestId("tab2-content")).not.toBeInTheDocument();
});
it("when the key specified is not present in any of the Tabs won't render any Tab's content", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the intended behaviour?

Copy link
Contributor Author

@harisbikovic harisbikovic Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it definitely should render any tab's content but that is not the case. I'm not sure what can be done about it?

expect(tabs[1]).toHaveTextContent("Tab 3");
expect(tabs[2]).toHaveTextContent("Tab 1");
});
it("when defaultActiveKey given and tabsOrder differs from the order of children, renders tabs as specified in tabsOrder", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the tabs rendering order depend on defaultActiveKey?
Do you want to check that if defaultActiveKey is present, regardless of the tabsOrder, it determines which tab's content is rendered?

const tab1 = screen.getByText("Tab 1");
expect(tab1).toHaveClass("custom-tab-class");
});
it("renders the Tab component with the specified title", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test repeat the it("renders tab elements correctly" above?
Do you want to set className here, and if so - what for?

@szakhlypa szakhlypa merged commit ce97cef into edgehog-device-manager:release-0.7 Jan 23, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants