Skip to content

Commit

Permalink
[dagit] Fix AssetView flakiness (#10293)
Browse files Browse the repository at this point in the history
### Summary & Motivation

I'm pretty sure the `Math.random()` I added to AssetView is causing flakiness. If I just make sure that only one materialization and no observations are returned for the mocked Asset, that should repair the duplicate key warning and also cause the tests to handle the materialization timestamp accurately.

### How I Tested These Changes

yarn jest AssetView
  • Loading branch information
hellendag committed Nov 1, 2022
1 parent 621b57a commit 7dd241f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions js_modules/dagit/packages/core/src/assets/AssetView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ import {AssetView} from './AssetView';
jest.mock('../graph/asyncGraphLayout', () => ({}));

describe('AssetView', () => {
const defaultMocks = {
const mocks = {
AssetNode: () => ({
partitionKeys: () => [...new Array(0)],
}),
Asset: () => ({
assetMaterializations: () => [...new Array(2)],
assetMaterializations: () => [...new Array(1)],
assetObservations: () => [...new Array(0)],
}),
MaterializationEvent: () => ({
timestamp: () => `${Math.random() * 100}`,
}),
ObservationEvent: () => ({
timestamp: () => `${Math.random() * 100}`,
timestamp: () => '100',
}),
MetadataEntry: () => ({
__typename: 'TextMetadataEntry',
Expand All @@ -32,7 +30,7 @@ describe('AssetView', () => {

const Test = ({path}: {path: string}) => {
return (
<TestProvider apolloProps={{mocks: defaultMocks}}>
<TestProvider apolloProps={{mocks}}>
<MemoryRouter initialEntries={[path]}>
<AssetView assetKey={{path: ['foo']}} />
</MemoryRouter>
Expand Down

0 comments on commit 7dd241f

Please sign in to comment.