-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dagit] AssetView: Don't show historical view message if it's not (#7639
) ## Summary Resolves #7636. We shouldn't show the "historical view" alert on the asset materialization list if the most recent materialization is at the top of the list. Added a "Loading…" title to the Spinner since it's good to have, and since it gives us something removable to target for testing. ## Test Plan Jest
- Loading branch information
Showing
3 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
js_modules/dagit/packages/core/src/assets/AssetView.test.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,57 @@ | ||
import {render, screen, waitForElementToBeRemoved} from '@testing-library/react'; | ||
import * as React from 'react'; | ||
import {MemoryRouter} from 'react-router-dom'; | ||
|
||
import {TestProvider} from '../testing/TestProvider'; | ||
|
||
import {AssetView} from './AssetView'; | ||
|
||
describe('AssetView', () => { | ||
const defaultMocks = { | ||
MaterializationEvent: () => ({ | ||
timestamp: 100, | ||
}), | ||
}; | ||
|
||
const Test = ({path}: {path: string}) => { | ||
return ( | ||
<TestProvider apolloProps={{mocks: defaultMocks}}> | ||
<MemoryRouter initialEntries={[path]}> | ||
<AssetView assetKey={{path: ['foo']}} /> | ||
</MemoryRouter> | ||
</TestProvider> | ||
); | ||
}; | ||
|
||
const MESSAGE = /this is a historical view of materializations as of \./i; | ||
|
||
describe('Historical view alert', () => { | ||
it('shows historical view alert if `asOf` is old', async () => { | ||
render(<Test path="/foo?asOf=10" />); | ||
const spinner = screen.queryByTitle(/loading…/i); | ||
await waitForElementToBeRemoved(spinner); | ||
expect(screen.queryByText(MESSAGE)).toBeVisible(); | ||
}); | ||
|
||
it('does not show historical view alert if `asOf` is past latest materialization', async () => { | ||
render(<Test path="/foo?asOf=200" />); | ||
const spinner = screen.queryByTitle(/loading…/i); | ||
await waitForElementToBeRemoved(spinner); | ||
expect(screen.queryByText(MESSAGE)).toBeNull(); | ||
}); | ||
|
||
it('does not show historical view alert if `asOf` is equal to latest materialization', async () => { | ||
render(<Test path="/foo?asOf=100" />); | ||
const spinner = screen.queryByTitle(/loading…/i); | ||
await waitForElementToBeRemoved(spinner); | ||
expect(screen.queryByText(MESSAGE)).toBeNull(); | ||
}); | ||
|
||
it('does not show historical view alert if no `asOf` is specified', async () => { | ||
render(<Test path="/foo" />); | ||
const spinner = screen.queryByTitle(/loading…/i); | ||
await waitForElementToBeRemoved(spinner); | ||
expect(screen.queryByText(MESSAGE)).toBeNull(); | ||
}); | ||
}); | ||
}); |
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
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
cc07c17
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.
Successfully deployed to the following URLs:
dagit-storybook – ./js_modules/dagit/packages/ui
dagit-storybook-elementl.vercel.app
dagit-storybook.vercel.app
dagit-storybook-git-master-elementl.vercel.app