Skip to content

Commit

Permalink
[dagit] Fix AssetView.test key warnings (#10226)
Browse files Browse the repository at this point in the history
### Summary & Motivation

Repair these warnings by adjusting some of the mocks.

### How I Tested These Changes

yarn jest AssetView
  • Loading branch information
hellendag committed Oct 27, 2022
1 parent f7c058a commit 4ef9d27
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
42 changes: 28 additions & 14 deletions js_modules/dagit/packages/core/src/assets/AssetView.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {render, screen, waitForElementToBeRemoved} from '@testing-library/react';
import {act, render, screen} from '@testing-library/react';
import faker from 'faker';
import * as React from 'react';
import {MemoryRouter} from 'react-router-dom';

Expand All @@ -11,8 +12,21 @@ jest.mock('../graph/asyncGraphLayout', () => ({}));

describe('AssetView', () => {
const defaultMocks = {
AssetNode: () => ({
partitionKeys: () => [...new Array(0)],
}),
Asset: () => ({
assetMaterializations: () => [...new Array(2)],
}),
MaterializationEvent: () => ({
timestamp: 100,
timestamp: () => `${Math.random() * 100}`,
}),
ObservationEvent: () => ({
timestamp: () => `${Math.random() * 100}`,
}),
MetadataEntry: () => ({
__typename: 'TextMetadataEntry',
label: () => faker.random.word().toLocaleLowerCase(),
}),
};

Expand All @@ -30,30 +44,30 @@ describe('AssetView', () => {

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);
await act(async () => {
render(<Test path="/foo?asOf=10" />);
});
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);
await act(async () => {
render(<Test path="/foo?asOf=200" />);
});
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);
await act(async () => {
render(<Test path="/foo?asOf=100" />);
});
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);
await act(async () => {
render(<Test path="/foo" />);
});
expect(screen.queryByText(MESSAGE)).toBeNull();
});
});
Expand Down
6 changes: 3 additions & 3 deletions js_modules/dagit/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13372,9 +13372,9 @@ __metadata:
linkType: hard

"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001109, caniuse-lite@npm:^1.0.30001214, caniuse-lite@npm:^1.0.30001219, caniuse-lite@npm:^1.0.30001286, caniuse-lite@npm:^1.0.30001297, caniuse-lite@npm:^1.0.30001299, caniuse-lite@npm:^1.0.30001332":
version: 1.0.30001336
resolution: "caniuse-lite@npm:1.0.30001336"
checksum: 05577b295f2c3780f4a2c814c4255b8b73353ff5a7238f5f97fe3b2bb61b78d77be7df52e9646b829bbde8f0efbfbad971324001086f9069ec144e4fc88ed5b8
version: 1.0.30001426
resolution: "caniuse-lite@npm:1.0.30001426"
checksum: e8b9c14ee33410d95b27da619f50648f373a7be712748970643f25d95fa80687b4755ba365f34a7a1cea00f9137193943aa6e742eedf0a4d7857f83809f49435
languageName: node
linkType: hard

Expand Down

0 comments on commit 4ef9d27

Please sign in to comment.