Skip to content

Commit

Permalink
fix: support xsd in Kaoto DataMapper on Windows
Browse files Browse the repository at this point in the history
* The fix consists in using fsPath of the vscode.URI
* Added the UI test part to check source xsd correctly loaded
* Note that the contextual menu to delete the step in tests is used
instead of the toolbar (which is more modern) as the delete button
toolbar is not visible enough to be clickable

fix #747

Signed-off-by: Aurélien Pupier <[email protected]>
  • Loading branch information
apupier committed Jan 6, 2025
1 parent 2ceb96a commit a6b7881
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 2.4.0

- Fix Kaoto Datamapper editor on Windows (issue when attaching an xsd)

# 2.3.0

- Introduced a `Kaoto` output channel. It is initially used to log message of exceptions.
Expand Down
18 changes: 10 additions & 8 deletions it-tests/BasicFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ async function addXsdForSource(driver: WebDriver, kaotoWebview: WebView) {
await xsdInputbox.confirm();
await kaotoWebview.switchToFrame();

//TODO: check content is loaded
await driver.wait(
until.elementLocated(By.xpath('//div[starts-with(@data-testid, "node-source-field-shiporder-")]'))
, 5000
, 'Root of the imported xsd is not displayed in the UI');
}

async function openDataMapperEditor(driver: WebDriver) {
Expand All @@ -220,16 +223,15 @@ async function openDataMapperEditor(driver: WebDriver) {
async function deleteDataMapperStep(driver: WebDriver, workspaceFolder: string) {
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__kaoto-datamapper', 'kaoto-datamapper');
const kaotoNodeConfigured = await driver.findElement(By.css('g[data-testid^="custom-node__kaoto-datamapper"],g[data-testid="custom-node__route.from.steps.0.kaoto-datamapper"]'));
await kaotoNodeConfigured.click();
await driver.wait(
until.elementLocated(By.css('button[data-testid="step-toolbar-button-delete"]'))
);
await (await driver.findElement(By.css('button[data-testid="step-toolbar-button-delete"]'))).click();

await driver.actions().contextClick(kaotoNodeConfigured).perform();

await driver.wait(
until.elementLocated(By.css('button[data-testid="action-confirmation-modal-btn-del-step-and-file"]'))
until.elementLocated(By.className('pf-v5-c-dropdown pf-m-expanded'))
);
await (await driver.findElement(By.css('button[data-testid="action-confirmation-modal-btn-del-step-and-file"]'))).click();
await (await driver.findElement(By.xpath("//*[@data-testid='context-menu-item-delete']"))).click();

await (await driver.findElement(By.css('button[data-testid="action-confirmation-modal-btn-del-step-and-file"]'))).click();
await waitUntil(() => {
const filesAfterDeletion = fs.readdirSync(workspaceFolder);
const xslFilesAfterDeletion = filesAfterDeletion.filter(file => file.endsWith('.xsl'));
Expand Down
2 changes: 1 addition & 1 deletion src/webview/VSCodeKaotoEditorChannelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class VSCodeKaotoEditorChannelApi extends DefaultVsCodeKieEditorChannelAp
kaotoMetadataFile = await this.findKaotoMetadataToCreate();
}
return await vscode.window.showQuickPick(files.map((f) => {
return path.relative(path.dirname(kaotoMetadataFile.fsPath), f.path);
return path.relative(path.dirname(kaotoMetadataFile.fsPath), f.fsPath);
}), options as vscode.QuickPickOptions);
} catch (ex) {
const errorMessage = `Cannot get a user selection: ${ex.message}`;
Expand Down

0 comments on commit a6b7881

Please sign in to comment.