Skip to content

Commit

Permalink
[dagit] Fix InstigationTick "Skipped" message if zero runs (#7527)
Browse files Browse the repository at this point in the history
## Summary

Resolves #7274.

The "Skipped" tag on instigation tick tags shows an incorrect tooltip when there are no run keys. Just a JS error, the array is always truthy.

## Test Plan

Added a jest test.
  • Loading branch information
hellendag committed Apr 22, 2022
1 parent 610745b commit 772afa6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {render, screen, waitFor} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import * as React from 'react';

import {InstigationTickStatus} from '../types/globalTypes';

import {TickTag} from './InstigationTick';
import {TickTagFragment} from './types/TickTagFragment';

describe('TickTag', () => {
const tick: TickTagFragment = {
__typename: 'InstigationTick',
id: 'foobar',
status: InstigationTickStatus.SUCCESS,
timestamp: Date.now(),
skipReason: 'lol skipped',
runIds: [],
runKeys: [],
error: null,
};

describe('Skipped', () => {
it('renders skip reason if no run keys', async () => {
const skippedTick = {...tick, status: InstigationTickStatus.SKIPPED};

render(<TickTag tick={skippedTick} />);

const tag = screen.queryByText(/skipped/i);
expect(tag).toBeVisible();

userEvent.hover(tag as HTMLElement);
await waitFor(() => {
expect(screen.queryByText('lol skipped')).toBeVisible();
});
});

it('renders info about requested run count if run keys', async () => {
const skippedTick = {...tick, status: InstigationTickStatus.SKIPPED, runKeys: ['foo', 'bar']};

render(<TickTag tick={skippedTick} />);

const tag = screen.queryByText(/skipped/i);
expect(tag).toBeVisible();

userEvent.hover(tag as HTMLElement);
await waitFor(() => {
expect(screen.queryByText(/2 runs requested, but skipped/i)).toBeVisible();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const TickTag: React.FC<{
return tag;

case InstigationTickStatus.SKIPPED:
if (tick.runKeys) {
if (tick.runKeys.length) {
const message = `${tick.runKeys.length} runs requested, but skipped because the runs already exist for the requested keys.`;
return (
<Tooltip position="right" content={message}>
Expand Down

0 comments on commit 772afa6

Please sign in to comment.