Skip to content

Commit

Permalink
test: test visual regression focus without waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed May 27, 2024
1 parent 1a28010 commit be8cfeb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/core/testing/private/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function visualRegressionFixture<T extends HTMLElement>(
const fix = await fixture<T>(
html`<div
style=${`padding: ${wrapperStyles?.padding ?? '2rem'};background-color: ${wrapperStyles?.backgroundColor ?? 'var(--sbb-color-white)'};${wrapperStyles?.focusOutlineDark ? ' --sbb-focus-outline-color: var(--sbb-focus-outline-color-dark);' : ''}`}
tabindex="1"
tabindex="0"

Check warning on line 94 in src/components/core/testing/private/fixture.ts

View check run for this annotation

Codecov / codecov/patch

src/components/core/testing/private/fixture.ts#L94

Added line #L94 was not covered by tests
>
${template}
</div>`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { aTimeout } from '@open-wc/testing';
import { resetMouse, sendKeys, sendMouse } from '@web/test-runner-commands';
import { visualDiff } from '@web/test-runner-visual-regression';

import { waitForCondition } from '../wait-for-condition.js';

export function imageName(test: Mocha.Runnable): string {
return test!.fullTitle().replaceAll(', ', '-').replaceAll(' ', '_');
}
Expand All @@ -30,12 +28,8 @@ export function testVisualDiff(snapshotElement: () => HTMLElement): void {

export function testVisualDiffFocus(snapshotElement: () => HTMLElement): void {
it('focus', async function () {
await waitForCondition(() => {
snapshotElement().focus();
return document.activeElement === snapshotElement();
});
snapshotElement().focus();

Check warning on line 31 in src/components/core/testing/private/visual-regression-snapshot.ts

View check run for this annotation

Codecov / codecov/patch

src/components/core/testing/private/visual-regression-snapshot.ts#L31

Added line #L31 was not covered by tests
await sendKeys({ press: 'Tab' });
await aTimeout(60);
await visualDiff(snapshotElement(), imageName(this.test!));
});
}
Expand Down

0 comments on commit be8cfeb

Please sign in to comment.