Skip to content

Commit

Permalink
FUSETOOLS2-2065: Provide tests for completion inside tasks.json (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
pospisilf authored Nov 10, 2023
1 parent 9451b58 commit dcdd7be
Show file tree
Hide file tree
Showing 12 changed files with 366 additions and 2 deletions.
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
},
"devDependencies": {
"@types/chai": "^4.3.10",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.4",
"@types/node": "14.x",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "Launch Camel test with Maven with camel.debug profile",
"type": "shell",
"command": "mvn", // mvn binary of Maven must be available on command-line
"args": [
"test",
"-Dtest=*", // If more than one test is present, a specific one must be specified as a single test can be Camel debugged per launch.
"-Pcamel.debug" // This depends on your project. The goal here is to have camel-debug on the classpath.
],
"options": {
"env": {
"CAMEL_DEBUGGER_SUSPEND": "true" // Set to true by default. A debugger must be attached for message to be processed.
}
},
"problemMatcher": "$camel.debug.problemMatcher",
"presentation": {
"reveal": "always"
},
"isBackground": true // Must be set as background as the Maven commands doesn't return until the Camel application stops.
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Camel application with JBang with camel-debug",
"type": "shell",
"command": "jbang", // jbang binary must be available on command-line
"args": [
"-Dorg.apache.camel.debugger.suspend=true", // requires Camel 3.18+ to take effect
"-Dcamel.jbang.version=4.0.0", // to adapt to your Camel version. 3.16+ is required
"camel@apache/camel",
"run",
"${relativeFile}", //to adapt to your workspace, using relativeFile means that the task must be launched when the file to start in debug in the active editor
"--logging-level=info",
"--reload",
"--dep=org.apache.camel:camel-debug"
],
"problemMatcher": "$camel.debug.problemMatcher",
"presentation": {
"reveal": "always"
},
"isBackground": true // Must be set as background as the jbang command doesn't return until the Camel application stops.
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Camel application with camel:debug Maven goal",
"type": "shell",
"command": "mvn", // mvn binary of Maven must be available on command-line
"args": [
"camel:debug"
],
"options": {
"env": {
"CAMEL_DEBUGGER_SUSPEND": "true" // Set to true by default. A debugger must be attached for message to be processed.
}
},
"problemMatcher": "$camel.debug.problemMatcher",
"presentation": {
"reveal": "always"
},
"isBackground": true // Must be set as background as the Maven commands doesn't return until the Camel application stops.
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Camel application with Maven Quarkus Dev with camel.debug profile",
"type": "shell",
"command": "mvn", // mvn binary of Maven must be available on command-line
"args": [
"compile",
"quarkus:dev",
"-Pcamel.debug" // This depends on your project. The goal here is to have camel-debug on the classpath.
],
"problemMatcher": "$camel.debug.problemMatcher",
"presentation": {
"reveal": "always"
},
"isBackground": true // Must be set as background as the Maven commands doesn't return until the Camel application stops.
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Camel application with camel.debug profile",
"type": "shell",
"command": "mvn", // mvn binary of Maven must be available on command-line
"args": [
"camel:run",
"-Pcamel.debug" // This depends on your project. The goal here is to have camel-debug on the classpath.
],
"problemMatcher": "$camel.debug.problemMatcher",
"presentation": {
"reveal": "always"
},
"isBackground": true // Must be set as background as the Maven commands doesn't return until the Camel application stops.
}
]
}
8 changes: 8 additions & 0 deletions src/ui-test/resources/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [

]
}
60 changes: 60 additions & 0 deletions src/ui-test/tests/tasks.json.autocompletion.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License", destination); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { expect } from "chai";
import { activateEditor, closeEditor, getFileContent, openFileInEditor, selectFromCA } from "../utils";
import { ActivityBar, TextEditor, VSBrowser, WebDriver } from "vscode-uitests-tooling";
import * as path from "path";
import { RESOURCES_DIR, RESOURCES_TASK_EXAMPLES_DIR, TASKS_TEST_FILE } from "../variables";

describe('Completion inside tasks.json', function () {
this.timeout(120000);

let driver: WebDriver;
let textEditor: TextEditor | null;

before(async function () {
driver = VSBrowser.instance.driver;
await VSBrowser.instance.openResources(path.resolve('src', 'ui-test', 'resources'));
await (await new ActivityBar().getViewControl('Explorer')).openView();
});

const PARAMS = [
// command, filename
['Launch Camel test with Maven with camel.debug profile', '01_launch_camel_debug_profile.json'],
['Run Camel application with JBang with camel-debug', '02_run_jbang_w_camel_debug.json'],
['Start Camel application with camel:debug Maven goal', '03_start_mvn_camel_debug_goal.json'],
['Start Camel application with Maven Quarkus Dev with camel.debug profile', '04_start_mvn_quarkus_dev_debug_profile.json'],
['Start Camel application with Maven with camel.debug profile', '05_start_mvn_camel_debug_profile.json']
];

PARAMS.forEach(function (params) {
const command = params.at(0) as string;
const file = params.at(1) as string;

it(`${command}`, async function () {
await openFileInEditor(driver, RESOURCES_DIR, TASKS_TEST_FILE);
textEditor = await activateEditor(driver, TASKS_TEST_FILE);
// workaround for https://github.com/redhat-developer/vscode-extension-tester/issues/931
await textEditor?.setTextAtLine(6, " ");
await textEditor?.moveCursor(6, 9);
await selectFromCA(command);
const text = await textEditor?.getText();
expect(text).equals(getFileContent(file, RESOURCES_TASK_EXAMPLES_DIR));
await closeEditor(TASKS_TEST_FILE, false);
});
});
});
Loading

0 comments on commit dcdd7be

Please sign in to comment.