Skip to content

Commit

Permalink
chore(wdio): port delegates-foucs test suite to wdio
Browse files Browse the repository at this point in the history
port the `test/karma/test-app/delegates-focus` test suite to webdriverio.

git history has been preserved as much as possible here, using `git mv`
to move files from the `karma` dir to `wdio/` in all possible cases.
however, git may fail to mark some files as 'moved' if we change a file
enough that it exceeds git's "sameness threshold".
  • Loading branch information
rwaskiewicz committed Mar 14, 2024
1 parent 722a11c commit fae0532
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 59 deletions.
27 changes: 0 additions & 27 deletions test/karma/test-app/delegates-focus/index.html

This file was deleted.

32 changes: 0 additions & 32 deletions test/karma/test-app/delegates-focus/karma.spec.ts

This file was deleted.

48 changes: 48 additions & 0 deletions test/wdio/delegates-focus/cmp.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Fragment, h } from '@stencil/core';
import { render } from '@wdio/browser-runner/stencil';

describe('delegates-focus', function () {
beforeEach(() => {
render({
template: () => (
<>
<button onClick={setFocus}>Set Focus</button>
<hr />
<div>Delegate Focus Enabled:</div>
<delegates-focus class="set-focus"></delegates-focus>
<hr />
<div>Delegate Focus Not Enabled:</div>
<no-delegates-focus class="set-focus"></no-delegates-focus>
</>
),
});
function setFocus() {
const elms = document.querySelectorAll('.set-focus');
for (let i = 0; i < elms.length; i++) {
(elms[i] as HTMLElement).focus();
}
}
});

it('should delegate focus', async () => {
await $('delegates-focus').waitForExist();
await $('no-delegates-focus').waitForExist();

const delegatesFocus = document.querySelector('delegates-focus');
const noDelegatesFocus = document.querySelector('no-delegates-focus');

const delegateFocusStyles1 = window.getComputedStyle(delegatesFocus);
expect(delegateFocusStyles1.borderColor).toBe('rgb(255, 0, 0)');

const noDelegateFocusStyles1 = window.getComputedStyle(noDelegatesFocus);
expect(noDelegateFocusStyles1.borderColor).toBe('rgb(255, 0, 0)');

await $('button').click();

const delegateFocusStyles2 = window.getComputedStyle(delegatesFocus);
expect(delegateFocusStyles2.borderColor).toBe('rgb(0, 0, 255)');

const noDelegateFocusStyles2 = window.getComputedStyle(noDelegatesFocus);
expect(noDelegateFocusStyles2.borderColor).toBe('rgb(255, 0, 0)');
});
});

0 comments on commit fae0532

Please sign in to comment.