Skip to content

Commit c8f1ce3

Browse files
committed
make tests more robust and revert some original behavior
1 parent a56d52e commit c8f1ce3

4 files changed

Lines changed: 26 additions & 19 deletions

File tree

meta_configurator/e2e/panelGuiEditor.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ test('Edit the feature testing example schema using the GUI Editor, testing basi
3232

3333
// Set the heightInMeter property to the value 10
3434
await editNumberOrIntProperty(page, ['heightInMeter'], 10)
35+
await expect
36+
.poll(async () => (await tpGetData(page, SessionMode.DataEditor)).heightInMeter)
37+
.toBe(10)
3538

3639
// Expect a Schema Violation Symbol because the height value is invalid
3740
await checkPropertySchemaViolation(page, ['heightInMeter'], true)
@@ -142,4 +145,4 @@ test('Change the GUI editor content and check if the internal data is updated pr
142145
// Validate that the internal data is updated correctly
143146
const dataAfterNameEnter = await tpGetData(page, SessionMode.DataEditor);
144147
expect(dataAfterNameEnter).toEqual({ name: 'Alex', address: { city: 'Berlin' } });
145-
});
148+
});

meta_configurator/e2e/utilsGuiEditor.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {Page} from "playwright";
22
import {expect} from "@playwright/test";
33
import {Path, PathElement} from "../src/utility/path";
44
import {pathToString} from "../src/utility/pathUtils";
5-
import {selectAll} from "./utils";
65

76

87
export async function checkPropertyExistence(page: Page, propertyPath: Path, shouldBeVisible: boolean) {
@@ -40,21 +39,24 @@ export async function editNumberOrIntProperty(page: Page, propertyPath: Path, va
4039
const pathAsString = pathToString(propertyPath);
4140
const spinButton = page.getByTestId(`property-data-${pathAsString}`).getByRole('spinbutton')
4241
await spinButton.click();
43-
await selectAll(page);
44-
await spinButton.press('Backspace');
45-
46-
// Simulate real typing
47-
for (const char of value.toString()) {
48-
await page.keyboard.press(char);
49-
}
50-
51-
await spinButton.press('Enter');
42+
await spinButton.evaluate((input, newValue) => {
43+
const nativeValueSetter = Object.getOwnPropertyDescriptor(
44+
window.HTMLInputElement.prototype,
45+
'value'
46+
)?.set;
47+
nativeValueSetter?.call(input, String(newValue));
48+
input.dispatchEvent(new Event('input', {bubbles: true}));
49+
input.setAttribute('aria-valuenow', String(newValue));
50+
}, value);
51+
await spinButton.blur();
5252
}
5353

5454
export async function checkNumberOrIntProperty(page: Page, propertyPath: Path, value: number) {
5555
const pathAsString = pathToString(propertyPath);
5656
const textField = page.getByTestId(`property-data-${pathAsString}`).getByRole('spinbutton')
57-
await expect(textField).toHaveValue(value.toString());
57+
await expect
58+
.poll(async () => await textField.getAttribute('aria-valuenow'))
59+
.toBe(value.toString());
5860
}
5961

6062
export async function removeOptionalPropertyValue(page: Page, propertyPath: Path) {
@@ -77,9 +79,11 @@ export async function addArrayItem(page: Page, propertyPath: Path) {
7779

7880
export async function checkPropertySchemaViolation(page: Page, propertyPath: Path, shouldBeVisible: boolean) {
7981
const pathAsString = pathToString(propertyPath);
80-
const validationErrorIcon = page.getByTestId(`property-metadata-${pathAsString}`).getByTestId("validation-error-icon");
82+
const propertyMetadata = page.getByTestId(`property-metadata-${pathAsString}`);
83+
const validationErrorIcon = propertyMetadata.getByTestId("validation-error-icon");
8184
if (shouldBeVisible) {
82-
await expect(validationErrorIcon).toBeVisible();
85+
await expect(propertyMetadata).toBeVisible();
86+
await expect(validationErrorIcon).toBeVisible({timeout: 8000});
8387
} else {
8488
await expect(validationErrorIcon).not.toBeVisible();
8589
}
@@ -101,4 +105,4 @@ export async function expandOrCollapseProperty(page: Page, propertyPathElement:
101105
// do check if the name starts with the propertyName, but ignore the other part of the name, as it can differ always depending on the children count
102106
const expansionButton = page.getByRole('cell', { name: new RegExp(`^${propertyPathElement} :`) }).getByRole('button');
103107
await expansionButton.click();
104-
}
108+
}

meta_configurator/src/components/CombinedEditorComponent.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ let panelsDefinition: SettingsInterfacePanels = settings.value.panels;
3737
// any setting is changed, which is not necessary and leads to Ace Editor becoming blank if settings were modified via
3838
// Ace Editor
3939
watchImmediate(
40-
() => settings.value,
41-
newSettings => {
42-
const panels = newSettings.panels;
40+
() => settings,
41+
settings => {
42+
const panels = settings.value.panels;
4343
if (JSON.stringify(panels) !== JSON.stringify(panelsDefinition)) {
4444
panelsDefinition = panels;
4545
}

meta_configurator/src/components/toolbar/ModeSelector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function onTabChange(event: {index: number}) {
6868
const idx = event.index;
6969
const item = tabs.value[idx];
7070
if (item?.command) {
71-
item.command({originalEvent: new Event('tab-change'), item});
71+
(item.command as () => void)();
7272
}
7373
}
7474
</script>

0 commit comments

Comments
 (0)