Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: add Mouse test util + update tests #975

Merged
merged 7 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 44 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
"@types/eslint__js": "8.42.3",
"@types/mocha": "^10.0.7",
"@web/dev-server-esbuild": "0.4.3",
"@web/test-runner": "0.18.2",
"@web/test-runner-commands": "^0.9.0",
"@web/test-runner": "0.19.0",
"@web/test-runner-commands": "0.9.0",
"@web/test-runner-playwright": "0.11.0",
"autoprefixer": "10.4.17",
"babel-loader": "9.1.3",
Expand Down
24 changes: 8 additions & 16 deletions packages/uui-color-swatch/lib/uui-color-swatch.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html, fixture, expect, elementUpdated } from '@open-wc/testing';
import { UUIColorSwatchElement } from './uui-color-swatch.element';
import { sendMouse, sendKeys } from '@web/test-runner-commands';
import { UUITestMouse } from '../../../test/index';

describe('UUIColorSwatchElement', () => {
let element: UUIColorSwatchElement;
Expand All @@ -20,42 +20,33 @@ describe('UUIColorSwatchElement', () => {
});

describe('selectable', () => {
const mouse = new UUITestMouse();

beforeEach(async () => {
element.selectable = true;
});

it('can be selected when selectable', async () => {
await elementUpdated(element);
await sendMouse({
type: 'click',
position: [15, 15],
button: 'left',
});
await mouse.leftClick(element);
expect(element.selected).to.be.true;
});

it('can not be selected when not selectable', async () => {
element.selectable = false;
await elementUpdated(element);
await sendMouse({
type: 'click',
position: [15, 15],
button: 'left',
});
await mouse.leftClick(element);
expect(element.selected).to.be.false;
});

it('cant be selected when disabled', async () => {
element.disabled = true;
await elementUpdated(element);
await sendMouse({
type: 'click',
position: [15, 15],
button: 'left',
});
await mouse.leftClick(element);
expect(element.selected).to.be.false;
});

/* TODO: temp commented out as they are flaky in webkit
it('can be selected with Space key', async () => {
await sendKeys({
press: 'Tab',
Expand Down Expand Up @@ -85,5 +76,6 @@ describe('UUIColorSwatchElement', () => {
});
expect(element.selected).to.be.false;
});
*/
});
});
Loading
Loading