Skip to content

Commit

Permalink
Adapt UI tests to Kaoto next
Browse files Browse the repository at this point in the history
part of #400

Signed-off-by: Aurélien Pupier <[email protected]>
  • Loading branch information
apupier committed Nov 24, 2023
1 parent 79cb48b commit 26cbaa3
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 92 deletions.
52 changes: 22 additions & 30 deletions it-tests/BasicFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ describe('Kaoto basic development flow', function () {
await editorView.closeAllEditors();
});

it('Open "emptyKameletBinding.kaoto.yaml" file and check Kaoto UI is loading', async function () {
it('Open "emptyPipe.kaoto.yaml" file and check Kaoto UI is loading', async function () {
const { kaotoWebview, kaotoEditor } = await openAndSwitchToKaotoFrame(
workspaceFolder,
'emptyKameletBinding.kaoto.yaml',
'emptyPipe.kaoto.yaml',
driver,
true
);
await checkIntegrationNameInTopBarLoaded(driver, 'my-integration-name');
// Route name is not displayed with Kaoto next
// await checkIntegrationNameInTopBarLoaded(driver, 'my-integration-name');
await checkEmptyCanvasLoaded(driver);
await kaotoWebview.switchBack();
assert.isFalse(
Expand All @@ -54,8 +55,9 @@ describe('Kaoto basic development flow', function () {
false
);
await checkEmptyCanvasLoaded(driver);
await createNewRoute(driver);
await addActiveMQStep(driver);
await checkStepWithTestIdPresent(driver, 'viz-step-activemq');
await checkStepWithTestIdPresent(driver, 'custom-node__amqp-*');

await kaotoWebview.switchBack();
assert.isTrue(
Expand All @@ -79,7 +81,7 @@ describe('Kaoto basic development flow', function () {
driver,
true
));
await checkStepWithTestIdPresent(driver, 'viz-step-activemq');
await checkStepWithTestIdPresent(driver, 'custom-node__amqp-*');
await kaotoWebview.switchBack();
});

Expand All @@ -90,8 +92,8 @@ describe('Kaoto basic development flow', function () {
driver,
true
);
await checkStepWithTestIdPresent(driver, 'viz-step-timer');
await checkStepWithTestIdPresent(driver, 'viz-step-log');
await checkStepWithTestIdPresent(driver, 'custom-node__timer-*');
await checkStepWithTestIdPresent(driver, 'custom-node__tlog-*');
await kaotoWebview.switchBack();
assert.isFalse(
await kaotoEditor.isDirty(),
Expand All @@ -100,36 +102,26 @@ describe('Kaoto basic development flow', function () {
});
});

async function createNewRoute(driver: WebDriver) {
await (await driver.findElement(By.xpath("//button[@data-testid='dsl-list-btn']"))).click();
}

async function addActiveMQStep(driver: WebDriver) {
await waitUntil(
async () => {
try {
await clickOnAddAStep(driver);
} catch {
console.log(
'Clicked on step failed surely due to Kaoto UI redrawing the content of the canvas. Will retry as a workaround'
);
return false;
}
return true;
},
10_000,
2_000
);
await driver.wait(
until.elementLocated(By.xpath("//button[@data-testid='miniCatalog__stepItem--activemq']"))
until.elementLocated(By.xpath("//rect[@class='pf-topology__node__action-icon__background']"))
);
await (
await driver.findElement(By.xpath("//button[@data-testid='miniCatalog__stepItem--activemq']"))
).click();
}
await (await driver.findElement(By.xpath("//rect[@class='pf-topology__node__action-icon__background']"))).click();

async function clickOnAddAStep(driver: WebDriver) {
await (await driver.findElement(By.xpath("//div[@data-testid='viz-step-slot']"))).click();
await (await driver.findElement(By.xpath("//li[@date-testid='context-menu-item-insert']"))).click();

await driver.wait(
until.elementLocated(By.xpath("//div[@data-testid='tile-activemq']"))
);
await (await driver.findElement(By.xpath("//div[@data-testid='tile-activemq']"))).click();
}

async function checkStepWithTestIdPresent(driver: WebDriver, testId: string) {
await driver.wait(until.elementLocated(By.xpath(`//div[@data-testid='${testId}']`)));
await driver.wait(until.elementLocated(By.xpath(`//g[@data-testid='${testId}']`)));
}

async function checkIntegrationNameInTopBarLoaded(driver: WebDriver, name: string) {
Expand Down
37 changes: 37 additions & 0 deletions it-tests/PropertyPanelLoading.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { By, EditorView, until, VSBrowser, WebDriver } from 'vscode-extension-tester';
import * as path from 'path';
import { openAndSwitchToKaotoFrame } from './Util';

describe('property panel loading test', function () {
this.timeout(60_000);

const workspaceFolder = path.join(__dirname, '../test Fixture with speci@l chars');

let driver: WebDriver;

before(async function () {
this.timeout(60_000);
driver = VSBrowser.instance.driver;
});

afterEach(async function () {
const editorView = new EditorView();
await editorView.closeAllEditors();
});

it('Open "choice.camel.yaml" file and check property panel is loading', async function () {
const { kaotoWebview, } = await openAndSwitchToKaotoFrame(
workspaceFolder,
'choice.camel.yaml',
driver,
true
);
const stepWhenXpath = By.xpath("//g[@data-testid='custom-node__when-*']");
await driver.wait(until.elementLocated(stepWhenXpath));
await (await driver.findElement(stepWhenXpath)).click();
await driver.wait(
until.elementLocated(By.xpath("//input[@value='${header.foo} == 1']"))
);
await kaotoWebview.switchBack();
});
});
54 changes: 0 additions & 54 deletions it-tests/StepExtensionLoading.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion it-tests/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ export async function switchToKaotoFrame(driver: WebDriver, checkNotDirty: boole
}

export async function checkEmptyCanvasLoaded(driver: WebDriver) {
await driver.wait(until.elementLocated(By.xpath("//div[@data-testid='viz-step-slot']")));
await driver.wait(until.elementLocated(By.xpath("//div[@data-test-id='topology']")));
}

This file was deleted.

7 changes: 7 additions & 0 deletions test Fixture with speci@l chars/emptyPipe.kaoto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: my-integration-name
spec:
source: {}
sink: {}

0 comments on commit 26cbaa3

Please sign in to comment.