mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
fix: hardcode default organization id in DashboardProvider (#13940)
This commit is contained in:
@@ -9,7 +9,6 @@ import type {
|
||||
Experiments,
|
||||
} from "api/typesGenerated";
|
||||
import { Loader } from "components/Loader/Loader";
|
||||
import { useAuthenticated } from "contexts/auth/RequireAuth";
|
||||
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata";
|
||||
|
||||
export interface DashboardValue {
|
||||
@@ -29,7 +28,6 @@ export const DashboardContext = createContext<DashboardValue | undefined>(
|
||||
|
||||
export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
|
||||
const { metadata } = useEmbeddedMetadata();
|
||||
const { user } = useAuthenticated();
|
||||
const entitlementsQuery = useQuery(entitlements(metadata.entitlements));
|
||||
const experimentsQuery = useQuery(experiments(metadata.experiments));
|
||||
const appearanceQuery = useQuery(appearance(metadata.appearance));
|
||||
@@ -44,7 +42,7 @@ export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
|
||||
return (
|
||||
<DashboardContext.Provider
|
||||
value={{
|
||||
organizationId: user.organization_ids[0] ?? "default",
|
||||
organizationId: "00000000-0000-0000-0000-000000000000",
|
||||
entitlements: entitlementsQuery.data,
|
||||
experiments: experimentsQuery.data,
|
||||
appearance: appearanceQuery.data,
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
MockTemplateVersionVariable2,
|
||||
MockTemplateVersionVariable3,
|
||||
MockTemplate,
|
||||
MockOrganization,
|
||||
} from "testHelpers/entities";
|
||||
import { renderWithAuth } from "testHelpers/renderHelpers";
|
||||
import CreateTemplatePage from "./CreateTemplatePage";
|
||||
@@ -96,17 +95,20 @@ test("Create template from starter template", async () => {
|
||||
expect(router.state.location.pathname).toEqual(
|
||||
`/templates/${MockTemplate.name}/files`,
|
||||
);
|
||||
expect(API.createTemplateVersion).toHaveBeenCalledWith(MockOrganization.id, {
|
||||
example_id: "aws-windows",
|
||||
provisioner: "terraform",
|
||||
storage_method: "file",
|
||||
tags: {},
|
||||
user_variable_values: [
|
||||
{ name: "first_variable", value: "First value" },
|
||||
{ name: "second_variable", value: "2" },
|
||||
{ name: "third_variable", value: "true" },
|
||||
],
|
||||
});
|
||||
expect(API.createTemplateVersion).toHaveBeenCalledWith(
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
{
|
||||
example_id: "aws-windows",
|
||||
provisioner: "terraform",
|
||||
storage_method: "file",
|
||||
tags: {},
|
||||
user_variable_values: [
|
||||
{ name: "first_variable", value: "First value" },
|
||||
{ name: "second_variable", value: "2" },
|
||||
{ name: "third_variable", value: "true" },
|
||||
],
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("Create template from duplicating a template", async () => {
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
MockTemplateVersionParameter2,
|
||||
MockTemplateVersionParameter3,
|
||||
MockTemplateVersionExternalAuthGithub,
|
||||
MockOrganization,
|
||||
MockTemplateVersionExternalAuthGithubAuthenticated,
|
||||
} from "testHelpers/entities";
|
||||
import {
|
||||
@@ -60,7 +59,7 @@ describe("CreateWorkspacePage", () => {
|
||||
|
||||
await waitFor(() =>
|
||||
expect(API.createWorkspace).toBeCalledWith(
|
||||
MockUser.organization_ids[0],
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
MockUser.id,
|
||||
expect.objectContaining({
|
||||
...MockWorkspaceRichParametersRequest,
|
||||
@@ -224,7 +223,7 @@ describe("CreateWorkspacePage", () => {
|
||||
|
||||
await waitFor(() =>
|
||||
expect(API.createWorkspace).toBeCalledWith(
|
||||
MockUser.organization_ids[0],
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
MockUser.id,
|
||||
expect.objectContaining({
|
||||
...MockWorkspaceRequest,
|
||||
@@ -264,7 +263,7 @@ describe("CreateWorkspacePage", () => {
|
||||
|
||||
await waitFor(() =>
|
||||
expect(API.createWorkspace).toBeCalledWith(
|
||||
MockUser.organization_ids[0],
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
MockUser.id,
|
||||
expect.objectContaining({
|
||||
...MockWorkspaceRequest,
|
||||
@@ -288,7 +287,7 @@ describe("CreateWorkspacePage", () => {
|
||||
|
||||
await waitFor(() => {
|
||||
expect(createWorkspaceSpy).toBeCalledWith(
|
||||
MockOrganization.id,
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
"me",
|
||||
expect.objectContaining({
|
||||
template_version_id: MockTemplate.active_version_id,
|
||||
@@ -348,7 +347,7 @@ describe("CreateWorkspacePage", () => {
|
||||
|
||||
await waitFor(() => {
|
||||
expect(createWorkspaceSpy).toBeCalledWith(
|
||||
MockOrganization.id,
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
"me",
|
||||
expect.objectContaining({
|
||||
template_version_id: MockTemplate.active_version_id,
|
||||
|
||||
Reference in New Issue
Block a user