Skip to content

Commit 2d64e3e

Browse files
Merge master into feature/auto-debug
2 parents 05dcea2 + 17a0a98 commit 2d64e3e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/core/src/sagemakerunifiedstudio/explorer/activation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
113113
if (connection) {
114114
try {
115115
await smusAuthProvider.reauthenticate(connection)
116+
const projectNode = smusRootNode.getProjectSelectNode()
117+
if (projectNode) {
118+
const project = projectNode.getProject()
119+
if (!project) {
120+
await vscode.commands.executeCommand('aws.smus.switchProject')
121+
}
122+
}
116123
treeDataProvider.refresh()
117124

118125
// IAM connections handle their own success messages

packages/core/src/test/sagemakerunifiedstudio/explorer/activation.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ describe('SMUS Explorer Activation', function () {
2727
let mockTreeView: sinon.SinonStubbedInstance<vscode.TreeView<any>>
2828
let mockTreeDataProvider: sinon.SinonStubbedInstance<ResourceTreeDataProvider>
2929
let mockSmusRootNode: sinon.SinonStubbedInstance<SageMakerUnifiedStudioRootNode>
30+
let mockProjectNode: any
3031
let createTreeViewStub: sinon.SinonStub
3132
let registerCommandStub: sinon.SinonStub
33+
let executeCommandSpy: sinon.SinonSpy
3234
let dataZoneDisposeStub: sinon.SinonStub
3335
let setupUserActivityMonitoringStub: sinon.SinonStub
3436

@@ -59,14 +61,20 @@ describe('SMUS Explorer Activation', function () {
5961
refresh: sinon.stub(),
6062
} as any
6163

64+
mockProjectNode = {
65+
getProject: sinon.stub().returns({ id: 'test-project', name: 'Test Project' }),
66+
refreshNode: sinon.stub().resolves(),
67+
}
68+
6269
mockSmusRootNode = {
6370
getChildren: sinon.stub().resolves([]),
64-
getProjectSelectNode: sinon.stub().returns({ refreshNode: sinon.stub().resolves() }),
71+
getProjectSelectNode: sinon.stub().returns(mockProjectNode),
6572
} as any
6673

6774
// Stub vscode APIs
6875
createTreeViewStub = sinon.stub(vscode.window, 'createTreeView').returns(mockTreeView as any)
6976
registerCommandStub = sinon.stub(vscode.commands, 'registerCommand').returns({ dispose: sinon.stub() } as any)
77+
executeCommandSpy = sinon.spy(vscode.commands, 'executeCommand')
7078

7179
// Stub SmusAuthenticationProvider
7280
sinon.stub(SmusAuthenticationProvider, 'fromContext').returns(mockSmusAuthProvider as any)
@@ -214,6 +222,9 @@ describe('SMUS Explorer Activation', function () {
214222
await reauthCommand.args[1](mockConnection)
215223

216224
assert.ok(mockSmusAuthProvider.reauthenticate.calledWith(mockConnection))
225+
assert.ok(mockSmusRootNode.getProjectSelectNode.called)
226+
assert.ok((mockProjectNode.getProject as sinon.SinonStub).called)
227+
assert.ok(executeCommandSpy.neverCalledWith('aws.smus.switchProject'))
217228
assert.ok(mockTreeDataProvider.refresh.called)
218229

219230
// Check that an information message was shown

0 commit comments

Comments
 (0)