Skip to content

fix: hardcode default organization id in DashboardProvider #13940

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 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions site/src/modules/dashboard/DashboardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
Expand All @@ -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,
Expand Down
26 changes: 14 additions & 12 deletions site/src/pages/CreateTemplatePage/CreateTemplatePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
MockTemplateVersionVariable2,
MockTemplateVersionVariable3,
MockTemplate,
MockOrganization,
} from "testHelpers/entities";
import { renderWithAuth } from "testHelpers/renderHelpers";
import CreateTemplatePage from "./CreateTemplatePage";
Expand Down Expand Up @@ -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 () => {
Expand Down
11 changes: 5 additions & 6 deletions site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
MockTemplateVersionParameter2,
MockTemplateVersionParameter3,
MockTemplateVersionExternalAuthGithub,
MockOrganization,
MockTemplateVersionExternalAuthGithubAuthenticated,
} from "testHelpers/entities";
import {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading