Skip to content

Commit fd7dfd5

Browse files
Chore: add Mouse test util + update tests (#975)
* add test mouse util * use test mouse util * upgrade test runner to latest * round the position * use relative imports * temp comment out keyboard test * add very basic selectable tests for table row
1 parent 29855fa commit fd7dfd5

File tree

6 files changed

+213
-90
lines changed

6 files changed

+213
-90
lines changed

package-lock.json

+44-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
"@types/eslint__js": "8.42.3",
8282
"@types/mocha": "^10.0.7",
8383
"@web/dev-server-esbuild": "0.4.3",
84-
"@web/test-runner": "0.18.2",
85-
"@web/test-runner-commands": "^0.9.0",
84+
"@web/test-runner": "0.19.0",
85+
"@web/test-runner-commands": "0.9.0",
8686
"@web/test-runner-playwright": "0.11.0",
8787
"autoprefixer": "10.4.17",
8888
"babel-loader": "9.1.3",

packages/uui-color-swatch/lib/uui-color-swatch.test.ts

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { html, fixture, expect, elementUpdated } from '@open-wc/testing';
22
import { UUIColorSwatchElement } from './uui-color-swatch.element';
3-
import { sendMouse, sendKeys } from '@web/test-runner-commands';
3+
import { UUITestMouse } from '../../../test/index';
44

55
describe('UUIColorSwatchElement', () => {
66
let element: UUIColorSwatchElement;
@@ -20,42 +20,33 @@ describe('UUIColorSwatchElement', () => {
2020
});
2121

2222
describe('selectable', () => {
23+
const mouse = new UUITestMouse();
24+
2325
beforeEach(async () => {
2426
element.selectable = true;
2527
});
2628

2729
it('can be selected when selectable', async () => {
2830
await elementUpdated(element);
29-
await sendMouse({
30-
type: 'click',
31-
position: [15, 15],
32-
button: 'left',
33-
});
31+
await mouse.leftClick(element);
3432
expect(element.selected).to.be.true;
3533
});
3634

3735
it('can not be selected when not selectable', async () => {
3836
element.selectable = false;
3937
await elementUpdated(element);
40-
await sendMouse({
41-
type: 'click',
42-
position: [15, 15],
43-
button: 'left',
44-
});
38+
await mouse.leftClick(element);
4539
expect(element.selected).to.be.false;
4640
});
4741

4842
it('cant be selected when disabled', async () => {
4943
element.disabled = true;
5044
await elementUpdated(element);
51-
await sendMouse({
52-
type: 'click',
53-
position: [15, 15],
54-
button: 'left',
55-
});
45+
await mouse.leftClick(element);
5646
expect(element.selected).to.be.false;
5747
});
5848

49+
/* TODO: temp commented out as they are flaky in webkit
5950
it('can be selected with Space key', async () => {
6051
await sendKeys({
6152
press: 'Tab',
@@ -85,5 +76,6 @@ describe('UUIColorSwatchElement', () => {
8576
});
8677
expect(element.selected).to.be.false;
8778
});
79+
*/
8880
});
8981
});

0 commit comments

Comments
 (0)