From 8728e94d0d11b9ec00b27af884b0b88b1f7ba209 Mon Sep 17 00:00:00 2001 From: Matt Seddon <37993418+mattseddon@users.noreply.github.com> Date: Wed, 8 Mar 2023 01:17:02 +1100 Subject: [PATCH] Remove delay progress notfication closing from integration tests (#3412) Co-authored-by: Stephanie Roy --- .../src/test/suite/experiments/workspace.test.ts | 9 ++++++--- extension/src/test/suite/patch.test.ts | 13 +++++++++---- extension/src/test/suite/setup/autoInstall.test.ts | 5 +++-- extension/src/test/suite/timeouts.ts | 1 - extension/src/test/suite/util.ts | 4 ++++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/extension/src/test/suite/experiments/workspace.test.ts b/extension/src/test/suite/experiments/workspace.test.ts index eca4d7c0de..55dba63447 100644 --- a/extension/src/test/suite/experiments/workspace.test.ts +++ b/extension/src/test/suite/experiments/workspace.test.ts @@ -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, @@ -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' @@ -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) @@ -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) @@ -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', () => { diff --git a/extension/src/test/suite/patch.test.ts b/extension/src/test/suite/patch.test.ts index 5580d7025e..5b90a3ef00 100644 --- a/extension/src/test/suite/patch.test.ts +++ b/extension/src/test/suite/patch.test.ts @@ -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' @@ -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' @@ -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) @@ -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) diff --git a/extension/src/test/suite/setup/autoInstall.test.ts b/extension/src/test/suite/setup/autoInstall.test.ts index 447cdc6e15..44276f5dfd 100644 --- a/extension/src/test/suite/setup/autoInstall.test.ts +++ b/extension/src/test/suite/setup/autoInstall.test.ts @@ -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 @@ -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) @@ -87,6 +88,6 @@ suite('Auto Install Test Suite', () => { defaultPython, 'dvclive' ) - }).timeout(PROGRESS_TEST_TIMEOUT) + }) }) }) diff --git a/extension/src/test/suite/timeouts.ts b/extension/src/test/suite/timeouts.ts index f7fd437b83..dda10cf6b2 100644 --- a/extension/src/test/suite/timeouts.ts +++ b/extension/src/test/suite/timeouts.ts @@ -1,2 +1 @@ export const WEBVIEW_TEST_TIMEOUT = 16000 -export const PROGRESS_TEST_TIMEOUT = 8000 diff --git a/extension/src/test/suite/util.ts b/extension/src/test/suite/util.ts index d0fa486623..61741bb9a2 100644 --- a/extension/src/test/suite/util.ts +++ b/extension/src/test/suite/util.ts @@ -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() @@ -306,3 +307,6 @@ export const getTimeSafeDisposer = (): Disposer & { } }) } + +export const bypassProgressCloseDelay = () => + stub(Toast, 'delayProgressClosing').resolves(undefined)