-
Notifications
You must be signed in to change notification settings - Fork 30
Feat/2052/ab comparison custom filters #2069
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
Open
felipebergamin
wants to merge
3
commits into
kernelci:main
Choose a base branch
from
profusion:feat/2052/ab-comparison-custom-filters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+724
−169
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6e0c5eb
feat(tree-compare): add status pair filter components and Storybook s…
felipebergamin d3323b1
feat(tree-compare): filter breakdown tables by status pairs
felipebergamin b985a83
feat(tree-compare): remember status pair filters in localStorage
felipebergamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
69 changes: 0 additions & 69 deletions
69
dashboard/src/pages/TreeCompare/components/CompareChangeStats.tsx
This file was deleted.
Oops, something went wrong.
134 changes: 134 additions & 0 deletions
134
dashboard/src/pages/TreeCompare/components/CompareStatusPairFilter.stories.tsx
This file contains hidden or 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,134 @@ | ||
| import type { JSX } from 'react'; | ||
| import { useState } from 'react'; | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { expect, fn, userEvent, within } from '@storybook/test'; | ||
| import { IntlProvider } from 'react-intl'; | ||
|
|
||
| import { LOCALES } from '@/locales/constants'; | ||
| import { messages } from '@/locales/messages'; | ||
|
|
||
| import { TooltipProvider } from '@/components/Tooltip'; | ||
|
|
||
| import { | ||
| CompareStatusPairChip, | ||
| CompareStatusPairFilter, | ||
| CompareStatusSelect, | ||
| type CompareStatusPair, | ||
| } from './CompareStatusPairFilter'; | ||
|
|
||
| const DEFAULT_PAIRS: CompareStatusPair[] = [ | ||
| { from: 'PASS', to: 'FAIL' }, | ||
| { from: 'FAIL', to: 'PASS' }, | ||
| ]; | ||
|
|
||
| const meta: Meta<typeof CompareStatusPairFilter> = { | ||
| title: 'Tree Compare/Status Pair Filter', | ||
| component: CompareStatusPairFilter, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| tags: ['autodocs'], | ||
| decorators: [ | ||
| (Story): JSX.Element => ( | ||
| <IntlProvider messages={messages[LOCALES.EN_US]} locale={LOCALES.EN_US}> | ||
| <TooltipProvider> | ||
| <div className="w-[min(40rem,90vw)]"> | ||
| <Story /> | ||
| </div> | ||
| </TooltipProvider> | ||
| </IntlProvider> | ||
| ), | ||
| ], | ||
| args: { | ||
| value: DEFAULT_PAIRS, | ||
| onChange: fn(), | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| function StatefulFilter({ | ||
| initialValue, | ||
| onChange, | ||
| }: { | ||
| initialValue: CompareStatusPair[]; | ||
| onChange: (value: CompareStatusPair[]) => void; | ||
| }): JSX.Element { | ||
| const [value, setValue] = useState(initialValue); | ||
|
|
||
| return ( | ||
| <CompareStatusPairFilter | ||
| value={value} | ||
| onChange={nextValue => { | ||
| setValue(nextValue); | ||
| onChange(nextValue); | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export const Default: Story = { | ||
| render: args => ( | ||
| <StatefulFilter initialValue={[...args.value]} onChange={args.onChange} /> | ||
| ), | ||
| }; | ||
|
|
||
| export const Empty: Story = { | ||
| args: { | ||
| value: [], | ||
| }, | ||
| render: args => <StatefulFilter initialValue={[]} onChange={args.onChange} />, | ||
| }; | ||
|
|
||
| export const DuplicateGuard: Story = { | ||
| render: args => ( | ||
| <StatefulFilter initialValue={[...args.value]} onChange={args.onChange} /> | ||
| ), | ||
| play: async ({ canvasElement }) => { | ||
| const canvas = within(canvasElement); | ||
| const page = within(document.body); | ||
|
|
||
| await userEvent.click(canvas.getByRole('combobox', { name: 'From' })); | ||
| await userEvent.click(page.getByRole('option', { name: 'PASS' })); | ||
| await userEvent.click(canvas.getByRole('combobox', { name: 'To' })); | ||
| await userEvent.click(page.getByRole('option', { name: 'FAIL' })); | ||
|
|
||
| const addButton = canvas.getByRole('button', { name: 'Add' }); | ||
| await expect(addButton).toBeDisabled(); | ||
|
|
||
| await userEvent.click( | ||
| canvas.getByRole('button', { name: 'Remove PASS to FAIL filter' }), | ||
| ); | ||
| await expect(addButton).toBeEnabled(); | ||
|
|
||
| await userEvent.click(addButton); | ||
| await expect( | ||
| canvas.getByRole('button', { name: 'Remove PASS to FAIL filter' }), | ||
| ).toBeInTheDocument(); | ||
| }, | ||
| }; | ||
|
|
||
| export const StatusSelect: Story = { | ||
| render: function Render() { | ||
| const [value, setValue] = useState<CompareStatusPair['from']>(); | ||
| return ( | ||
| <CompareStatusSelect | ||
| id="status-select-story" | ||
| label="From" | ||
| value={value} | ||
| onChange={setValue} | ||
| /> | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const StatusPairChip: Story = { | ||
| render: args => ( | ||
| <CompareStatusPairChip | ||
| pair={{ from: 'PASS', to: 'FAIL' }} | ||
| onRemove={() => args.onChange([])} | ||
| /> | ||
| ), | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are those .stories. files running in prod?