-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(site): use server-side workspace restart orchestration #28034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ibetitsmike
wants to merge
12
commits into
main
Choose a base branch
from
mike/eng-3020-ui-restart-on-success
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+327
−31
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
58a777c
fix(site): use server-side workspace restart orchestration
ibetitsmike 808615d
chore(site): simplify restart orchestration helpers and tests
ibetitsmike e48ac69
fix(site): address restart orchestration review feedback
ibetitsmike a2d7cb2
fix(site): warn about template updates in schedule restart dialog
ibetitsmike f6addc4
fix(site): warn about template updates in schedule restart dialog
ibetitsmike e0fd39e
fix(site): explain manual recovery when restart start build never app…
ibetitsmike ce1bf50
fix(site): warn unconditionally that restart uses the active template…
ibetitsmike 25db173
fix(site): move restart confirm interaction coverage into Storybook
ibetitsmike bd72398
fix(site): derive story query fixtures from each story's workspace
ibetitsmike 568ac3d
fix(site): discover restart child build via workspace ID
ibetitsmike 4f6bb7c
fix(site): handle restart timeout rejection before advancing timers
ibetitsmike f332120
chore(site): drop redundant waitFor around synchronous dialog assertions
ibetitsmike File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
112 changes: 112 additions & 0 deletions
112
site/src/pages/WorkspacePage/WorkspaceReadyPage.stories.tsx
This file contains hidden or 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,112 @@ | ||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
| import { expect, spyOn, userEvent, waitFor, within } from "storybook/test"; | ||
| import { API } from "#/api/api"; | ||
| import { buildInfoKey } from "#/api/queries/buildInfo"; | ||
| import { templateVersion } from "#/api/queries/templates"; | ||
| import { agentListeningPorts } from "#/api/queries/workspaces"; | ||
| import type { Workspace } from "#/api/typesGenerated"; | ||
| import * as Mocks from "#/testHelpers/entities"; | ||
| import { | ||
| withAuthProvider, | ||
| withDashboardProvider, | ||
| withProxyProvider, | ||
| } from "#/testHelpers/storybook"; | ||
| import type { WorkspacePermissions } from "../../modules/workspaces/permissions"; | ||
| import { WorkspaceReadyPage } from "./WorkspaceReadyPage"; | ||
|
|
||
| const permissions: WorkspacePermissions = { | ||
| readWorkspace: true, | ||
| shareWorkspace: true, | ||
| updateWorkspace: true, | ||
| updateWorkspaceVersion: true, | ||
| deleteFailedWorkspace: true, | ||
| }; | ||
|
|
||
| const workspaceQueries = (workspace: Workspace) => [ | ||
| { key: buildInfoKey, data: Mocks.MockBuildInfo }, | ||
| { | ||
| key: agentListeningPorts(Mocks.MockWorkspaceAgent.id).queryKey, | ||
| data: Mocks.MockListeningPortsResponse, | ||
| }, | ||
| { | ||
| key: templateVersion(workspace.template_active_version_id).queryKey, | ||
| data: Mocks.MockTemplateVersion, | ||
| }, | ||
| ]; | ||
|
|
||
| const meta: Meta<typeof WorkspaceReadyPage> = { | ||
| title: "pages/WorkspacePage/WorkspaceReadyPage", | ||
| component: WorkspaceReadyPage, | ||
| args: { | ||
| workspace: Mocks.MockWorkspace, | ||
| template: Mocks.MockTemplate, | ||
| permissions, | ||
| }, | ||
| parameters: { | ||
| queries: workspaceQueries(Mocks.MockWorkspace), | ||
| user: Mocks.MockUserOwner, | ||
| }, | ||
| decorators: [withAuthProvider, withDashboardProvider, withProxyProvider()], | ||
| beforeEach: () => { | ||
| spyOn(API, "getDynamicParameters").mockResolvedValue([]); | ||
| spyOn(API, "workspaceBuildTimings").mockResolvedValue({ | ||
| provisioner_timings: [], | ||
| agent_script_timings: [], | ||
| agent_connection_timings: [], | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof WorkspaceReadyPage>; | ||
|
|
||
| const openRestartDialog = async (canvasElement: HTMLElement) => { | ||
| const body = within(canvasElement.ownerDocument.body); | ||
| const restartButton = await body.findByRole("button", { | ||
| name: /^restart…$/i, | ||
| }); | ||
| await userEvent.click(restartButton); | ||
| return await body.findByRole("dialog"); | ||
| }; | ||
|
|
||
| export const RestartDialog: Story = { | ||
| play: async ({ canvasElement }) => { | ||
| const dialog = await openRestartDialog(canvasElement); | ||
| expect(dialog).toHaveTextContent(/delete non-persistent data/); | ||
| expect(dialog).toHaveTextContent( | ||
| /The workspace will start using the template's active version/, | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const RestartDialogOutdatedWorkspace: Story = { | ||
| args: { | ||
| workspace: Mocks.MockRunningOutdatedWorkspace, | ||
| }, | ||
| parameters: { | ||
| queries: workspaceQueries(Mocks.MockRunningOutdatedWorkspace), | ||
| }, | ||
| play: async ({ canvasElement }) => { | ||
| const dialog = await openRestartDialog(canvasElement); | ||
| expect(dialog).toHaveTextContent( | ||
| /The workspace will start using the template's active version/, | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const ConfirmRestart: Story = { | ||
| beforeEach: () => { | ||
| spyOn(API, "restartWorkspace").mockResolvedValue(undefined); | ||
| }, | ||
| play: async ({ canvasElement }) => { | ||
| const dialog = await openRestartDialog(canvasElement); | ||
| await userEvent.click( | ||
| within(dialog).getByRole("button", { name: "Restart" }), | ||
| ); | ||
| await waitFor(() => | ||
| expect(API.restartWorkspace).toHaveBeenCalledWith( | ||
| expect.objectContaining({ workspace: Mocks.MockWorkspace }), | ||
| ), | ||
| ); | ||
| }, | ||
| }; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.