Skip to content

Commit

Permalink
Fix ide not exists bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Apr 22, 2022
1 parent d3d65b3 commit 1bcf2a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions components/server/src/workspace/workspace-starter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,19 @@ describe("workspace-starter", function () {
const result = chooseIDE("unknown-custom", customOptions, useLatest, hasPerm);
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
});

it("not exists ide with custom permission", function () {
const useLatest = true;
const hasPerm = true;
const result = chooseIDE("not-exists", ideOptions, useLatest, hasPerm);
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
});

it("not exists ide with custom permission", function () {
const useLatest = true;
const hasPerm = false;
const result = chooseIDE("not-exists", ideOptions, useLatest, hasPerm);
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
});
});
});
2 changes: 1 addition & 1 deletion components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const chooseIDE = (
const data: { desktopIdeImage?: string; ideImage: string } = {
ideImage: defaultIdeImage,
};
const chooseOption = ideOptions.options[ideChoice];
const chooseOption = ideOptions.options[ideChoice] ?? defaultIDEOption;
const isDesktopIde = chooseOption.type === "desktop";
if (isDesktopIde) {
data.desktopIdeImage = useLatest ? chooseOption?.latestImage ?? chooseOption?.image : chooseOption?.image;
Expand Down

0 comments on commit 1bcf2a0

Please sign in to comment.