Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/www/static/js/grid/renderTaskRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const TaskInstances = ({
<Flex justifyContent="flex-end">
{dagRunIds.map((runId) => {
// Check if an instance exists for the run, or return an empty box
const instance = task.instances.find((gi) => gi.runId === runId);
const instance = task.instances.find((gi) => gi && gi.runId === runId);
const isSelected = selectedRunId === runId;
return (
<Box
Expand Down
72 changes: 48 additions & 24 deletions airflow/www/static/js/grid/renderTaskRows.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,43 @@ const mockGroup = {
instances: [],
};

const nullMockGroup = {
id: null,
label: null,
children: [
{
extraLinks: [],
id: 'group_1',
label: 'group_1',
instances: [null],
children: [
{
id: 'group_1.task_1',
label: 'group_1.task_1',
extraLinks: [],
instances: [null],
},
],
},
],
instances: [null],
};

describe('Test renderTaskRows', () => {
test('Renders name and task instance', () => {
const task = mockGroup;

const { queryByTestId, getByText } = render(
<>{renderTaskRows({ task, dagRunIds: ['run1'] })}</>,
{ wrapper: TableWrapper },
);

expect(getByText('group_1')).toBeInTheDocument();
expect(queryByTestId('task-instance')).toBeDefined();
expect(queryByTestId('blank-task')).toBeNull();
});

test('Still renders names if there are no instances', () => {
global.gridData = {
groups: {
id: null,
label: null,
children: [
{
extraLinks: [],
id: 'group_1',
label: 'group_1',
instances: [],
children: [
{
id: 'group_1.task_1',
label: 'group_1.task_1',
extraLinks: [],
instances: [],
},
],
},
],
instances: [],
},
dagRuns: [],
};
Comment thread
jedcunningham marked this conversation as resolved.
const task = mockGroup;

const { queryByTestId, getByText } = render(
Expand All @@ -109,4 +120,17 @@ describe('Test renderTaskRows', () => {
expect(getByText('group_1')).toBeInTheDocument();
expect(queryByTestId('task-instance')).toBeNull();
});

test('Still renders correctly if task instance is null', () => {
const task = nullMockGroup;

const { queryByTestId, getByText } = render(
<>{renderTaskRows({ task, dagRunIds: ['run1'] })}</>,
{ wrapper: TableWrapper },
);

expect(getByText('group_1')).toBeInTheDocument();
expect(queryByTestId('task-instance')).toBeNull();
expect(queryByTestId('blank-task')).toBeInTheDocument();
});
});