Skip to content

Commit

Permalink
Fix workspace loader which should pass its query strings to the under…
Browse files Browse the repository at this point in the history
…lying alternate IDE

Signed-off-by: Sun Tan <sutan@redhat.com>
  • Loading branch information
sunix committed Apr 12, 2018
1 parent 6f3842b commit fe6bc26
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions workspace-loader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ export class WorkspaceLoader {
for (let serverId in servers) {
let attributes = servers[serverId].attributes;
if (attributes['type'] === 'ide') {
this.openURL(servers[serverId].url);
this.openURL(servers[serverId].url + this.getQueryString());
return;
}
}
}

this.openURL(workspace.links.ide);
this.openURL(workspace.links.ide + this.getQueryString());
});
}

Expand Down
30 changes: 30 additions & 0 deletions workspace-loader/test/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,36 @@ describe('Workspace Loader', () => {
});
});

describe('must open preconfigured IDE with query parameters', () => {
let ideURL = "ide URL"
let workspaceLoader;

beforeEach((done) => {
let loader = new Loader();
workspaceLoader = new WorkspaceLoader(loader);

spyOn(workspaceLoader, 'getWorkspaceKey').and.returnValue("foo/bar");
spyOn(workspaceLoader, 'getQueryString').and.returnValue("?param=value");

spyOn(workspaceLoader, 'getWorkspace').and.callFake(() => {
return new Promise((resolve) => {
fakeWorkspaceConfig.status = 'RUNNING';
fakeWorkspaceConfig.runtime = {machines: {ide: {servers: {server1: {attributes: {type: "ide"}, url: ideURL}}}}}
resolve(fakeWorkspaceConfig);
done();
});
});

spyOn(workspaceLoader, "openIDE").and.callThrough();
spyOn(workspaceLoader, "openURL");
workspaceLoader.load();
});

it('must be called', () => {
expect(workspaceLoader.openURL).toHaveBeenCalledWith(ideURL + "?param=value");
});
});

describe('must handle workspace when it has IDE server', () => {
let workspaceLoader;

Expand Down

0 comments on commit fe6bc26

Please sign in to comment.