diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/EvaluateScheduleDialog.fixtures.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/EvaluateScheduleDialog.fixtures.tsx index a747734e79869..c476ceb35c020 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/EvaluateScheduleDialog.fixtures.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/EvaluateScheduleDialog.fixtures.tsx @@ -1,6 +1,7 @@ import {MockedResponse} from '@apollo/client/testing'; import { + RunStatus, buildDryRunInstigationTick, buildErrorChainLink, buildPipelineTag, @@ -9,6 +10,8 @@ import { buildSchedule, buildTickEvaluation, } from '../../graphql/types'; +import {LAUNCH_MULTIPLE_RUNS_MUTATION} from '../../runs/RunUtils'; +import {LaunchMultipleRunsMutation} from '../../runs/types/RunUtils.types'; import {GET_SCHEDULE_QUERY, SCHEDULE_DRY_RUN_MUTATION} from '../EvaluateScheduleDialog'; import {GetScheduleQuery, ScheduleDryRunMutation} from '../types/EvaluateScheduleDialog.types'; @@ -63,7 +66,7 @@ export const scheduleDryWithWithRunRequest = { value: 'okay', }), ], - runKey: null, + runKey: 'EvaluateScheduleDialog.test.tsx:1675705668.993122345', }), ], skipReason: null, @@ -164,3 +167,89 @@ export const ScheduleDryRunMutationSkipped: MockedResponse = { + request: { + query: LAUNCH_MULTIPLE_RUNS_MUTATION, + variables: { + executionParamsList: [ + { + runConfigData: 'ops:\n configurable_op:\n config:\n scheduled_date: 2023-01-29', + selector: { + jobName: 'saepe', + repositoryLocationName: 'testLocation', + repositoryName: 'testName', + assetSelection: [], + assetCheckSelection: [], + solidSelection: undefined, + }, + mode: 'default', + executionMetadata: { + tags: [ + { + key: 'dagster/schedule_name', + value: 'configurable_job_schedule', + }, + { + key: 'date', + value: '2023-01-29', + }, + { + key: 'github_test', + value: 'test', + }, + { + key: 'okay_t2', + value: 'okay', + }, + ], + }, + }, + ], + }, + }, + result: { + data: { + __typename: 'Mutation', + launchMultipleRuns: { + __typename: 'LaunchMultipleRunsResult', + launchMultipleRunsResult: [ + { + __typename: 'LaunchRunSuccess', + run: { + __typename: 'Run', + id: '504b3a77-d6c4-440c-a128-7f59c9d75d59', + pipeline: { + __typename: 'PipelineSnapshot', + name: 'saepe', + }, + tags: [ + buildPipelineTag({ + key: 'dagster/schedule_name', + value: 'configurable_job_schedule', + }), + buildPipelineTag({ + key: 'date', + value: '2023-01-29', + }), + buildPipelineTag({ + key: 'github_test', + value: 'test', + }), + buildPipelineTag({ + key: 'okay_t2', + value: 'okay', + }), + ], + status: RunStatus.QUEUED, + runConfigYaml: + 'ops:\n configurable_op:\n config:\n scheduled_date: 2023-01-29', + mode: 'default', + resolvedOpSelection: null, + }, + }, + ], + }, + }, + }, +}; diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/SensorDryRunDialog.fixtures.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/SensorDryRunDialog.fixtures.tsx index 4959a6cc6dee3..e5c9dac3baf3b 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/SensorDryRunDialog.fixtures.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/__fixtures__/SensorDryRunDialog.fixtures.tsx @@ -3,6 +3,7 @@ import {MockedResponse} from '@apollo/client/testing'; import { InstigationStatus, RunRequest, + RunStatus, buildDryRunInstigationTick, buildErrorChainLink, buildInstigationState, @@ -13,6 +14,8 @@ import { buildSensorData, buildTickEvaluation, } from '../../graphql/types'; +import {LAUNCH_MULTIPLE_RUNS_MUTATION} from '../../runs/RunUtils'; +import {LaunchMultipleRunsMutation} from '../../runs/types/RunUtils.types'; import {SET_CURSOR_MUTATION} from '../../sensors/EditCursorDialog'; import {SetSensorCursorMutation} from '../../sensors/types/EditCursorDialog.types'; import {EVALUATE_SENSOR_MUTATION} from '../SensorDryRunDialog'; @@ -177,3 +180,161 @@ export const PersistCursorValueMock: MockedResponse = { }, }, }; + +export const SensorLaunchAllMutation: MockedResponse = { + request: { + query: LAUNCH_MULTIPLE_RUNS_MUTATION, + variables: { + executionParamsList: [ + { + runConfigData: + 'solids:\n read_file:\n config:\n directory: /Users/marcosalazar/code/dagster/js_modules/dagster-ui/packages/ui-core/src/ticks/tests\n filename: DryRunRequestTable.test.tsx', + selector: { + jobName: 'saepe', + repositoryLocationName: 'testLocation', + repositoryName: 'testName', + assetSelection: [], + assetCheckSelection: [], + solidSelection: undefined, + }, + mode: 'default', + executionMetadata: { + tags: [ + { + key: 'dagster2', + value: 'test', + }, + { + key: 'marco2', + value: 'salazar2', + }, + ], + }, + }, + { + runConfigData: + 'solids:\n read_file:\n config:\n directory: /Users/marcosalazar/code/dagster/js_modules/dagster-ui/packages/ui-core/src/ticks/tests\n filename: DryRunRequestTable.test.tsx', + selector: { + jobName: 'saepe', + repositoryLocationName: 'testLocation', + repositoryName: 'testName', + assetSelection: [], + assetCheckSelection: [], + solidSelection: undefined, + }, + mode: 'default', + executionMetadata: { + tags: [ + { + key: 'dagster3', + value: 'test', + }, + { + key: 'marco3', + value: 'salazar3', + }, + ], + }, + }, + { + runConfigData: + 'solids:\n read_file:\n config:\n directory: /Users/marcosalazar/code/dagster/js_modules/dagster-ui/packages/ui-core/src/ticks/tests\n filename: DryRunRequestTable.test.tsx', + selector: { + jobName: 'saepe', + repositoryLocationName: 'testLocation', + repositoryName: 'testName', + assetSelection: [], + assetCheckSelection: [], + solidSelection: undefined, + }, + mode: 'default', + executionMetadata: { + tags: [ + { + key: 'dagster6', + value: 'test', + }, + { + key: 'marco6', + value: 'salazar6', + }, + ], + }, + }, + ], + }, + }, + result: { + data: { + __typename: 'Mutation', + launchMultipleRuns: { + __typename: 'LaunchMultipleRunsResult', + launchMultipleRunsResult: [ + { + __typename: 'LaunchRunSuccess', + run: { + __typename: 'Run', + id: '504b3a77-d6c4-440c-a128-7f59c9d75d59', + pipeline: { + __typename: 'PipelineSnapshot', + name: 'saepe', + }, + tags: [ + buildPipelineTag({key: 'dagster2', value: 'test'}), + buildPipelineTag({key: 'marco2', value: 'salazar2'}), + ], + status: RunStatus.QUEUED, + runConfigYaml: + 'solids:\n read_file:\n config:\n directory: /Users/marcosalazar/code/dagster/js_modules/dagster-ui/packages/ui-core/src/ticks/tests\n filename: DryRunRequestTable.test.tsx\n', + mode: 'default', + resolvedOpSelection: null, + }, + }, + { + __typename: 'LaunchRunSuccess', + run: { + __typename: 'Run', + id: '6745cd03-3d89-4fd2-a41f-6b9d9ffdc134', + pipeline: { + __typename: 'PipelineSnapshot', + name: 'saepe', + }, + tags: [ + buildPipelineTag({key: 'dagster3', value: 'test'}), + buildPipelineTag({key: 'marco3', value: 'salazar3'}), + ], + + status: RunStatus.QUEUED, + runConfigYaml: + 'solids:\n read_file:\n config:\n directory: /Users/marcosalazar/code/dagster/js_modules/dagster-ui/packages/ui-core/src/ticks/tests\n filename: DryRunRequestTable.test.tsx\n', + + mode: 'default', + resolvedOpSelection: null, + }, + }, + { + __typename: 'LaunchRunSuccess', + run: { + __typename: 'Run', + id: '7ed35f69-42cf-4518-84a4-c97d0551a56b', + pipeline: { + __typename: 'PipelineSnapshot', + name: 'simple_config_job', + }, + tags: [ + buildPipelineTag({key: 'dagster6', value: 'test'}), + buildPipelineTag({key: 'marco6', value: 'salazar6'}), + ], + status: RunStatus.QUEUED, + runConfigYaml: + 'solids:\n read_file:\n config:\n directory: /Users/marcosalazar/code/dagster/js_modules/dagster-ui/packages/ui-core/src/ticks/tests\n filename: DryRunRequestTable.test.tsx\n', + + mode: 'default', + resolvedOpSelection: null, + }, + }, + ], + }, + }, + }, +}; diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx index 944295f2f90e0..6c17208d0628d 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx @@ -1,6 +1,7 @@ import {MockedProvider, MockedResponse} from '@apollo/client/testing'; import {render, screen, waitFor} from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import {MemoryRouter, useHistory} from 'react-router-dom'; import {Resolvers} from '../../apollo-client'; import {EvaluateScheduleDialog} from '../EvaluateScheduleDialog'; @@ -9,6 +10,7 @@ import { ScheduleDryRunMutationError, ScheduleDryRunMutationRunRequests, ScheduleDryRunMutationSkipped, + ScheduleLaunchAllMutation, } from '../__fixtures__/EvaluateScheduleDialog.fixtures'; // This component is unit tested separately so mocking it out @@ -18,6 +20,12 @@ jest.mock('../DryRunRequestTable', () => { }; }); +// Mocking useHistory +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useHistory: jest.fn(), +})); + const onCloseMock = jest.fn(); function Test({mocks, resolvers}: {mocks?: MockedResponse[]; resolvers?: Resolvers}) { @@ -103,7 +111,25 @@ describe('EvaluateScheduleTest', () => { }); it('launches all runs', async () => { - render(); + const pushSpy = jest.fn(); + const createHrefSpy = jest.fn(); + + (useHistory as jest.Mock).mockReturnValue({ + push: pushSpy, + createHref: createHrefSpy, + }); + + render( + + + , + ); const selectButton = await screen.findByTestId('tick-selection'); await userEvent.click(selectButton); await waitFor(() => { @@ -121,5 +147,9 @@ describe('EvaluateScheduleTest', () => { await waitFor(() => { expect(screen.getByText(/Launching runs/i)).toBeVisible(); }); - }, 10000); + + await waitFor(() => { + expect(pushSpy).toHaveBeenCalled(); + }); + }); }); diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/SensorDryRunDialog.test.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/SensorDryRunDialog.test.tsx index 2051f5f6e3acb..c8307def66a00 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/SensorDryRunDialog.test.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/SensorDryRunDialog.test.tsx @@ -1,6 +1,7 @@ import {MockedProvider, MockedResponse} from '@apollo/client/testing'; import {render, screen, waitFor} from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import {MemoryRouter, useHistory} from 'react-router-dom'; import {Resolvers} from '../../apollo-client'; import {SensorDryRunDialog} from '../SensorDryRunDialog'; @@ -13,6 +14,12 @@ jest.mock('../DryRunRequestTable', () => { }; }); +// Mocking useHistory +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useHistory: jest.fn(), +})); + const onCloseMock = jest.fn(); function Test({mocks, resolvers}: {mocks?: MockedResponse[]; resolvers?: Resolvers}) { @@ -83,7 +90,25 @@ describe('SensorDryRunTest', () => { }); it('launches all runs', async () => { - render(); + const pushSpy = jest.fn(); + const createHrefSpy = jest.fn(); + + (useHistory as jest.Mock).mockReturnValue({ + push: pushSpy, + createHref: createHrefSpy, + }); + + render( + + + , + ); const cursorInput = await screen.findByTestId('cursor-input'); await userEvent.type(cursorInput, 'testing123'); await userEvent.click(screen.getByTestId('continue')); @@ -102,5 +127,9 @@ describe('SensorDryRunTest', () => { await waitFor(() => { expect(screen.getByText(/Launching runs/i)).toBeVisible(); }); - }, 10000); + + await waitFor(() => { + expect(pushSpy).toHaveBeenCalled(); + }); + }); });