feat(web): a couple of .sortedInputs unit tests

This commit is contained in:
Joshua A. Horton 2023-04-28 12:38:43 +07:00
parent 07b5c1f83d
commit db0dc335de
2 changed files with 65 additions and 3 deletions

View file

@ -556,10 +556,67 @@ describe.only('KMW element-attachment logic', function () {
});
});
describe.skip("sortedList: tests for expected ordering", () => {
it('todo: straightforward, standard layout', () => {});
describe("sortedList: tests for expected ordering", () => {
beforeEach(function() {
this.attacher = new PageContextAttachment(window.document, STANDARD_OPTIONS);
fixture.setBase('fixtures');
});
it('todo: tricky layout with absolute positioning', () => {});
afterEach(function() {
fixture.cleanup();
this.attacher?.shutdown();
this.attacher = null;
});
it('straightforward, standard layout', async function () {
fixture.load("a-bit-of-everything.html");
const attacher = this.attacher;
let attached = [];
// Note: iframes require additional time to resolve.
await promiseForIframeLoad(document.getElementById('iframe'));
attacher.on('enabled', (elem) => attached.push(elem));
attacher.install(false);
assert.sameMembers(attached.map((elem) => elem.id), ['iframe-input', 'editable', 'input', 'textarea']);
// At this time, `.sortedInputs` never includes iframe-embedded elements, design-iframes,
// or content-editables. (This matches KMW 16.0 + before behavior.)
assert.sameOrderedMembers(attacher.sortedInputs.map((elem) => elem.id), ['input', 'textarea']);
attacher.shutdown();
});
it('tricky layout with absolute positioning', function () {
fixture.load("wild-absolute-positioning.html");
const attacher = this.attacher;
let attached = [];
attacher.on('enabled', (elem) => attached.push(elem));
attacher.install(false);
// Numerals: the order of their definition within the HTML fixture.
// Directionals: the actual positioning on the page.
const elements = [
"input1-middle",
"input2-top-right",
"input3-bottom-left",
"input4-top-left",
"input5-bottom-right"
];
assert.sameMembers(attached.map((elem) => elem.id), elements);
// Top to bottom, left to right.
assert.sameOrderedMembers(attacher.sortedInputs.map((elem) => elem.id), [
"input4-top-left",
"input2-top-right",
"input1-middle",
"input3-bottom-left",
"input5-bottom-right"
]);
attacher.shutdown();
});
});
describe.skip("maintenance of site-intended .inputMode", () => {

View file

@ -0,0 +1,5 @@
<input id="input1-middle" style="position: absolute; left:40%; top:50%; width:20%"/>
<input id="input2-top-right" style="position: absolute; right:0%; top:0%"/>
<input id="input3-bottom-left" style="position: absolute; left:0%; bottom:0%"/>
<input id="input4-top-left" style="position: absolute; left:0%; top:0%"/>
<input id="input5-bottom-right" style="position: absolute; right:0%; bottom:0%"/>