Skip to content

Commit 58ceb91

Browse files
mustard-mhroboquat
authored andcommitted
[server] fix ide option not exists bug
1 parent 978805e commit 58ceb91

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

components/server/src/workspace/workspace-starter.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,19 @@ describe("workspace-starter", function () {
249249
const result = chooseIDE("unknown-custom", customOptions, useLatest, hasPerm);
250250
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
251251
});
252+
253+
it("not exists ide with custom permission", function () {
254+
const useLatest = true;
255+
const hasPerm = true;
256+
const result = chooseIDE("not-exists", ideOptions, useLatest, hasPerm);
257+
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
258+
});
259+
260+
it("not exists ide with custom permission", function () {
261+
const useLatest = true;
262+
const hasPerm = false;
263+
const result = chooseIDE("not-exists", ideOptions, useLatest, hasPerm);
264+
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
265+
});
252266
});
253267
});

components/server/src/workspace/workspace-starter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export const chooseIDE = (
159159
const data: { desktopIdeImage?: string; ideImage: string } = {
160160
ideImage: defaultIdeImage,
161161
};
162-
const chooseOption = ideOptions.options[ideChoice];
162+
const chooseOption = ideOptions.options[ideChoice] ?? defaultIDEOption;
163163
const isDesktopIde = chooseOption.type === "desktop";
164164
if (isDesktopIde) {
165165
data.desktopIdeImage = useLatest ? chooseOption?.latestImage ?? chooseOption?.image : chooseOption?.image;

0 commit comments

Comments
 (0)