Skip to content

Commit

Permalink
Remove delay progress notfication closing from integration tests (#3412)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephanie Roy <[email protected]>
  • Loading branch information
mattseddon and sroy3 authored Mar 7, 2023
1 parent b208a2f commit 8728e94
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
9 changes: 6 additions & 3 deletions extension/src/test/suite/experiments/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Experiments } from '../../../experiments'
import * as QuickPick from '../../../vscode/quickPick'
import { DvcExecutor } from '../../../cli/dvc/executor'
import {
bypassProgressCloseDelay,
closeAllEditors,
getInputBoxEvent,
getTimeSafeDisposer,
Expand All @@ -30,7 +31,7 @@ import {
QuickPickItemWithValue,
QuickPickOptionsWithTitle
} from '../../../vscode/quickPick'
import { PROGRESS_TEST_TIMEOUT, WEBVIEW_TEST_TIMEOUT } from '../timeouts'
import { WEBVIEW_TEST_TIMEOUT } from '../timeouts'
import { Title } from '../../../vscode/title'
import { join } from '../../util/path'
import { AvailableCommands } from '../../../commands/internal'
Expand Down Expand Up @@ -688,6 +689,7 @@ suite('Workspace Experiments Test Suite', () => {

describe('dvc.shareExperimentAsBranch', () => {
it('should be able to share an experiment as a branch', async () => {
bypassProgressCloseDelay()
stub(DvcReader.prototype, 'listStages').resolves('train')

const { experiments } = buildExperiments(disposable)
Expand Down Expand Up @@ -746,10 +748,11 @@ suite('Workspace Experiments Test Suite', () => {
expect(mockPush).to.be.calledWithExactly(dvcDemoPath)
expect(mockGitPush).to.be.calledWithExactly(dvcDemoPath, mockBranch)
})
}).timeout(PROGRESS_TEST_TIMEOUT)
})

describe('dvc.shareExperimentAsCommit', () => {
it('should be able to share an experiment as a commit', async () => {
bypassProgressCloseDelay()
stub(DvcReader.prototype, 'listStages').resolves('train')

const { experiments } = buildExperiments(disposable)
Expand Down Expand Up @@ -802,7 +805,7 @@ suite('Workspace Experiments Test Suite', () => {
)
expect(mockPush).to.be.calledWithExactly(dvcDemoPath)
expect(mockGitPush).to.be.calledWithExactly(dvcDemoPath)
}).timeout(PROGRESS_TEST_TIMEOUT)
})
})

describe('dvc.removeExperiments', () => {
Expand Down
13 changes: 9 additions & 4 deletions extension/src/test/suite/patch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { restore, spy, stub } from 'sinon'
import { expect } from 'chai'
import * as Fetch from 'node-fetch'
import { commands } from 'vscode'
import { buildInternalCommands, closeAllEditors } from './util'
import { PROGRESS_TEST_TIMEOUT } from './timeouts'
import {
buildInternalCommands,
bypassProgressCloseDelay,
closeAllEditors
} from './util'
import { Disposable } from '../../extension'
import { STUDIO_ENDPOINT, registerPatchCommand } from '../../patch'
import { AvailableCommands } from '../../commands/internal'
Expand All @@ -31,6 +34,7 @@ suite('Patch Test Suite', () => {

describe('exp push patch', () => {
it('should share an experiment to Studio', async () => {
bypassProgressCloseDelay()
const mockFetch = stub(Fetch, 'default').resolves({} as Fetch.Response)
const mockStudioAccessToken = 'isat_12123123123123123'
const mockRepoUrl = 'https://github.com/iterative/vscode-dvc-demo'
Expand Down Expand Up @@ -100,9 +104,10 @@ suite('Patch Test Suite', () => {
headers,
method: 'POST'
})
}).timeout(PROGRESS_TEST_TIMEOUT)
})

it('should show an error modal if Studio returns a 401 response', async () => {
bypassProgressCloseDelay()
const mockFetch = stub(Fetch, 'default').resolves({
status: 401
} as Fetch.Response)
Expand Down Expand Up @@ -160,7 +165,7 @@ suite('Patch Test Suite', () => {
headers,
method: 'POST'
})
}).timeout(PROGRESS_TEST_TIMEOUT)
})

it('should show an error message if the experiment cannot be found', async () => {
const mockShowError = stub(Toast, 'showError').resolves(undefined)
Expand Down
5 changes: 3 additions & 2 deletions extension/src/test/suite/setup/autoInstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as PythonExtension from '../../../extensions/python'
import * as Python from '../../../python'
import { autoInstallDvc } from '../../../setup/autoInstall'
import * as WorkspaceFolders from '../../../vscode/workspaceFolders'
import { PROGRESS_TEST_TIMEOUT } from '../timeouts'
import { bypassProgressCloseDelay } from '../util'

const { getDefaultPython } = Python

Expand Down Expand Up @@ -61,6 +61,7 @@ suite('Auto Install Test Suite', () => {
})

it('should install DVC and DVCLive if a Python interpreter is found', async () => {
bypassProgressCloseDelay()
const cwd = __dirname
stub(PythonExtension, 'getPythonExecutionDetails').resolves(undefined)
stub(Python, 'findPythonBin').resolves(defaultPython)
Expand All @@ -87,6 +88,6 @@ suite('Auto Install Test Suite', () => {
defaultPython,
'dvclive'
)
}).timeout(PROGRESS_TEST_TIMEOUT)
})
})
})
1 change: 0 additions & 1 deletion extension/src/test/suite/timeouts.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const WEBVIEW_TEST_TIMEOUT = 16000
export const PROGRESS_TEST_TIMEOUT = 8000
4 changes: 4 additions & 0 deletions extension/src/test/suite/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { GitReader } from '../../cli/git/reader'
import { SetupData } from '../../setup/webview/contract'
import { DvcViewer } from '../../cli/dvc/viewer'
import { ConnectData } from '../../connect/webview/contract'
import { Toast } from '../../vscode/toast'

export const mockDisposable = {
dispose: stub()
Expand Down Expand Up @@ -306,3 +307,6 @@ export const getTimeSafeDisposer = (): Disposer & {
}
})
}

export const bypassProgressCloseDelay = () =>
stub(Toast, 'delayProgressClosing').resolves(undefined)

0 comments on commit 8728e94

Please sign in to comment.