Skip to content

Commit

Permalink
Migrate more
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejeambrun committed Aug 26, 2022
1 parent f132b50 commit 0d00add
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion airflow/www/static/js/api/useConfirmMarkTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function useConfirmMarkTask({
future,
upstream,
downstream,
state: state || 'null',
state,
});

mapIndexes.forEach((mi: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,53 @@

/* global describe, test, expect */

import type { DagRun } from 'src/types';
import { areActiveRuns } from './useGridData';

const commonDagRunParams = {
runId: 'runId',
executionDate: '2022-01-01T10:00+00:00',
dataIntervalStart: '2022-01-01T05:00+00:00',
dataIntervalEnd: '2022-01-01T10:00+00:00',
startDate: null,
endDate: null,
lastSchedulingDecision: null,
};

describe('Test areActiveRuns()', () => {
test('Correctly detects active runs', () => {
const runs = [
{ runType: 'scheduled', state: 'success' },
{ runType: 'manual', state: 'queued' },
const runs: DagRun[] = [
{ runType: 'scheduled', state: 'success', ...commonDagRunParams },
{ runType: 'manual', state: 'queued', ...commonDagRunParams },
];
expect(areActiveRuns(runs)).toBe(true);
});

test('Returns false when all runs are resolved', () => {
const runs = [
{ runType: 'scheduled', state: 'success' },
{ runType: 'manual', state: 'failed' },
{ runType: 'manual', state: 'failed' },
const runs: DagRun[] = [
{ runType: 'scheduled', state: 'success', ...commonDagRunParams },
{ runType: 'manual', state: 'failed', ...commonDagRunParams },
{ runType: 'manual', state: 'failed', ...commonDagRunParams },
];
const result = areActiveRuns(runs);
expect(result).toBe(false);
});

test('Returns false when filtering runs runtype ["backfill"] and state ["failed"]', () => {
const runs = [
{ runType: 'scheduled', state: 'success' },
{ runType: 'manual', state: 'failed' },
{ runType: 'backfill', state: 'failed' },
test('Returns false when filtering runs runtype ["backfill"]', () => {
const runs: DagRun[] = [
{ runType: 'scheduled', state: 'success', ...commonDagRunParams },
{ runType: 'manual', state: 'failed', ...commonDagRunParams },
{ runType: 'backfill', state: 'failed', ...commonDagRunParams },
];
const result = areActiveRuns(runs);
expect(result).toBe(false);
});

test('Returns false when filtering runs runtype ["backfill"] and state ["queued"]', () => {
const runs = [
{ runType: 'scheduled', state: 'success' },
{ runType: 'manual', state: 'failed' },
{ runType: 'backfill', state: 'queued' },
const runs: DagRun[] = [
{ runType: 'scheduled', state: 'success', ...commonDagRunParams },
{ runType: 'manual', state: 'failed', ...commonDagRunParams },
{ runType: 'backfill', state: 'queued', ...commonDagRunParams },
];
const result = areActiveRuns(runs);
expect(result).toBe(false);
Expand Down Expand Up @@ -87,7 +98,7 @@ describe('Test areActiveRuns()', () => {
},
].forEach(({ state, runType, expectedResult }) => {
test(`Returns ${expectedResult} when filtering runs with runtype ["${runType}"] and state ["${state}"]`, () => {
const runs = [{ runType, state }];
const runs: DagRun[] = [{ runType, state, ...commonDagRunParams } as DagRun];
const result = areActiveRuns(runs);
expect(result).toBe(expectedResult);
});
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/static/js/api/useMarkFailedTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function useMarkFailedTask({
dag_id: dagId,
dag_run_id: runId,
task_id: taskId,
confirmed: 'true',
confirmed: true,
past,
future,
upstream,
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/static/js/api/useMarkSuccessTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function useMarkSuccessTask({
dag_id: dagId,
dag_run_id: runId,
task_id: taskId,
confirmed: 'true',
confirmed: true,
past,
future,
upstream,
Expand Down

0 comments on commit 0d00add

Please sign in to comment.