Skip to content

Commit

Permalink
Merge pull request #30107 from storybookjs/context-menu-updates
Browse files Browse the repository at this point in the history
Addon Test: Context menu updates
  • Loading branch information
ghengeveld authored Dec 27, 2024
2 parents 91f53fd + b82d3b0 commit 413c45e
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 269 deletions.
76 changes: 0 additions & 76 deletions code/addons/test/src/components/ContextMenuItem.tsx

This file was deleted.

21 changes: 13 additions & 8 deletions code/addons/test/src/components/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link as LinkComponent } from 'storybook/internal/components';
import { type TestProviderConfig, type TestProviderState } from 'storybook/internal/core-events';
import { styled } from 'storybook/internal/theming';

import type { TestResultResult } from '../node/reporter';
import { GlobalErrorContext } from './GlobalErrorModal';
import { RelativeTime } from './RelativeTime';

Expand All @@ -19,11 +20,13 @@ const PositiveText = styled.span(({ theme }) => ({
color: theme.color.positiveText,
}));

interface DescriptionProps extends ComponentProps<typeof Wrapper> {
interface DescriptionProps extends Omit<ComponentProps<typeof Wrapper>, 'results'> {
state: TestProviderConfig & TestProviderState;
entryId?: string;
results?: TestResultResult[];
}

export function Description({ state, ...props }: DescriptionProps) {
export function Description({ state, entryId, results, ...props }: DescriptionProps) {
const isMounted = React.useRef(false);
const [isUpdated, setUpdated] = React.useState(false);
const { setModalOpen } = React.useContext(GlobalErrorContext);
Expand All @@ -48,15 +51,17 @@ export function Description({ state, ...props }: DescriptionProps) {
description = state.progress
? `Testing... ${state.progress.numPassedTests}/${state.progress.numTotalTests}`
: 'Starting...';
} else if (entryId && results?.length) {
description = `Ran ${results.length} ${results.length === 1 ? 'test' : 'tests'}`;
} else if (state.failed && !errorMessage) {
description = 'Failed';
} else if (state.crashed || (state.failed && errorMessage)) {
description = (
<>
<LinkComponent isButton onClick={() => setModalOpen(true)}>
{state.error?.name || 'View full error'}
</LinkComponent>
</>
description = setModalOpen ? (
<LinkComponent isButton onClick={() => setModalOpen(true)}>
{state.error?.name || 'View full error'}
</LinkComponent>
) : (
state.error?.name || 'Failed'
);
} else if (state.progress?.finishedAt) {
description = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export const Editing: Story = {
play: async ({ canvasElement }) => {
const screen = within(canvasElement);

screen.getByLabelText(/Open settings/).click();
screen.getByLabelText(/Show settings/).click();
},
};

Expand Down
Loading

0 comments on commit 413c45e

Please sign in to comment.