Skip to content

Commit 9e83223

Browse files
authored
test: add Aura visual tests for custom-field and field-highlighter (#10922)
1 parent a29454f commit 9e83223

File tree

10 files changed

+80
-0
lines changed

10 files changed

+80
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { fixtureSync } from '@vaadin/testing-helpers';
2+
import { visualDiff } from '@web/test-runner-visual-regression';
3+
import '@vaadin/aura/aura.css';
4+
import '../common.js';
5+
import '../../../vaadin-custom-field.js';
6+
7+
describe('custom-field', () => {
8+
describe('basic', () => {
9+
let div, element;
10+
11+
beforeEach(() => {
12+
div = document.createElement('div');
13+
div.style.display = 'inline-block';
14+
div.style.padding = '10px';
15+
16+
element = fixtureSync(
17+
`
18+
<vaadin-custom-field>
19+
<input type="text" />
20+
<input type="number" />
21+
</vaadin-custom-field>
22+
`,
23+
div,
24+
);
25+
});
26+
27+
it('basic', async () => {
28+
await visualDiff(div, 'default');
29+
});
30+
31+
it('label', async () => {
32+
element.label = 'Home address';
33+
await visualDiff(div, 'label');
34+
});
35+
});
36+
});
3.64 KB
Loading
6.96 KB
Loading
3.25 KB
Loading
6.43 KB
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { sendKeys } from '@vaadin/test-runner-commands';
2+
import { fixtureSync, mousedown, nextFrame } from '@vaadin/testing-helpers';
3+
import { visualDiff } from '@web/test-runner-visual-regression';
4+
import '../common.js';
5+
import '@vaadin/aura/aura.css';
6+
import '@vaadin/text-field';
7+
import '../../../src/vaadin-field-highlighter.js';
8+
import { setUsers } from '../helpers.js';
9+
10+
describe('field-highlighter', () => {
11+
let div, element;
12+
13+
beforeEach(() => {
14+
div = document.createElement('div');
15+
div.style.display = 'inline-block';
16+
div.style.padding = '20px';
17+
div.style.height = '150px';
18+
});
19+
20+
afterEach(() => {
21+
// After tests which use sendKeys() the focus-utils.js -> isKeyboardActive is set to true.
22+
// Click once here on body to reset it so other tests are not affected by it.
23+
// An unwanted focus-ring would be shown in other tests otherwise.
24+
mousedown(document.body);
25+
});
26+
27+
describe('text-field', () => {
28+
beforeEach(async () => {
29+
element = fixtureSync(`<vaadin-text-field></vaadin-text-field>`, div);
30+
setUsers(element);
31+
await nextFrame();
32+
});
33+
34+
it('default', async () => {
35+
await visualDiff(div, 'text-field');
36+
});
37+
38+
it('focused', async () => {
39+
await sendKeys({ press: 'Tab' });
40+
await nextFrame();
41+
await visualDiff(div, 'text-field-focused');
42+
});
43+
});
44+
});
10.6 KB
Loading
10.7 KB
Loading
10.8 KB
Loading
10.8 KB
Loading

0 commit comments

Comments
 (0)