Skip to content

Commit 19ef62c

Browse files
author
Keegan Irby
committed
fix close tab race condition in tailLogGroup test
1 parent f5efbd3 commit 19ef62c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

packages/core/src/test/awsService/cloudWatchLogs/commands/tailLogGroup.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,11 @@ describe('TailLogGroup', function () {
7373

7474
//Test that closing all tabs the session's document is open in will cause the session to close
7575
const window = getTestWindow()
76-
window.tabGroups.all.forEach(async (tabGroup) =>
77-
tabGroup.tabs.forEach(async (tab) => {
78-
if (tab.input instanceof vscode.TabInputText) {
79-
if (sessionUri!.toString() === tab.input.uri.toString()) {
80-
await window.tabGroups.close(tab)
81-
}
82-
}
83-
})
84-
)
76+
let tabs: vscode.Tab[] = []
77+
window.tabGroups.all.forEach((tabGroup) => {
78+
tabs = tabs.concat(getLiveTailSessionTabsFromTabGroup(tabGroup, sessionUri!))
79+
})
80+
await Promise.all(tabs.map((tab) => window.tabGroups.close(tab)))
8581
assert.strictEqual(registry.size, 0)
8682
assert.strictEqual(stopLiveTailSessionSpy.calledOnce, true)
8783
})
@@ -119,6 +115,14 @@ describe('TailLogGroup', function () {
119115
assert.strictEqual(document.getText(), '')
120116
})
121117

118+
function getLiveTailSessionTabsFromTabGroup(tabGroup: vscode.TabGroup, sessionUri: vscode.Uri): vscode.Tab[] {
119+
return tabGroup.tabs.filter((tab) => {
120+
if (tab.input instanceof vscode.TabInputText) {
121+
return sessionUri!.toString() === tab.input.uri.toString()
122+
}
123+
})
124+
}
125+
122126
function getTestWizardResponse(): TailLogGroupWizardResponse {
123127
return {
124128
regionLogGroupSubmenuResponse: {

0 commit comments

Comments
 (0)