Skip to content

Commit

Permalink
Move tests, fixtures, and storybooks into folders (#12614)
Browse files Browse the repository at this point in the history
### Summary & Motivation

As titled. I didn't add any of these files just moving.
  • Loading branch information
salazarm committed Mar 1, 2023
1 parent f532d6e commit e403d39
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 82 deletions.
@@ -1,15 +1,14 @@
import {MockedResponse} from '@apollo/client/testing';

import {RunStatus} from '../graphql/types';

import {ASSET_MATERIALIZATION_UPSTREAM_QUERY} from './AssetMaterializationUpstreamData';
import {ASSET_PARTITION_DETAIL_QUERY} from './AssetPartitionDetail';
import {AssetMaterializationUpstreamQuery} from './types/AssetMaterializationUpstreamData.types';
import {AssetPartitionDetailQuery} from './types/AssetPartitionDetail.types';
import {RunStatus} from '../../graphql/types';
import {ASSET_MATERIALIZATION_UPSTREAM_QUERY} from '../AssetMaterializationUpstreamData';
import {ASSET_PARTITION_DETAIL_QUERY} from '../AssetPartitionDetail';
import {AssetMaterializationUpstreamQuery} from '../types/AssetMaterializationUpstreamData.types';
import {AssetPartitionDetailQuery} from '../types/AssetPartitionDetail.types';
import {
AssetMaterializationFragment,
AssetObservationFragment,
} from './types/useRecentAssetEvents.types';
} from '../types/useRecentAssetEvents.types';

export const Partition = '2022-02-02';
export const MaterializationTimestamp = 1673996425523;
Expand Down
@@ -1,14 +1,13 @@
import {MockedResponse} from '@apollo/client/testing';

import {RunStatus} from '../graphql/types';
import {SINGLE_ASSET_QUERY} from '../workspace/VirtualizedAssetRow';
import {SingleAssetQuery} from '../workspace/types/VirtualizedAssetRow.types';

import {ASSET_CATALOG_GROUP_TABLE_QUERY, ASSET_CATALOG_TABLE_QUERY} from './AssetsCatalogTable';
import {RunStatus} from '../../graphql/types';
import {SINGLE_ASSET_QUERY} from '../../workspace/VirtualizedAssetRow';
import {SingleAssetQuery} from '../../workspace/types/VirtualizedAssetRow.types';
import {ASSET_CATALOG_GROUP_TABLE_QUERY, ASSET_CATALOG_TABLE_QUERY} from '../AssetsCatalogTable';
import {
AssetCatalogGroupTableQuery,
AssetCatalogTableQuery,
} from './types/AssetsCatalogTable.types';
} from '../types/AssetsCatalogTable.types';

export const AssetCatalogGroupTableMock: MockedResponse<AssetCatalogGroupTableQuery> = {
request: {
Expand Down
@@ -1,15 +1,15 @@
import {MockedResponse} from '@apollo/client/testing';

import {AssetNodeForGraphQueryFragment} from '../asset-graph/types/useAssetGraphData.types';
import {PartitionDefinitionType} from '../graphql/types';
import {AssetNodeForGraphQueryFragment} from '../../asset-graph/types/useAssetGraphData.types';
import {PartitionDefinitionType} from '../../graphql/types';
import {LAUNCH_ASSET_CHOOSE_PARTITIONS_QUERY} from '../LaunchAssetChoosePartitionsDialog';
import {LAUNCH_ASSET_LOADER_QUERY} from '../LaunchAssetExecutionButton';
import {LaunchAssetChoosePartitionsQuery} from '../types/LaunchAssetChoosePartitionsDialog.types';
import {LaunchAssetLoaderQuery} from '../types/LaunchAssetExecutionButton.types';
import {PartitionHealthQuery} from '../types/usePartitionHealthData.types';
import {PARTITION_HEALTH_QUERY} from '../usePartitionHealthData';

import {LAUNCH_ASSET_CHOOSE_PARTITIONS_QUERY} from './LaunchAssetChoosePartitionsDialog';
import {LAUNCH_ASSET_LOADER_QUERY} from './LaunchAssetExecutionButton';
import {generateDailyTimePartitions} from './PartitionHealthSummary.mocks';
import {LaunchAssetChoosePartitionsQuery} from './types/LaunchAssetChoosePartitionsDialog.types';
import {LaunchAssetLoaderQuery} from './types/LaunchAssetExecutionButton.types';
import {PartitionHealthQuery} from './types/usePartitionHealthData.types';
import {PARTITION_HEALTH_QUERY} from './usePartitionHealthData';

export const ASSET_DAILY_PARTITION_KEYS = generateDailyTimePartitions(
new Date('2020-01-01'),
Expand Down
@@ -1,7 +1,7 @@
import {MockedResponse} from '@apollo/client/testing';

import {PartitionHealthQuery} from './types/usePartitionHealthData.types';
import {PARTITION_HEALTH_QUERY} from './usePartitionHealthData';
import {PartitionHealthQuery} from '../types/usePartitionHealthData.types';
import {PARTITION_HEALTH_QUERY} from '../usePartitionHealthData';

// Generates hourly partitions in the format 2022-08-31-00:00
function generateHourlyTimePartitions(startDate: Date, endDate: Date) {
Expand Down
Expand Up @@ -2,18 +2,17 @@ import {MockedProvider} from '@apollo/client/testing';
import {Box} from '@dagster-io/ui';
import React from 'react';

import {createAppCache} from '../app/AppCache';
import {StorybookProvider} from '../testing/StorybookProvider';
import {WorkspaceProvider} from '../workspace/WorkspaceContext';

import {AssetEventDetail, AssetEventDetailEmpty} from './AssetEventDetail';
import {createAppCache} from '../../app/AppCache';
import {StorybookProvider} from '../../testing/StorybookProvider';
import {WorkspaceProvider} from '../../workspace/WorkspaceContext';
import {AssetEventDetail, AssetEventDetailEmpty} from '../AssetEventDetail';
import {
BasicObservationEvent,
MaterializationEventFull,
MaterializationEventMinimal,
MaterializationUpstreamDataEmptyMock,
MaterializationUpstreamDataFullMock,
} from './AssetEventDetail.mocks';
} from '../__fixtures__/AssetEventDetail.mocks';

// eslint-disable-next-line import/no-default-export
export default {component: AssetEventDetail};
Expand Down
@@ -1,8 +1,8 @@
import {Meta} from '@storybook/react/types-6-0';
import * as React from 'react';

import {AssetLineageElements} from './AssetLineageElements';
import {AssetLineageFragment} from './types/AssetLineageElements.types';
import {AssetLineageElements} from '../AssetLineageElements';
import {AssetLineageFragment} from '../types/AssetLineageElements.types';

// eslint-disable-next-line import/no-default-export
export default {
Expand Down
Expand Up @@ -2,18 +2,17 @@ import {MockedProvider} from '@apollo/client/testing';
import {Box} from '@dagster-io/ui';
import React from 'react';

import {createAppCache} from '../app/AppCache';
import {WorkspaceProvider} from '../workspace/WorkspaceContext';

import {
AssetPartitionDetailMock,
MaterializationUpstreamDataFullMock,
} from './AssetEventDetail.mocks';
import {createAppCache} from '../../app/AppCache';
import {WorkspaceProvider} from '../../workspace/WorkspaceContext';
import {
AssetPartitionDetail,
AssetPartitionDetailEmpty,
AssetPartitionDetailLoader,
} from './AssetPartitionDetail';
} from '../AssetPartitionDetail';
import {
AssetPartitionDetailMock,
MaterializationUpstreamDataFullMock,
} from '../__fixtures__/AssetEventDetail.mocks';

// eslint-disable-next-line import/no-default-export
export default {component: AssetPartitionDetail};
Expand Down
@@ -1,17 +1,16 @@
import {MockedProvider} from '@apollo/client/testing';
import React from 'react';

import {StorybookProvider} from '../testing/StorybookProvider';

import {AssetPartitions} from './AssetPartitions';
import {AssetViewParams} from './AssetView';
import {StorybookProvider} from '../../testing/StorybookProvider';
import {AssetPartitions} from '../AssetPartitions';
import {AssetViewParams} from '../AssetView';
import {
MultiDimensionStaticPartitionHealthQuery,
MultiDimensionTimeFirstPartitionHealthQuery,
MultiDimensionTimeSecondPartitionHealthQuery,
SingleDimensionStaticPartitionHealthQuery,
SingleDimensionTimePartitionHealthQuery,
} from './PartitionHealthSummary.mocks';
} from '../__fixtures__/PartitionHealthSummary.mocks';

// eslint-disable-next-line import/no-default-export
export default {component: AssetPartitions};
Expand Down
@@ -1,17 +1,16 @@
import {MockedProvider} from '@apollo/client/testing';
import React from 'react';

import {StorybookProvider} from '../testing/StorybookProvider';

import {AssetsCatalogTable} from './AssetsCatalogTable';
import {StorybookProvider} from '../../testing/StorybookProvider';
import {AssetsCatalogTable} from '../AssetsCatalogTable';
import {
AssetCatalogGroupTableMock,
AssetCatalogTableMock,
SingleAssetQueryLastRunFailed,
SingleAssetQueryMaterializedStaleAndLate,
SingleAssetQueryMaterializedWithLatestRun,
SingleAssetQueryTrafficDashboard,
} from './AssetsCatalogTable.mocks';
} from '../__fixtures__/AssetsCatalogTable.mocks';

// eslint-disable-next-line import/no-default-export
export default {component: AssetsCatalogTable};
Expand Down
Expand Up @@ -2,16 +2,16 @@ import {MockedProvider} from '@apollo/client/testing';
import {Box} from '@dagster-io/ui';
import React from 'react';

import {PartitionHealthSummary} from './PartitionHealthSummary';
import {PartitionHealthSummary} from '../PartitionHealthSummary';
import {
MultiDimensionStaticPartitionHealthQuery,
MultiDimensionTimeFirstPartitionHealthQuery,
MultiDimensionTimeSecondPartitionHealthQuery,
SingleDimensionStaticPartitionHealthQuery,
SingleDimensionTimePartitionHealthQuery,
} from './PartitionHealthSummary.mocks';
import {AssetKey} from './types';
import {PartitionDimensionSelection, usePartitionHealthData} from './usePartitionHealthData';
} from '../__fixtures__/PartitionHealthSummary.mocks';
import {AssetKey} from '../types';
import {PartitionDimensionSelection, usePartitionHealthData} from '../usePartitionHealthData';

// eslint-disable-next-line import/no-default-export
export default {
Expand Down
Expand Up @@ -4,20 +4,19 @@ import userEvent, {specialChars} from '@testing-library/user-event';
import React from 'react';
import {MemoryRouter, Route} from 'react-router-dom';

import {AssetKeyInput} from '../graphql/types';

import {AssetPartitionListProps} from './AssetPartitionList';
import {AssetPartitions} from './AssetPartitions';
import {AssetViewParams} from './AssetView';
import {AssetKeyInput} from '../../graphql/types';
import {AssetPartitionListProps} from '../AssetPartitionList';
import {AssetPartitions} from '../AssetPartitions';
import {AssetViewParams} from '../AssetView';
import {
SingleDimensionStaticPartitionHealthQuery,
SingleDimensionTimePartitionHealthQuery,
} from './PartitionHealthSummary.mocks';
} from '../__fixtures__/PartitionHealthSummary.mocks';

// This file must be mocked because useVirtualizer tries to create a ResizeObserver,
// and the component tree fails to mount. We still want to test whether certain partitions
// are shown, so we print the keys in a simple "list".
jest.mock('./AssetPartitionList', () => ({
jest.mock('../AssetPartitionList', () => ({
AssetPartitionList: (props: AssetPartitionListProps) => (
<div>
<div data-testid="focused-partition">{props.focusedDimensionKey}</div>
Expand Down
Expand Up @@ -3,16 +3,15 @@ import faker from 'faker';
import * as React from 'react';
import {MemoryRouter} from 'react-router-dom';

import {TestProvider} from '../testing/TestProvider';

import {AssetView} from './AssetView';
import {TestProvider} from '../../testing/TestProvider';
import {AssetView} from '../AssetView';

// This file must be mocked because Jest can't handle `import.meta.url`.
jest.mock('../graph/asyncGraphLayout', () => ({}));
jest.mock('../../graph/asyncGraphLayout', () => ({}));

// This file must be mocked because useVirtualizer tries to create a ResizeObserver,
// and the component tree fails to mount.
jest.mock('./AssetPartitions', () => ({AssetPartitions: () => <div />}));
jest.mock('../AssetPartitions', () => ({AssetPartitions: () => <div />}));

describe('AssetView', () => {
const mocks = {
Expand Down
Expand Up @@ -2,15 +2,14 @@ import {MockedProvider, MockedResponse} from '@apollo/client/testing';
import {act, render, screen, waitFor} from '@testing-library/react';
import React from 'react';

import {CustomAlertProvider} from '../app/CustomAlertProvider';
import {LAUNCH_PARTITION_BACKFILL_MUTATION} from '../instance/BackfillUtils';
import {LaunchPartitionBackfillMutation} from '../instance/types/BackfillUtils.types';
import {TestProvider} from '../testing/TestProvider';

import {CustomAlertProvider} from '../../app/CustomAlertProvider';
import {LAUNCH_PARTITION_BACKFILL_MUTATION} from '../../instance/BackfillUtils';
import {LaunchPartitionBackfillMutation} from '../../instance/types/BackfillUtils.types';
import {TestProvider} from '../../testing/TestProvider';
import {
ERROR_INVALID_ASSET_SELECTION,
LaunchAssetExecutionButton,
} from './LaunchAssetExecutionButton';
} from '../LaunchAssetExecutionButton';
import {
ASSET_DAILY,
ASSET_DAILY_PARTITION_KEYS,
Expand All @@ -22,10 +21,10 @@ import {
PartitionHealthAssetDailyMock,
PartitionHealthAssetWeeklyMock,
PartitionHealthAssetWeeklyRootMock,
} from './LaunchAssetExecutionButton.mocks';
} from '../__fixtures__/LaunchAssetExecutionButton.mocks';

// This file must be mocked because Jest can't handle `import.meta.url`.
jest.mock('../graph/asyncGraphLayout', () => ({}));
jest.mock('../../graph/asyncGraphLayout', () => ({}));

describe('LaunchAssetExecutionButton', () => {
it('should show the partition dialog with an anchor asset', async () => {
Expand Down
@@ -1,7 +1,6 @@
import {PartitionState} from '../partitions/PartitionStatus';

import {mergedRanges, mergedStates} from './MultipartitioningSupport';
import {Range} from './usePartitionHealthData';
import {PartitionState} from '../../partitions/PartitionStatus';
import {mergedRanges, mergedStates} from '../MultipartitioningSupport';
import {Range} from '../usePartitionHealthData';

describe('multipartitioning support', () => {
describe('mergedStates', () => {
Expand Down
@@ -1,6 +1,5 @@
import {PartitionState} from '../partitions/PartitionStatus';

import {PartitionHealthQuery} from './types/usePartitionHealthData.types';
import {PartitionState} from '../../partitions/PartitionStatus';
import {PartitionHealthQuery} from '../types/usePartitionHealthData.types';
import {
Range,
buildPartitionHealthData,
Expand All @@ -14,7 +13,7 @@ import {
PartitionDimensionSelection,
keyCountInRanges,
keyCountInSelection,
} from './usePartitionHealthData';
} from '../usePartitionHealthData';

const {SUCCESS, MISSING} = PartitionState;

Expand Down
@@ -1,7 +1,7 @@
import {render, waitFor, screen} from '@testing-library/react';
import React from 'react';

import {usePartitionKeyInParams} from './usePartitionKeyInParams';
import {usePartitionKeyInParams} from '../usePartitionKeyInParams';

describe('usePartitionKeyInParams', () => {
it('should parse and set a one-dimensional partition key', async () => {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e403d39

Please sign in to comment.