Skip to content

chore: refactor frontend to use workspace status directly #4361

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

Merged
merged 11 commits into from
Oct 5, 2022
Prev Previous commit
Next Next commit
Update mocks
  • Loading branch information
presleyp committed Oct 4, 2022
commit c38352d833af133cf043d0264cdc3c15ba38fd0f
16 changes: 10 additions & 6 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,14 @@ export const MockWorkspace: TypesGen.Workspace = {

export const MockStoppedWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: MockWorkspaceBuildStop,
latest_build: { ...MockWorkspaceBuildStop, status: "stopped" },
}
export const MockStoppingWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: {
...MockWorkspaceBuildStop,
job: MockRunningProvisionerJob,
status: "stopping",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we're pulling these values from the types that way they stay in sync

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, since the generated type is a union of strings, I don't know how to do that. Do you have a way? Or would I just have to create an enum to layer on top of the generated type?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm...we might have to dig in. At first glance, I'm not sure. I mean you do have the TypesGen.Workspace there so maybe we don't have to worry. We could look later!

},
}
export const MockStartingWorkspace: TypesGen.Workspace = {
Expand All @@ -289,40 +290,43 @@ export const MockStartingWorkspace: TypesGen.Workspace = {
...MockWorkspaceBuild,
job: MockRunningProvisionerJob,
transition: "start",
status: "starting",
},
}
export const MockCancelingWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: { ...MockWorkspaceBuild, job: MockCancelingProvisionerJob },
latest_build: { ...MockWorkspaceBuild, job: MockCancelingProvisionerJob, status: "canceling" },
}
export const MockCanceledWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: { ...MockWorkspaceBuild, job: MockCanceledProvisionerJob },
latest_build: { ...MockWorkspaceBuild, job: MockCanceledProvisionerJob, status: "canceled" },
}
export const MockFailedWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: {
...MockWorkspaceBuild,
job: MockFailedProvisionerJob,
status: "failed",
},
}
export const MockDeletingWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: { ...MockWorkspaceBuildDelete, job: MockRunningProvisionerJob },
latest_build: { ...MockWorkspaceBuildDelete, job: MockRunningProvisionerJob, status: "deleting" },
}
export const MockDeletedWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: MockWorkspaceBuildDelete,
latest_build: { ...MockWorkspaceBuildDelete, status: "deleted" },
}

export const MockOutdatedWorkspace: TypesGen.Workspace = { ...MockFailedWorkspace, outdated: true }

export const MockQueuedWorkspace: TypesGen.Workspace = {
export const MockPendingWorkspace: TypesGen.Workspace = {
...MockWorkspace,
latest_build: {
...MockWorkspaceBuild,
job: MockPendingProvisionerJob,
transition: "start",
status: "pending",
},
}

Expand Down