Loading src/status_bar.test.ts +5 −3 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ import * as vscode from 'vscode'; import * as gitLabService from './gitlab_service'; import { pipeline, mr, issue } from './test_utils/entities'; import { USER_COMMANDS } from './command_names'; import { getCurrentWorkspaceFolder } from './services/workspace_service'; import { gitExtensionWrapper } from './git/git_extension_wrapper'; jest.mock('./gitlab_service'); jest.mock('./services/workspace_service'); jest.mock('./git/git_extension_wrapper'); const asMock = (mockFn: unknown) => mockFn as jest.Mock; Loading Loading @@ -45,7 +45,9 @@ describe('status_bar', () => { fakeItems.push(fakeItem); return fakeItem; }); asMock(getCurrentWorkspaceFolder).mockResolvedValue('/folder'); asMock(gitExtensionWrapper.getActiveRepository).mockReturnValue({ rootFsPath: '/folder', }); asMock(gitLabService.fetchCurrentProject).mockResolvedValue({}); }); Loading src/status_bar.ts +7 −7 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ import * as vscode from 'vscode'; import * as openers from './openers'; import * as gitLabService from './gitlab_service'; import { getCurrentWorkspaceFolder } from './services/workspace_service'; import { UserFriendlyError } from './errors/user_friendly_error'; import { log, logError } from './log'; import { USER_COMMANDS } from './command_names'; import { gitExtensionWrapper } from './git/git_extension_wrapper'; const MAXIMUM_DISPLAYED_JOBS = 4; Loading Loading @@ -72,10 +72,10 @@ export class StatusBar { firstRun = true; async refresh() { const workspaceFolder = await getCurrentWorkspaceFolder(); if (!workspaceFolder) return; const repository = gitExtensionWrapper.getActiveRepository(); if (!repository) return; const project = await gitLabService.fetchCurrentProject(workspaceFolder); const project = await gitLabService.fetchCurrentProject(repository.rootFsPath); if (!project) { log( 'GitLab project not found, the extension is going to hide the status bar until next refresh in 30s.', Loading @@ -84,11 +84,11 @@ export class StatusBar { return; } const { mr, pipeline } = await gitLabService.fetchPipelineAndMrForCurrentBranch( workspaceFolder, repository.rootFsPath, ); await this.updatePipelineItem(pipeline, workspaceFolder); await this.updatePipelineItem(pipeline, repository.rootFsPath); this.updateMrItem(mr); await this.fetchMrClosingIssue(mr, workspaceFolder); await this.fetchMrClosingIssue(mr, repository.rootFsPath); } hideAllItems(): void { Loading Loading
src/status_bar.test.ts +5 −3 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ import * as vscode from 'vscode'; import * as gitLabService from './gitlab_service'; import { pipeline, mr, issue } from './test_utils/entities'; import { USER_COMMANDS } from './command_names'; import { getCurrentWorkspaceFolder } from './services/workspace_service'; import { gitExtensionWrapper } from './git/git_extension_wrapper'; jest.mock('./gitlab_service'); jest.mock('./services/workspace_service'); jest.mock('./git/git_extension_wrapper'); const asMock = (mockFn: unknown) => mockFn as jest.Mock; Loading Loading @@ -45,7 +45,9 @@ describe('status_bar', () => { fakeItems.push(fakeItem); return fakeItem; }); asMock(getCurrentWorkspaceFolder).mockResolvedValue('/folder'); asMock(gitExtensionWrapper.getActiveRepository).mockReturnValue({ rootFsPath: '/folder', }); asMock(gitLabService.fetchCurrentProject).mockResolvedValue({}); }); Loading
src/status_bar.ts +7 −7 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ import * as vscode from 'vscode'; import * as openers from './openers'; import * as gitLabService from './gitlab_service'; import { getCurrentWorkspaceFolder } from './services/workspace_service'; import { UserFriendlyError } from './errors/user_friendly_error'; import { log, logError } from './log'; import { USER_COMMANDS } from './command_names'; import { gitExtensionWrapper } from './git/git_extension_wrapper'; const MAXIMUM_DISPLAYED_JOBS = 4; Loading Loading @@ -72,10 +72,10 @@ export class StatusBar { firstRun = true; async refresh() { const workspaceFolder = await getCurrentWorkspaceFolder(); if (!workspaceFolder) return; const repository = gitExtensionWrapper.getActiveRepository(); if (!repository) return; const project = await gitLabService.fetchCurrentProject(workspaceFolder); const project = await gitLabService.fetchCurrentProject(repository.rootFsPath); if (!project) { log( 'GitLab project not found, the extension is going to hide the status bar until next refresh in 30s.', Loading @@ -84,11 +84,11 @@ export class StatusBar { return; } const { mr, pipeline } = await gitLabService.fetchPipelineAndMrForCurrentBranch( workspaceFolder, repository.rootFsPath, ); await this.updatePipelineItem(pipeline, workspaceFolder); await this.updatePipelineItem(pipeline, repository.rootFsPath); this.updateMrItem(mr); await this.fetchMrClosingIssue(mr, workspaceFolder); await this.fetchMrClosingIssue(mr, repository.rootFsPath); } hideAllItems(): void { Loading