-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the following commit includes api integration tests for `scm`. Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
- Loading branch information
1 parent
fd23988
commit a28cf27
Showing
1 changed file
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
// @ts-check | ||
describe('SCM', function () { | ||
|
||
const { assert } = chai; | ||
|
||
const Uri = require('@theia/core/lib/common/uri'); | ||
const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell'); | ||
const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution'); | ||
const { ScmService } = require('@theia/scm/lib/browser/scm-service'); | ||
const { ScmWidget } = require('@theia/scm/lib/browser/scm-widget'); | ||
|
||
/** @type {import('inversify').Container} */ | ||
const container = window['theia'].container; | ||
const scmContribution = container.get(ScmContribution); | ||
const shell = container.get(ApplicationShell); | ||
|
||
/** @type {ScmWidget} */ | ||
let scmWidget; | ||
|
||
/** @type {ScmService} */ | ||
let scmService; | ||
|
||
beforeEach(async () => { | ||
await shell.leftPanelHandler.collapse(); | ||
scmWidget = await scmContribution.openView({ activate: true, reveal: true }); | ||
scmService = scmWidget['scmService']; | ||
}); | ||
|
||
describe('scm-view', () => { | ||
|
||
it('the view should open and activate successfully', () => { | ||
assert.notEqual(scmWidget, undefined); | ||
assert.strictEqual(scmWidget, shell.activeWidget); | ||
}); | ||
|
||
it('the view should not display the \'NoRepositoryWidget\' widget when a repository is present', () => { | ||
const noRepositoryWidget = scmWidget['noRepositoryWidget']; | ||
assert.isFalse(noRepositoryWidget.isVisible); | ||
}); | ||
|
||
it('the view should display the \'NoRepositoryWidget\' widget when no repository is present', () => { | ||
|
||
// Store the current selected repository so it can be restored. | ||
const cachedSelectedRepository = scmService.selectedRepository; | ||
|
||
scmService.selectedRepository = undefined; | ||
const noRepositoryWidget = scmWidget['noRepositoryWidget']; | ||
assert.isTrue(noRepositoryWidget.isVisible); | ||
|
||
// Restore the selected repository. | ||
scmService.selectedRepository = cachedSelectedRepository; | ||
|
||
}); | ||
|
||
it('the view should display the resource tree when a repository is present', () => { | ||
const resourceWidget = scmWidget['resourceWidget']; | ||
assert.isTrue(resourceWidget.isVisible); | ||
}); | ||
|
||
it('the view should not display the resource tree when no repository is present', () => { | ||
|
||
// Store the current selected repository so it can be restored. | ||
const cachedSelectedRepository = scmService.selectedRepository; | ||
|
||
scmService.selectedRepository = undefined; | ||
const resourceWidget = scmWidget['resourceWidget']; | ||
assert.isFalse(resourceWidget.isVisible); | ||
|
||
// Restore the selected repository. | ||
scmService.selectedRepository = cachedSelectedRepository; | ||
}); | ||
|
||
}); | ||
|
||
describe('scm-service', () => { | ||
|
||
it('the service should successfully return the list of repositories', () => { | ||
const repositories = scmService.repositories; | ||
assert.isTrue(repositories.length > 0); | ||
}); | ||
|
||
it('the service should successfully return the selected repository', () => { | ||
const selectedRepository = scmService.selectedRepository; | ||
assert.notEqual(selectedRepository, undefined); | ||
}); | ||
|
||
it('the service should not find a repository for an unknown uri', () => { | ||
const mockUri = new Uri.default('foobar/foo/bar'); | ||
const repo = scmService.findRepository(mockUri); | ||
assert.strictEqual(repo, undefined); | ||
}); | ||
|
||
it('the service should successfully return the list of statusbar commands', () => { | ||
const commands = scmService.statusBarCommands; | ||
assert.isTrue(commands.length > 0); | ||
}); | ||
|
||
}); | ||
|
||
describe('scm-provider', () => { | ||
|
||
it('the provider should successfully return the last commit', async () => { | ||
const selectedRepository = scmService.selectedRepository; | ||
if (selectedRepository) { | ||
const amendSupport = selectedRepository.provider.amendSupport; | ||
if (amendSupport) { | ||
const commit = await amendSupport.getLastCommit(); | ||
assert.notEqual(commit, undefined); | ||
} | ||
} | ||
}); | ||
|
||
}); | ||
|
||
}); |