-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui] Refactor RunActionsMenu.test (#17243)
## Summary & Motivation Delete a TestProvider use case. ## How I Tested These Changes Lint, TS, jest.
- Loading branch information
Showing
3 changed files
with
153 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
js_modules/dagster-ui/packages/ui-core/src/runs/__fixtures__/RunActionsMenu.fixtures.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import {MockedResponse} from '@apollo/client/testing'; | ||
|
||
import { | ||
RunStatus, | ||
buildPipeline, | ||
buildRepository, | ||
buildRepositoryLocation, | ||
buildRepositoryOrigin, | ||
buildRun, | ||
buildWorkspace, | ||
buildWorkspaceLocationEntry, | ||
} from '../../graphql/types'; | ||
import {ROOT_WORKSPACE_QUERY} from '../../workspace/WorkspaceContext'; | ||
import {RootWorkspaceQuery} from '../../workspace/types/WorkspaceContext.types'; | ||
import {PIPELINE_ENVIRONMENT_QUERY} from '../RunActionsMenu'; | ||
import { | ||
PipelineEnvironmentQuery, | ||
PipelineEnvironmentQueryVariables, | ||
} from '../types/RunActionsMenu.types'; | ||
|
||
const LOCATION_NAME = 'my-origin'; | ||
const REPO_NAME = 'my-repo'; | ||
const JOB_NAME = 'job-bar'; | ||
const RUN_ID = 'run-foo-bar'; | ||
const SNAPSHOT_ID = 'snapshotID'; | ||
|
||
type RunConfigInput = { | ||
hasReExecutePermission: boolean; | ||
}; | ||
|
||
export const buildRunActionsMenuFragment = ({hasReExecutePermission}: RunConfigInput) => { | ||
return buildRun({ | ||
id: RUN_ID, | ||
status: RunStatus.SUCCESS, | ||
stepKeysToExecute: null, | ||
canTerminate: true, | ||
hasDeletePermission: true, | ||
hasReExecutePermission, | ||
hasTerminatePermission: true, | ||
mode: 'default', | ||
rootRunId: 'abcdef12', | ||
parentRunId: null, | ||
pipelineSnapshotId: SNAPSHOT_ID, | ||
pipelineName: JOB_NAME, | ||
repositoryOrigin: buildRepositoryOrigin({ | ||
id: 'repo', | ||
repositoryName: REPO_NAME, | ||
repositoryLocationName: LOCATION_NAME, | ||
}), | ||
solidSelection: null, | ||
assetSelection: null, | ||
assetCheckSelection: null, | ||
tags: [], | ||
startTime: 123, | ||
endTime: 456, | ||
updateTime: 789, | ||
}); | ||
}; | ||
|
||
export const buildMockRootWorkspaceQuery = (): MockedResponse<RootWorkspaceQuery> => { | ||
return { | ||
request: { | ||
query: ROOT_WORKSPACE_QUERY, | ||
}, | ||
result: { | ||
data: { | ||
__typename: 'Query', | ||
workspaceOrError: buildWorkspace({ | ||
id: 'workspace', | ||
locationEntries: [ | ||
buildWorkspaceLocationEntry({ | ||
id: LOCATION_NAME, | ||
locationOrLoadError: buildRepositoryLocation({ | ||
id: LOCATION_NAME, | ||
repositories: [ | ||
buildRepository({ | ||
id: REPO_NAME, | ||
name: REPO_NAME, | ||
pipelines: [ | ||
buildPipeline({ | ||
id: JOB_NAME, | ||
name: JOB_NAME, | ||
pipelineSnapshotId: SNAPSHOT_ID, | ||
}), | ||
], | ||
}), | ||
], | ||
}), | ||
}), | ||
], | ||
}), | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
export const buildPipelineEnvironmentQuery = ( | ||
runConfig: RunConfigInput, | ||
): MockedResponse<PipelineEnvironmentQuery, PipelineEnvironmentQueryVariables> => { | ||
return { | ||
request: { | ||
query: PIPELINE_ENVIRONMENT_QUERY, | ||
variables: { | ||
runId: RUN_ID, | ||
}, | ||
}, | ||
result: { | ||
data: { | ||
__typename: 'Query', | ||
pipelineRunOrError: buildRunActionsMenuFragment(runConfig), | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
caf571a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagit-core-storybook ready!
✅ Preview
https://dagit-core-storybook-oyh769nbf-elementl.vercel.app
Built with commit caf571a.
This pull request is being automatically deployed with vercel-action