From d615531c2415b2ef85fc75e454c7715562b61d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Fri, 24 Nov 2023 14:38:30 +0100 Subject: [PATCH] Adapt UI tests to Kaoto next MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit part of #400 Signed-off-by: Aurélien Pupier --- it-tests/BasicFlow.test.ts | 55 +++++++++---------- it-tests/PropertyPanelLoading.test.ts | 37 +++++++++++++ it-tests/StepExtensionLoading.test.ts | 54 ------------------ it-tests/Util.ts | 2 +- .../emptyKameletBinding.kaoto.yaml | 7 --- .../emptyPipe.kaoto.yaml | 7 +++ 6 files changed, 70 insertions(+), 92 deletions(-) create mode 100644 it-tests/PropertyPanelLoading.test.ts delete mode 100644 it-tests/StepExtensionLoading.test.ts delete mode 100644 test Fixture with speci@l chars/emptyKameletBinding.kaoto.yaml create mode 100644 test Fixture with speci@l chars/emptyPipe.kaoto.yaml diff --git a/it-tests/BasicFlow.test.ts b/it-tests/BasicFlow.test.ts index bd9726bb..baa23cf1 100644 --- a/it-tests/BasicFlow.test.ts +++ b/it-tests/BasicFlow.test.ts @@ -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( @@ -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( @@ -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(); }); @@ -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(), @@ -100,36 +102,29 @@ 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 - ); + console.log('will add an activemq step'); await driver.wait( - until.elementLocated(By.xpath("//button[@data-testid='miniCatalog__stepItem--activemq']")) + until.elementLocated(By.xpath("//g[@class='pf-topology__node__action-icon']")) ); - await ( - await driver.findElement(By.xpath("//button[@data-testid='miniCatalog__stepItem--activemq']")) - ).click(); -} + await (await driver.findElement(By.xpath("//g[@class='pf-topology__node__action-icon']"))).click(); -async function clickOnAddAStep(driver: WebDriver) { - await (await driver.findElement(By.xpath("//div[@data-testid='viz-step-slot']"))).click(); + console.log('open context menu opened, will click on insert'); + await (await driver.findElement(By.xpath("//li[@date-testid='context-menu-item-insert']"))).click(); + + console.log('will click on the activemq tile'); + 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) { diff --git a/it-tests/PropertyPanelLoading.test.ts b/it-tests/PropertyPanelLoading.test.ts new file mode 100644 index 00000000..cf2accbc --- /dev/null +++ b/it-tests/PropertyPanelLoading.test.ts @@ -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(); + }); +}); diff --git a/it-tests/StepExtensionLoading.test.ts b/it-tests/StepExtensionLoading.test.ts deleted file mode 100644 index 1282b5f1..00000000 --- a/it-tests/StepExtensionLoading.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { By, EditorView, until, VSBrowser, WebDriver } from 'vscode-extension-tester'; -import * as path from 'path'; -import { openAndSwitchToKaotoFrame } from './Util'; -import waitUntil from 'async-wait-until'; - -describe('Step extension 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 Step extension is loading', async function () { - const { kaotoWebview, kaotoEditor } = await openAndSwitchToKaotoFrame( - workspaceFolder, - 'choice.camel.yaml', - driver, - true - ); - const stepChoiceXpath = By.xpath("//div[@data-testid='viz-step-choice']"); - await driver.wait(until.elementLocated(stepChoiceXpath)); - - await waitUntil( - async () => { - try { - await (await driver.findElement(stepChoiceXpath)).click(); - } 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='choice-add-when-button']")) - ); - await kaotoWebview.switchBack(); - }); -}); diff --git a/it-tests/Util.ts b/it-tests/Util.ts index 497d318e..f89c43a0 100644 --- a/it-tests/Util.ts +++ b/it-tests/Util.ts @@ -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']"))); } diff --git a/test Fixture with speci@l chars/emptyKameletBinding.kaoto.yaml b/test Fixture with speci@l chars/emptyKameletBinding.kaoto.yaml deleted file mode 100644 index 3874ec9a..00000000 --- a/test Fixture with speci@l chars/emptyKameletBinding.kaoto.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: camel.apache.org/v1alpha1 -kind: KameletBinding -metadata: - name: my-integration-name -spec: - source: null - sink: null diff --git a/test Fixture with speci@l chars/emptyPipe.kaoto.yaml b/test Fixture with speci@l chars/emptyPipe.kaoto.yaml new file mode 100644 index 00000000..96c83822 --- /dev/null +++ b/test Fixture with speci@l chars/emptyPipe.kaoto.yaml @@ -0,0 +1,7 @@ +apiVersion: camel.apache.org/v1 +kind: Pipe +metadata: + name: my-integration-name +spec: + source: {} + sink: {}