Skip to content

Commit

Permalink
update the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bengotow committed Aug 20, 2024
1 parent 8d08bb1 commit 6b35aa4
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import {RepoAddress} from '../workspace/types';

const MISSING_FAILED_STATUSES = [AssetPartitionStatus.MISSING, AssetPartitionStatus.FAILED];

interface Props {
export interface LaunchAssetChoosePartitionsDialogProps {
open: boolean;
setOpen: (open: boolean) => void;
repoAddress: RepoAddress;
Expand All @@ -94,7 +94,9 @@ interface Props {
refetch?: () => Promise<void>;
}

export const LaunchAssetChoosePartitionsDialog = (props: Props) => {
export const LaunchAssetChoosePartitionsDialog = (
props: LaunchAssetChoosePartitionsDialogProps,
) => {
const displayName =
props.assets.length > 1
? `${props.assets.length} assets`
Expand Down Expand Up @@ -130,7 +132,7 @@ const LaunchAssetChoosePartitionsDialogBody = ({
target,
upstreamAssetKeys,
refetch: _refetch,
}: Props) => {
}: LaunchAssetChoosePartitionsDialogProps) => {
const partitionedAssets = assets.filter((a) => !!a.partitionDefinition);

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ export const useMaterializationAction = (preferredJobName?: string) => {

const launchpad = () => {
if (state.type === 'launchpad') {
console.log(state.sessionPresets);
return (
<AssetLaunchpad
assetJobName={state.jobName}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {assetNodes} from './LaunchAssetLoaderQuery.fixtures';
import {LaunchAssetChoosePartitionsDialogProps} from '../LaunchAssetChoosePartitionsDialog';

export const ReleasesJobProps = {
export const ReleasesJobProps: Omit<LaunchAssetChoosePartitionsDialogProps, 'open' | 'setOpen'> = {
assets: assetNodes,
upstreamAssetKeys: [],
repoAddress: {
Expand All @@ -10,7 +11,6 @@ export const ReleasesJobProps = {
target: {
type: 'job' as const,
jobName: '__ASSET_JOB_0',
partitionSetName: '__ASSET_JOB_0_partition_set',
assetKeys: [{path: ['asset_key_1']}],
},
open: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import {
buildMaterializationEvent,
buildMode,
buildPartitionDefinition,
buildPartitionSet,
buildPartitionSets,
buildPartitionRunConfig,
buildPartitionTags,
buildPartitionTagsAndConfig,
buildPipeline,
buildRegularConfigType,
buildRepository,
buildRepositoryLocation,
Expand All @@ -32,8 +34,8 @@ import {
} from '../../graphql/types';
import {LAUNCH_PARTITION_BACKFILL_MUTATION} from '../../instance/backfill/BackfillUtils';
import {LaunchPartitionBackfillMutation} from '../../instance/backfill/types/BackfillUtils.types';
import {CONFIG_PARTITION_SELECTION_QUERY} from '../../launchpad/ConfigEditorConfigPicker';
import {ConfigPartitionSelectionQuery} from '../../launchpad/types/ConfigEditorConfigPicker.types';
import {CONFIG_PARTITION_FOR_ASSET_JOB_QUERY} from '../../launchpad/ConfigFetch';
import {ConfigPartitionForAssetJobQuery} from '../../launchpad/types/ConfigFetch.types';
import {LAUNCH_PIPELINE_EXECUTION_MUTATION} from '../../runs/RunUtils';
import {
LaunchPipelineExecutionMutation,
Expand Down Expand Up @@ -94,7 +96,7 @@ export const UNPARTITIONED_ASSET = buildAssetNode({
dependencyKeys: [],
dependedByKeys: [],
graphName: null,
jobNames: ['__ASSET_JOB_7', 'my_asset_job'],
jobNames: ['__ASSET_JOB', 'my_asset_job'],
opNames: ['unpartitioned_asset'],
opVersion: null,
description: null,
Expand All @@ -114,7 +116,7 @@ export const UNPARTITIONED_ASSET = buildAssetNode({
export const CHECKED_ASSET = buildAssetNode({
...UNPARTITIONED_ASSET,
id: 'test.py.repo.["checked_asset"]',
jobNames: ['__ASSET_JOB_7', 'checks_included_job', 'checks_excluded_job'],
jobNames: ['__ASSET_JOB', 'checks_included_job', 'checks_excluded_job'],
assetKey: buildAssetKey({path: ['checked_asset']}),
configField: BASE_CONFIG_TYPE_FIELD,
assetChecksOrError: buildAssetChecks({
Expand Down Expand Up @@ -165,14 +167,14 @@ export const UNPARTITIONED_ASSET_WITH_REQUIRED_CONFIG = buildAssetNode({
export const MULTI_ASSET_OUT_1 = buildAssetNode({
...UNPARTITIONED_ASSET,
id: 'test.py.repo.["multi_asset_out_1"]',
jobNames: ['__ASSET_JOB_7'],
jobNames: ['__ASSET_JOB'],
assetKey: buildAssetKey({path: ['multi_asset_out_1']}),
});

export const MULTI_ASSET_OUT_2 = buildAssetNode({
...UNPARTITIONED_ASSET,
id: 'test.py.repo.["multi_asset_out_2"]',
jobNames: ['__ASSET_JOB_7'],
jobNames: ['__ASSET_JOB'],
assetKey: buildAssetKey({path: ['multi_asset_out_2']}),
});

Expand All @@ -189,7 +191,7 @@ export const ASSET_DAILY = buildAssetNode({
dependencyKeys: [],
dependedByKeys: [{__typename: 'AssetKey', path: ['asset_weekly']}],
graphName: null,
jobNames: ['__ASSET_JOB_7', 'my_asset_job'],
jobNames: ['__ASSET_JOB', 'my_asset_job'],
opNames: ['asset_daily'],
opVersion: null,
description: null,
Expand Down Expand Up @@ -442,7 +444,6 @@ export const buildLaunchAssetLoaderGenericJobMock = (jobName: string) => {
result: {
data: {
__typename: 'Query',
partitionSetsOrError: buildPartitionSets({results: []}),
pipelineOrError: {
id: '8e2d3f9597c4a45bb52fe9ab5656419f4329d4fb',
modes: [
Expand All @@ -463,23 +464,14 @@ export const LaunchAssetLoaderResourceJob7Mock: MockedResponse<LaunchAssetLoader
request: {
query: LAUNCH_ASSET_LOADER_RESOURCE_QUERY,
variables: {
pipelineName: '__ASSET_JOB_7',
pipelineName: '__ASSET_JOB',
repositoryLocationName: 'test.py',
repositoryName: 'repo',
},
},
result: {
data: {
__typename: 'Query',
partitionSetsOrError: {
results: [
buildPartitionSet({
id: '5b10aae97b738c48a4262b1eca530f89b13e9afc',
name: '__ASSET_JOB_7_partition_set',
}),
],
__typename: 'PartitionSets',
},
pipelineOrError: {
id: '8e2d3f9597c4a45bb52fe9ab5656419f4329d4fb',
modes: [
Expand Down Expand Up @@ -575,15 +567,6 @@ export const LaunchAssetLoaderResourceJob8Mock: MockedResponse<LaunchAssetLoader
result: {
data: {
__typename: 'Query',
partitionSetsOrError: {
results: [
buildPartitionSet({
id: '129179973a9144278c2429d3ba680bf0f809a59b',
name: '__ASSET_JOB_8_partition_set',
}),
],
__typename: 'PartitionSets',
},
pipelineOrError: {
id: '8689a9dcd052f769b73d73dfe57e89065dac369d',
modes: [
Expand Down Expand Up @@ -680,15 +663,6 @@ export const LaunchAssetLoaderResourceMyAssetJobMock: MockedResponse<LaunchAsset
result: {
data: {
__typename: 'Query',
partitionSetsOrError: {
results: [
buildPartitionSet({
id: '129179973a9144278c2429d3ba680bf0f809a59b',
name: 'my_asset_job_partition_set',
}),
],
__typename: 'PartitionSets',
},
pipelineOrError: {
id: '8689a9dcd052f769b73d73dfe57e89065dac369d',
modes: [
Expand Down Expand Up @@ -738,35 +712,30 @@ export const LaunchAssetCheckUpstreamWeeklyRootMock: MockedResponse<LaunchAssetC

export function buildConfigPartitionSelectionLatestPartitionMock(
partitionName: string,
partitionSetName: string,
): MockedResponse<ConfigPartitionSelectionQuery> {
jobName: string,
): MockedResponse<ConfigPartitionForAssetJobQuery> {
return {
request: {
query: CONFIG_PARTITION_SELECTION_QUERY,
query: CONFIG_PARTITION_FOR_ASSET_JOB_QUERY,
variables: {
jobName,
partitionName,
partitionSetName,
repositorySelector: {
repositoryLocationName: 'test.py',
repositoryName: 'repo',
},
repositoryLocationName: 'test.py',
repositoryName: 'repo',
assetKeys: [{path: ['asset_daily']}],
},
},
result: {
data: {
__typename: 'Query',
partitionSetOrError: {
__typename: 'PartitionSet',
id: '5b10aae97b738c48a4262b1eca530f89b13e9afc',
partition: {
pipelineOrError: buildPipeline({
partition: buildPartitionTagsAndConfig({
name: '2023-03-14',
solidSelection: null,
runConfigOrError: {
runConfigOrError: buildPartitionRunConfig({
yaml: '{}\n',
__typename: 'PartitionRunConfig',
},
mode: 'default',
tagsOrError: {
}),
tagsOrError: buildPartitionTags({
results: [
{
key: 'dagster/partition',
Expand All @@ -775,15 +744,13 @@ export function buildConfigPartitionSelectionLatestPartitionMock(
},
{
key: 'dagster/partition_set',
value: partitionSetName,
value: `${jobName}_partition_set`,
__typename: 'PipelineTag',
},
],
__typename: 'PartitionTags',
},
__typename: 'Partition',
},
},
}),
}),
}),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ describe('launchAssetChoosePartitionsDialog', () => {
setOpen={(_open: boolean) => {}}
repoAddress={buildRepoAddress('test', 'test')}
target={{
jobName: '__ASSET_JOB_0',
partitionSetName: '__ASSET_JOB_0_partition_set',
jobName: '__ASSET_JOB',
assetKeys: [assetA.assetKey, assetB.assetKey],
type: 'job',
}}
assets={[assetA, assetB]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe('LaunchAssetExecutionButton', () => {
selector: {
repositoryLocationName: 'test.py',
repositoryName: 'repo',
pipelineName: '__ASSET_JOB_7',
pipelineName: '__ASSET_JOB',
assetSelection: [{path: ['unpartitioned_asset']}],
assetCheckSelection: [],
},
Expand Down Expand Up @@ -375,15 +375,15 @@ describe('LaunchAssetExecutionButton', () => {
executionMetadata: {
tags: [
{key: 'dagster/partition', value: '2023-02-22'},
{key: 'dagster/partition_set', value: '__ASSET_JOB_7_partition_set'},
{key: 'dagster/partition_set', value: '__ASSET_JOB_partition_set'},
],
},
mode: 'default',
runConfigData: '{}\n',
selector: {
assetSelection: [{path: ['asset_daily']}],
assetCheckSelection: [],
pipelineName: '__ASSET_JOB_7',
pipelineName: '__ASSET_JOB',
repositoryLocationName: 'test.py',
repositoryName: 'repo',
},
Expand Down Expand Up @@ -593,7 +593,7 @@ describe('LaunchAssetExecutionButton', () => {
selector: {
repositoryLocationName: 'test.py',
repositoryName: 'repo',
pipelineName: '__ASSET_JOB_7',
pipelineName: '__ASSET_JOB',
assetSelection: [
asAssetKeyInput(MULTI_ASSET_OUT_1.assetKey),
asAssetKeyInput(MULTI_ASSET_OUT_2.assetKey),
Expand Down Expand Up @@ -644,9 +644,9 @@ function renderButton({
LaunchAssetCheckUpstreamWeeklyRootMock,
...PartitionHealthAssetMocks,
buildLaunchAssetWarningsMock([]),
buildConfigPartitionSelectionLatestPartitionMock('2020-01-02', 'my_asset_job_partition_set'),
buildConfigPartitionSelectionLatestPartitionMock('2023-02-22', 'my_asset_job_partition_set'),
buildConfigPartitionSelectionLatestPartitionMock('2023-02-22', '__ASSET_JOB_7_partition_set'),
buildConfigPartitionSelectionLatestPartitionMock('2020-01-02', 'my_asset_job'),
buildConfigPartitionSelectionLatestPartitionMock('2023-02-22', 'my_asset_job'),
buildConfigPartitionSelectionLatestPartitionMock('2023-02-22', '__ASSET_JOB'),
buildLaunchAssetLoaderMock([MULTI_ASSET_OUT_1.assetKey], {
assetNodeAdditionalRequiredKeys: [MULTI_ASSET_OUT_2.assetKey],
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import styled from 'styled-components';
import {
ConfigEditorGeneratorPipelineFragment,
ConfigEditorPipelinePresetFragment,
ConfigPartitionResultFragment,
ConfigPartitionsAssetsQuery,
ConfigPartitionsAssetsQueryVariables,
ConfigPartitionsQuery,
Expand All @@ -44,7 +43,6 @@ import {RepoAddress} from '../workspace/types';
type Pipeline = ConfigEditorGeneratorPipelineFragment;
type Preset = ConfigEditorPipelinePresetFragment;
type PartitionSet = PartitionSetForConfigEditorFragment;
type Partition = ConfigPartitionResultFragment;
type ConfigGenerator = Preset | PartitionSet;

interface ConfigEditorConfigPickerProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,7 @@ const LaunchpadSession = (props: LaunchpadSessionProps) => {
if (
base &&
needsRefresh &&
('presetName' in base ||
('partitionsSetName' in base && base.partitionsSetName && base.partitionName) ||
('assetKeys' in base && base.assetKeys && base.partitionName))
('presetName' in base || ('partitionName' in base && base.partitionName))
) {
return base;
}
Expand Down

0 comments on commit 6b35aa4

Please sign in to comment.