-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:evergreen-ci/ui into dependabot/npm…
…_and_yarn/leafygreen-ui/number-input-2.1.0
- Loading branch information
Showing
17 changed files
with
559 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
apps/parsley/src/components/LogRow/SectionHeader/SectionHeader.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import styled from "@emotion/styled"; | ||
import { SectionStatus } from "constants/logs"; | ||
import { CustomMeta, CustomStoryObj } from "test_utils/types"; | ||
import SectionHeader from "."; | ||
|
||
export default { | ||
component: SectionHeader, | ||
} satisfies CustomMeta<typeof SectionHeader>; | ||
|
||
const SectionHeaderStory = () => ( | ||
<Container> | ||
<SectionHeader | ||
{...sectionHeaderProps} | ||
functionName="populate_expansions" | ||
lineIndex={0} | ||
/> | ||
<SectionHeader | ||
{...sectionHeaderProps} | ||
functionName="setup_mongodb_database_and_seed_with_data" | ||
lineIndex={1} | ||
/> | ||
<SectionHeader | ||
{...sectionHeaderProps} | ||
functionName="build_frontend" | ||
lineIndex={2} | ||
status={SectionStatus.Fail} | ||
/> | ||
</Container> | ||
); | ||
|
||
export const SectionHeaderSingle: CustomStoryObj<typeof SectionHeader> = { | ||
render: () => <SectionHeaderStory />, | ||
}; | ||
|
||
// TODO: Update this story with LogPane examples which should handle log rendering internally. | ||
|
||
const Container = styled.div` | ||
height: 400px; | ||
width: 800px; | ||
`; | ||
|
||
const sectionHeaderProps = { | ||
defaultOpen: false, | ||
onFocus: () => {}, | ||
onOpen: () => {}, | ||
status: SectionStatus.Pass, | ||
}; |
100 changes: 100 additions & 0 deletions
100
apps/parsley/src/components/LogRow/SectionHeader/SectionHeader.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { SectionStatus } from "constants/logs"; | ||
import { render, screen, userEvent } from "test_utils"; | ||
import SectionHeader from "."; | ||
|
||
describe("sectionHeader", () => { | ||
it("displays function name", () => { | ||
render(<SectionHeader {...sectionHeaderProps} functionName="load_data" />); | ||
expect(screen.getByText("Function: load_data")).toBeVisible(); | ||
}); | ||
|
||
it("displays checkmark icon if status is passing", () => { | ||
render( | ||
<SectionHeader {...sectionHeaderProps} status={SectionStatus.Pass} />, | ||
); | ||
expect( | ||
screen.getByLabelText("Checkmark With Circle Icon"), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it("displays X icon if status is failing", () => { | ||
render( | ||
<SectionHeader {...sectionHeaderProps} status={SectionStatus.Fail} />, | ||
); | ||
expect(screen.getByLabelText("XWith Circle Icon")).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders as opened if 'defaultOpen' prop is true", async () => { | ||
render(<SectionHeader {...sectionHeaderProps} defaultOpen />); | ||
expect(screen.getByDataCy("section-header")).toHaveAttribute( | ||
"aria-expanded", | ||
"true", | ||
); | ||
}); | ||
|
||
it("renders as closed if 'defaultOpen' prop is false", async () => { | ||
render(<SectionHeader {...sectionHeaderProps} defaultOpen={false} />); | ||
expect(screen.getByDataCy("section-header")).toHaveAttribute( | ||
"aria-expanded", | ||
"false", | ||
); | ||
}); | ||
|
||
it("should call onOpen function when 'open' button is clicked", async () => { | ||
const user = userEvent.setup(); | ||
const onOpen = vi.fn(); | ||
render(<SectionHeader {...sectionHeaderProps} onOpen={onOpen} />); | ||
const openButton = screen.getByRole("button", { | ||
name: "Open", | ||
}); | ||
await user.click(openButton); | ||
expect(onOpen).toHaveBeenCalledTimes(1); | ||
expect(onOpen).toHaveBeenCalledWith("load_data"); | ||
}); | ||
|
||
it("should call onFocus function when 'focus' button is clicked", async () => { | ||
const user = userEvent.setup(); | ||
const onFocus = vi.fn(); | ||
render(<SectionHeader {...sectionHeaderProps} onFocus={onFocus} />); | ||
const focusButton = screen.getByRole("button", { | ||
name: "Focus", | ||
}); | ||
await user.click(focusButton); | ||
expect(onFocus).toHaveBeenCalledTimes(1); | ||
expect(onFocus).toHaveBeenCalledWith("load_data"); | ||
}); | ||
|
||
it("can open and close the section header using 'open' and 'close' buttons", async () => { | ||
const user = userEvent.setup(); | ||
render(<SectionHeader {...sectionHeaderProps} defaultOpen={false} />); | ||
expect(screen.getByDataCy("section-header")).toHaveAttribute( | ||
"aria-expanded", | ||
"false", | ||
); | ||
const openButton = screen.getByRole("button", { | ||
name: "Open", | ||
}); | ||
await user.click(openButton); | ||
expect(screen.getByDataCy("section-header")).toHaveAttribute( | ||
"aria-expanded", | ||
"true", | ||
); | ||
const closeButton = screen.getByRole("button", { | ||
name: "Close", | ||
}); | ||
await user.click(closeButton); | ||
expect(screen.getByDataCy("section-header")).toHaveAttribute( | ||
"aria-expanded", | ||
"false", | ||
); | ||
}); | ||
}); | ||
|
||
const sectionHeaderProps = { | ||
defaultOpen: false, | ||
functionName: "load_data", | ||
lineIndex: 0, | ||
onFocus: vi.fn(), | ||
onOpen: vi.fn(), | ||
status: SectionStatus.Pass, | ||
}; |
Oops, something went wrong.