From 786a1e4accfa72efd4d3741b5997b39fb90c9dca Mon Sep 17 00:00:00 2001 From: Lukas Lieb Date: Tue, 7 Jan 2025 08:15:13 +0100 Subject: [PATCH] wip --- .../src/components/widgets/select/Select.test.tsx | 4 ++-- packages/inscription-view/src/test-utils/combobox-utils.tsx | 2 +- packages/inscription-view/src/test-utils/setupTests.tsx | 2 +- packages/inscription-view/src/test-utils/test-utils.tsx | 2 +- playwright/tests/inscription/parts/output.ts | 4 ---- playwright/tests/page-objects/editor/element.ts | 5 ++++- playwright/tests/page-objects/editor/process-editor.ts | 5 ++++- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/inscription-view/src/components/widgets/select/Select.test.tsx b/packages/inscription-view/src/components/widgets/select/Select.test.tsx index 9a148e46e..1895ae333 100644 --- a/packages/inscription-view/src/components/widgets/select/Select.test.tsx +++ b/packages/inscription-view/src/components/widgets/select/Select.test.tsx @@ -63,11 +63,11 @@ describe('Select', () => { expect(screen.queryByRole('listbox')).not.toBeInTheDocument(); await userEvent.keyboard('[Enter]'); - expect(screen.queryByRole('listbox')).toBeInTheDocument(); + expect(screen.getByRole('listbox')).toBeInTheDocument(); await userEvent.keyboard('[Enter]'); expect(screen.queryByRole('listbox')).not.toBeInTheDocument(); await userEvent.keyboard('[Space]'); - expect(screen.queryByRole('listbox')).toBeInTheDocument(); + expect(screen.getByRole('listbox')).toBeInTheDocument(); const option1 = screen.getByRole('option', { name: 'label' }); const option2 = screen.getByRole('option', { name: 'test' }); diff --git a/packages/inscription-view/src/test-utils/combobox-utils.tsx b/packages/inscription-view/src/test-utils/combobox-utils.tsx index 0c15e2144..b71e039e2 100644 --- a/packages/inscription-view/src/test-utils/combobox-utils.tsx +++ b/packages/inscription-view/src/test-utils/combobox-utils.tsx @@ -12,7 +12,7 @@ export namespace ComboboxUtil { return screen.getByRole('combobox', { name: options.label }); } if (options?.nth !== undefined) { - return screen.getAllByRole('combobox').at(options.nth)!; + return screen.getAllByRole('combobox')[options.nth]; } return screen.getByRole('combobox'); } diff --git a/packages/inscription-view/src/test-utils/setupTests.tsx b/packages/inscription-view/src/test-utils/setupTests.tsx index d07199434..18f0f9df2 100644 --- a/packages/inscription-view/src/test-utils/setupTests.tsx +++ b/packages/inscription-view/src/test-utils/setupTests.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/ban-ts-comment */ /* eslint-disable @typescript-eslint/no-explicit-any */ // jest-dom adds custom jest matchers for asserting on DOM nodes. // allows you to do things like: @@ -13,7 +14,6 @@ afterEach(() => cleanup()); //@ts-ignore global.IntersectionObserver = class IntersectionObserver { - constructor() {} observe() { return null; } diff --git a/packages/inscription-view/src/test-utils/test-utils.tsx b/packages/inscription-view/src/test-utils/test-utils.tsx index ce3575c35..222b928e8 100644 --- a/packages/inscription-view/src/test-utils/test-utils.tsx +++ b/packages/inscription-view/src/test-utils/test-utils.tsx @@ -1,4 +1,4 @@ -/* eslint-disable import/export */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ import type { ElementData, ConfigData, diff --git a/playwright/tests/inscription/parts/output.ts b/playwright/tests/inscription/parts/output.ts index b12632361..364857eaf 100644 --- a/playwright/tests/inscription/parts/output.ts +++ b/playwright/tests/inscription/parts/output.ts @@ -77,10 +77,6 @@ class OutputCode extends Output { } class OutputEmptyMap extends OutputCode { - constructor(part: Part) { - super(part); - } - override async assertClear() { await this.mappingSection.expectIsClosed(); await this.codeSection.expectIsClosed(); diff --git a/playwright/tests/page-objects/editor/element.ts b/playwright/tests/page-objects/editor/element.ts index 13f18b81c..c39e8f52e 100644 --- a/playwright/tests/page-objects/editor/element.ts +++ b/playwright/tests/page-objects/editor/element.ts @@ -110,7 +110,10 @@ export class Element extends BaseElement { async getPosition() { const transform = await this.element.getAttribute('transform'); - const position = transform!.substring(transform!.indexOf('(') + 1, transform!.indexOf(')')); + if (!transform) { + throw new Error('Element has no transform'); + } + const position = transform.substring(transform.indexOf('(') + 1, transform.indexOf(')')); const x = parseInt(position.split(',')[0].trim(), 10); const y = parseInt(position.split(',')[1].trim(), 10); return { x: x, y: y }; diff --git a/playwright/tests/page-objects/editor/process-editor.ts b/playwright/tests/page-objects/editor/process-editor.ts index bac322ecf..6084b3092 100644 --- a/playwright/tests/page-objects/editor/process-editor.ts +++ b/playwright/tests/page-objects/editor/process-editor.ts @@ -148,7 +148,10 @@ export class ProcessEditor { const graph = this.page.locator('#sprotty'); await expect(graph).toBeVisible(); const bounds = await graph.boundingBox(); - await graph.click({ position: { x: bounds!.width - 20, y: bounds!.height - 80 } }); + if (!bounds) { + throw new Error('Graph has no bounds'); + } + await graph.click({ position: { x: bounds.width - 20, y: bounds.height - 80 } }); await expect(this.page.locator('g.selected')).toHaveCount(0); }