Skip to content

Commit

Permalink
fix close tab race condition in tailLogGroup test
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Irby committed Oct 17, 2024
1 parent f5efbd3 commit 19ef62c
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,11 @@ describe('TailLogGroup', function () {

//Test that closing all tabs the session's document is open in will cause the session to close
const window = getTestWindow()
window.tabGroups.all.forEach(async (tabGroup) =>
tabGroup.tabs.forEach(async (tab) => {
if (tab.input instanceof vscode.TabInputText) {
if (sessionUri!.toString() === tab.input.uri.toString()) {
await window.tabGroups.close(tab)
}
}
})
)
let tabs: vscode.Tab[] = []
window.tabGroups.all.forEach((tabGroup) => {
tabs = tabs.concat(getLiveTailSessionTabsFromTabGroup(tabGroup, sessionUri!))
})
await Promise.all(tabs.map((tab) => window.tabGroups.close(tab)))
assert.strictEqual(registry.size, 0)
assert.strictEqual(stopLiveTailSessionSpy.calledOnce, true)
})
Expand Down Expand Up @@ -119,6 +115,14 @@ describe('TailLogGroup', function () {
assert.strictEqual(document.getText(), '')
})

function getLiveTailSessionTabsFromTabGroup(tabGroup: vscode.TabGroup, sessionUri: vscode.Uri): vscode.Tab[] {
return tabGroup.tabs.filter((tab) => {
if (tab.input instanceof vscode.TabInputText) {
return sessionUri!.toString() === tab.input.uri.toString()
}
})
}

function getTestWizardResponse(): TailLogGroupWizardResponse {
return {
regionLogGroupSubmenuResponse: {
Expand Down

0 comments on commit 19ef62c

Please sign in to comment.