-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui] Stop using the job page as the home page when single job is defi…
…ned (#26120) ## Summary & Motivation https://linear.app/dagster-labs/issue/FE-683/change-fallthrough-redirect-not-to-land-on-single-job This case is somewhat rare -- if a user has exactly one job, we had special cased it and opening the Dagster UI would land you directly on the job page. We think that this case is odd and it'd be better to direct to the Overview. ## How I Tested These Changes I added test coverage for all variants of the landing page behavior. 🫡 ## Changelog [ui] Opening Dagster's UI with a single job defined takes you to the Overview page rather than the Job page Co-authored-by: bengotow <[email protected]>
- Loading branch information
Showing
3 changed files
with
128 additions
and
25 deletions.
There are no files selected for viewing
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
107 changes: 107 additions & 0 deletions
107
js_modules/dagster-ui/packages/ui-core/src/app/__tests__/BaseFallthroughRoot.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,107 @@ | ||
import {MockedProvider} from '@apollo/client/testing'; | ||
import {render, waitFor} from '@testing-library/react'; | ||
import {MemoryRouter, Route, Switch} from 'react-router'; | ||
|
||
import {__ANONYMOUS_ASSET_JOB_PREFIX} from '../../asset-graph/Utils'; | ||
import { | ||
buildAssetGroup, | ||
buildPipeline, | ||
buildRepository, | ||
buildRepositoryLocation, | ||
buildWorkspaceLocationEntry, | ||
} from '../../graphql/types'; | ||
import {testId} from '../../testing/testId'; | ||
import {WorkspaceProvider} from '../../workspace/WorkspaceContext/WorkspaceContext'; | ||
import {buildWorkspaceMocks} from '../../workspace/WorkspaceContext/__fixtures__/Workspace.fixtures'; | ||
import {BaseFallthroughRoot} from '../BaseFallthroughRoot'; | ||
import { | ||
workspaceWithDunderJob, | ||
workspaceWithJob, | ||
workspaceWithNoRepos, | ||
} from '../__fixtures__/useJobStateForNav.fixtures'; | ||
|
||
describe('BaseFallthroughRoot', () => { | ||
const Test = () => ( | ||
<MemoryRouter initialEntries={[{pathname: '/'}]}> | ||
<WorkspaceProvider> | ||
<Switch> | ||
<Route path="/overview" render={() => <div />} /> | ||
<Route path="/locations" render={() => <div />} /> | ||
<BaseFallthroughRoot /> | ||
</Switch> | ||
<Route render={(m) => <div data-testid={testId('path')}>{m.location.pathname}</div>} /> | ||
</WorkspaceProvider> | ||
</MemoryRouter> | ||
); | ||
|
||
it('redirects to /locations if there are no repositories', async () => { | ||
const {getByTestId} = render( | ||
<MockedProvider mocks={[...workspaceWithNoRepos]}> | ||
<Test /> | ||
</MockedProvider>, | ||
); | ||
await waitFor(() => { | ||
expect(getByTestId('path').textContent).toEqual('/locations'); | ||
}); | ||
}); | ||
|
||
it('redirects to the asset graph if assetGroups are present and repos have no visible jobs', async () => { | ||
const {getByTestId} = render( | ||
<MockedProvider | ||
mocks={buildWorkspaceMocks([ | ||
buildWorkspaceLocationEntry({ | ||
name: 'some_workspace', | ||
locationOrLoadError: buildRepositoryLocation({ | ||
name: 'location_with_dunder_job', | ||
repositories: [ | ||
buildRepository({ | ||
name: `repo_with_pseudo_job`, | ||
assetGroups: [ | ||
buildAssetGroup({ | ||
groupName: 'group1', | ||
}), | ||
], | ||
pipelines: [ | ||
buildPipeline({ | ||
name: `${__ANONYMOUS_ASSET_JOB_PREFIX}_pseudo_job`, | ||
isJob: true, | ||
}), | ||
], | ||
}), | ||
], | ||
}), | ||
}), | ||
])} | ||
> | ||
<Test /> | ||
</MockedProvider>, | ||
); | ||
await waitFor(() => { | ||
expect(getByTestId('path').textContent).toEqual( | ||
'/locations/repo_with_pseudo_job@location_with_dunder_job/asset-groups/group1', | ||
); | ||
}); | ||
}); | ||
|
||
it('redirects to /overview if repos have visible jobs', async () => { | ||
const {getByTestId} = render( | ||
<MockedProvider mocks={[...workspaceWithJob]}> | ||
<Test /> | ||
</MockedProvider>, | ||
); | ||
await waitFor(() => { | ||
expect(getByTestId('path').textContent).toEqual('/overview'); | ||
}); | ||
}); | ||
|
||
it('redirects to /locations if repos have no visible jobs and no asset groups', async () => { | ||
const {getByTestId} = render( | ||
<MockedProvider mocks={[...workspaceWithDunderJob]}> | ||
<Test /> | ||
</MockedProvider>, | ||
); | ||
await waitFor(() => { | ||
expect(getByTestId('path').textContent).toEqual('/locations'); | ||
}); | ||
}); | ||
}); |
d8c00f1
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.
Deploy preview for dagit-core-storybook ready!
✅ Preview
https://dagit-core-storybook-3k44l8rix-elementl.vercel.app
Built with commit d8c00f1.
This pull request is being automatically deployed with vercel-action