Skip to content

Commit

Permalink
Adapt UI test to new attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Pupier <[email protected]>
  • Loading branch information
apupier committed Dec 23, 2024
1 parent 9e1bd86 commit 973a5f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
30 changes: 18 additions & 12 deletions it-tests/BasicFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Kaoto basic development flow', function () {
await checkEmptyCanvasLoaded(driver);
await createNewRoute(driver);
await addActiveMQStep(driver);
await checkStepWithTestIdPresent(driver, 'custom-node__activemq');
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__activemq', 'activemq');

await kaotoWebview.switchBack();
assert.isTrue(
Expand All @@ -104,7 +104,7 @@ describe('Kaoto basic development flow', function () {
true
));
globalKaotoWebView = kaotoWebview;
await checkStepWithTestIdPresent(driver, 'custom-node__activemq');
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__activemq', 'activemq');
await kaotoWebview.switchBack();
});

Expand All @@ -116,8 +116,8 @@ describe('Kaoto basic development flow', function () {
true
);
globalKaotoWebView = kaotoWebview;
await checkStepWithTestIdPresent(driver, 'custom-node__timer');
await checkStepWithTestIdPresent(driver, 'custom-node__log');
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__timer', 'timer');
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__log', 'log');
await kaotoWebview.switchBack();
assert.isFalse(
await kaotoEditor.isDirty(),
Expand All @@ -133,9 +133,9 @@ describe('Kaoto basic development flow', function () {
true
);
globalKaotoWebView = kaotoWebview;
await checkStepWithTestIdPresent(driver, 'custom-node__timer');
await checkStepWithTestIdPresent(driver, 'custom-node__https');
await checkStepWithTestIdPresent(driver, 'custom-node__kamelet:sink');
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__timer', 'timer');
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__https', 'https');
await checkStepWithTestIdOrNodeLabelPresent(driver, 'custom-node__kamelet:sink', 'kamelet:sink');
await kaotoWebview.switchBack();
assert.isFalse(
await kaotoEditor.isDirty(),
Expand All @@ -151,10 +151,10 @@ async function createNewRoute(driver: WebDriver) {

async function addActiveMQStep(driver: WebDriver) {
await driver.wait(
until.elementLocated(By.css('g[data-testid^="custom-node__timer"]'))
);
until.elementLocated(By.css('g[data-testid^="custom-node__timer"],g[data-testid="custom-node__route.from"]'))
, 5000, 'Cannot find the node for the timer');

const canvasNode = await driver.findElement(By.css('g[data-testid^="custom-node__timer"]'));
const canvasNode = await driver.findElement(By.css('g[data-testid^="custom-node__timer"],g[data-testid="custom-node__route.from"]'));
await driver.actions().contextClick(canvasNode).perform();

await driver.wait(
Expand All @@ -168,9 +168,15 @@ async function addActiveMQStep(driver: WebDriver) {
await (await driver.findElement(By.xpath("//div[@data-testid='tile-activemq']"))).click();
}

async function checkStepWithTestIdPresent(driver: WebDriver, testId: string) {
/**
*
* @param driver
* @param testId used for Kaoto 2.3
* @param nodeLabel used for Kaoto 2.4
*/
async function checkStepWithTestIdOrNodeLabelPresent(driver: WebDriver, testId: string, nodeLabel: string) {
await driver.wait(
until.elementLocated(By.xpath(`//\*[name()='g' and starts-with(@data-testid,'${testId}')]`)
until.elementLocated(By.xpath(`//\*[name()='g' and starts-with(@data-testid,'${testId}') or @data-nodelabel='${nodeLabel}']`)
), 5_000);
}

Expand Down
11 changes: 8 additions & 3 deletions it-tests/settings/NodeLabelSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ describe('User Settings', function () {

const locators = {
TimerComponent: {
timer: `g[data-id^='timer'][data-kind='node']`,
timer_2_3: `g[data-id^='timer'][data-kind='node']`,
timer_2_4: `g[data-nodelabel='timerID']`,
label: `.custom-node__label`,
}
}
Expand Down Expand Up @@ -63,8 +64,12 @@ describe('User Settings', function () {

it(`Check 'id' Node Label is used instead of default 'description'`, async function () {
this.timeout(60_000);

const timer = await driver.findElement(By.css(`${locators.TimerComponent.timer} ${locators.TimerComponent.label}`));
let timer;
try {
timer = await driver.findElement(By.css(`${locators.TimerComponent.timer_2_3} ${locators.TimerComponent.label}`));
} catch {
timer = await driver.findElement(By.css(`${locators.TimerComponent.timer_2_4} ${locators.TimerComponent.label}`));
}
const label = await timer.getText();

expect(label.split('\n')).to.contains('timerID');
Expand Down

0 comments on commit 973a5f2

Please sign in to comment.