diff --git a/airflow/www/static/js/grid/api/useGridData.test.js b/airflow/www/static/js/grid/api/useGridData.test.js index f8c7d451c6c2b..d6e7a5b68a1f4 100644 --- a/airflow/www/static/js/grid/api/useGridData.test.js +++ b/airflow/www/static/js/grid/api/useGridData.test.js @@ -60,6 +60,24 @@ describe('Test areActiveRuns()', () => { expect(result).toBe(false); }); + [ + { runType: 'manual', state: 'queued', result: true }, + { runType: 'manual', state: 'running', result: true }, + { runType: 'scheduled', state: 'queued', result: true }, + { runType: 'scheduled', state: 'running', result: true }, + { runType: 'backfill', state: 'queued', result: false }, + { runType: 'backfill', state: 'running', result: false }, + ].forEach((conf) => { + test(`Returns ${conf.result} when filtering runs with runtype ["${conf.runType}"] and state ["${conf.state}"]`, () => { + const runConf = { ...conf }; + delete runConf.result; + const runs = [runConf]; + + const result = areActiveRuns(runs); + expect(result).toBe(conf.result); + }); + }); + test('Returns false when there are no runs', () => { const result = areActiveRuns(); expect(result).toBe(false); diff --git a/airflow/www/static/js/grid/api/useGridData.ts b/airflow/www/static/js/grid/api/useGridData.ts index 3af43df9b10d0..493418cda096f 100644 --- a/airflow/www/static/js/grid/api/useGridData.ts +++ b/airflow/www/static/js/grid/api/useGridData.ts @@ -49,7 +49,7 @@ const emptyGridData: GridData = { }, }; -export const areActiveRuns = (runs: DagRun[] = []) => runs.filter((run) => ['manual', 'manual'].includes(run.runType)).filter((run) => ['queued', 'running', 'scheduled'].includes(run.state)).length > 0; +export const areActiveRuns = (runs: DagRun[] = []) => runs.filter((run) => ['manual', 'scheduled'].includes(run.runType)).filter((run) => ['queued', 'running', 'scheduled'].includes(run.state)).length > 0; const useGridData = () => { const { isRefreshOn, stopRefresh } = useAutoRefresh();