Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
140 changes: 86 additions & 54 deletions airflow/www/static/js/grid/renderTaskRows.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,16 @@ import { render } from '@testing-library/react';
import renderTaskRows from './renderTaskRows';
import { TableWrapper } from './utils/testUtils';

const mockGroup = {
id: null,
label: null,
children: [
{
extraLinks: [],
id: 'group_1',
label: 'group_1',
instances: [
{
dagId: 'dagId',
duration: 0,
endDate: '2021-10-26T15:42:03.391939+00:00',
executionDate: '2021-10-25T15:41:09.726436+00:00',
operator: 'DummyOperator',
runId: 'run1',
startDate: '2021-10-26T15:42:03.391917+00:00',
state: 'success',
taskId: 'group_1',
tryNumber: 1,
},
],
describe('Test renderTaskRows', () => {
test('Renders name and task instance', () => {
const task = {
id: null,
label: null,
children: [
{
id: 'group_1.task_1',
label: 'group_1.task_1',
extraLinks: [],
id: 'group_1',
label: 'group_1',
instances: [
{
dagId: 'dagId',
Expand All @@ -62,44 +45,60 @@ const mockGroup = {
runId: 'run1',
startDate: '2021-10-26T15:42:03.391917+00:00',
state: 'success',
taskId: 'group_1.task_1',
taskId: 'group_1',
tryNumber: 1,
},
],
children: [
{
id: 'group_1.task_1',
label: 'group_1.task_1',
extraLinks: [],
instances: [
{
dagId: 'dagId',
duration: 0,
endDate: '2021-10-26T15:42:03.391939+00:00',
executionDate: '2021-10-25T15:41:09.726436+00:00',
operator: 'DummyOperator',
runId: 'run1',
startDate: '2021-10-26T15:42:03.391917+00:00',
state: 'success',
taskId: 'group_1.task_1',
tryNumber: 1,
},
],
},
],
},
],
},
],
instances: [],
};
instances: [],
};

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();
});

describe('Test renderTaskRows', () => {
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: [],
const task = {
id: null,
label: null,
children: [
{
extraLinks: [],
id: 'group_1',
label: 'group_1',
instances: [],
},
],
instances: [],
};
const task = mockGroup;

const { queryByTestId, getByText } = render(
<>{renderTaskRows({ task, dagRunIds: [] })}</>,
Expand All @@ -109,4 +108,37 @@ describe('Test renderTaskRows', () => {
expect(getByText('group_1')).toBeInTheDocument();
expect(queryByTestId('task-instance')).toBeNull();
});

test('Still renders correctly if task instance is null', () => {
const task = {
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],
};

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();
});
});