This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support qmlls with e2e tests for configuration changes
Fix: #251
- Loading branch information
1 parent
c35d822
commit 63aefd3
Showing
8 changed files
with
173 additions
and
19 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
nodejs 18.10.0 | ||
python 3.10.6 | ||
python 3.11.1 |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
python 3.10.6 | ||
python 3.11.1 |
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
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
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
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
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,155 @@ | ||
import * as assert from 'node:assert' | ||
import * as path from 'node:path' | ||
import type { CompletionList, Diagnostic, TextDocument } from 'vscode' | ||
import { commands, languages, Position, window, workspace } from 'vscode' | ||
import { URI } from 'vscode-uri' | ||
import { | ||
E2E_TIMEOUT, | ||
setupE2EEnvironment, | ||
TEST_ASSETS_PATH, | ||
waitFor, | ||
} from '../test-utils' | ||
|
||
suite('qmlls/e2e', () => { | ||
suiteSetup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
await setupE2EEnvironment() | ||
}) | ||
|
||
suite('when open missing_import.qml', () => { | ||
let diagnostics: readonly Diagnostic[] | ||
let document: TextDocument | ||
|
||
suiteSetup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
|
||
document = await openAndShowTestQmlFile('missing_import.qml') | ||
}) | ||
|
||
test('should contain diagnostics', async () => | ||
waitFor(() => { | ||
diagnostics = languages.getDiagnostics(document.uri) | ||
assert.ok(diagnostics.length > 0) | ||
})).timeout(E2E_TIMEOUT) | ||
|
||
suite('when trigger completion in first line', () => { | ||
const position = new Position(0, 0) | ||
|
||
test('should contain Qt completion items', async () => { | ||
const itemResolveCount = 1 | ||
|
||
const completionList: CompletionList = await commands.executeCommand( | ||
'vscode.executeCompletionItemProvider', | ||
document.uri, | ||
position, | ||
undefined, | ||
itemResolveCount, | ||
) | ||
|
||
assert.ok(completionList.items.map(i => i.label).includes('Qt')) | ||
}).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
|
||
suite('when disable qmlls', () => { | ||
suiteSetup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
|
||
await workspace | ||
.getConfiguration('qtForPython.qmlls') | ||
.update('enabled', false) | ||
}) | ||
|
||
suiteTeardown(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
|
||
await workspace | ||
.getConfiguration('qtForPython.qmlls') | ||
.update('enabled', undefined) | ||
}) | ||
|
||
test('should not contain diagnostic', async () => | ||
waitFor(() => { | ||
diagnostics = languages.getDiagnostics(document.uri) | ||
assert.ok(diagnostics.length === 0) | ||
})).timeout(E2E_TIMEOUT) | ||
|
||
suite('when trigger completion in first line', () => { | ||
const position = new Position(0, 0) | ||
|
||
test('should not contain Qt completion item', async () => { | ||
const completionList: CompletionList = await commands.executeCommand( | ||
'vscode.executeCompletionItemProvider', | ||
document.uri, | ||
position, | ||
) | ||
|
||
assert.ok(!completionList.items.map(i => i.label).includes('Qt')) | ||
}).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
|
||
suite('when enable qmlls again', () => { | ||
suiteSetup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
|
||
await workspace | ||
.getConfiguration('qtForPython.qmlls') | ||
.update('enabled', true) | ||
}) | ||
|
||
suiteTeardown(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
|
||
await workspace | ||
.getConfiguration('qtForPython.qmlls') | ||
.update('enabled', undefined) | ||
}) | ||
|
||
test('should contain diagnostic again', async () => | ||
waitFor(() => { | ||
diagnostics = languages.getDiagnostics(document.uri) | ||
assert.ok(diagnostics.length > 0) | ||
})).timeout(E2E_TIMEOUT) | ||
|
||
suite('when trigger completion in first line', () => { | ||
const position = new Position(0, 0) | ||
|
||
test('should contain Qt completion item again', async () => { | ||
const completionList: CompletionList = | ||
await commands.executeCommand( | ||
'vscode.executeCompletionItemProvider', | ||
document.uri, | ||
position, | ||
) | ||
|
||
assert.ok(completionList.items.map(i => i.label).includes('Qt')) | ||
}).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
|
||
suite('when open pass.qml', () => { | ||
let diagnostics: readonly Diagnostic[] | ||
let document: TextDocument | ||
|
||
suiteSetup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
|
||
document = await openAndShowTestQmlFile('pass.qml') | ||
}) | ||
|
||
test('should not contain diagnostic', async () => | ||
waitFor(() => { | ||
diagnostics = languages.getDiagnostics(document.uri) | ||
assert.ok(diagnostics.length === 0) | ||
})).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
}).timeout(E2E_TIMEOUT) | ||
|
||
async function openAndShowTestQmlFile(filename: string) { | ||
const document = await workspace.openTextDocument( | ||
URI.file(path.resolve(TEST_ASSETS_PATH, 'qml', filename)), | ||
) | ||
await window.showTextDocument(document) | ||
return document | ||
} |