From 408eda8eb32a7abcccf67494466807ef4c702a82 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 7 Jun 2022 16:55:58 -0600 Subject: [PATCH] Fix some JS tests - Basic selectbox tests failed to set label --- api/js/etemplate/Et2Select/test/Et2SelectBasic.test.ts | 7 +++++-- api/js/etemplate/Et2Widget/Et2Widget.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Select/test/Et2SelectBasic.test.ts b/api/js/etemplate/Et2Select/test/Et2SelectBasic.test.ts index 8f33447fd9..f048b37d78 100644 --- a/api/js/etemplate/Et2Select/test/Et2SelectBasic.test.ts +++ b/api/js/etemplate/Et2Select/test/Et2SelectBasic.test.ts @@ -9,9 +9,10 @@ window.egw = { image: () => "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkViZW5lXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB3aWR0aD0iMzJweCIgaGVpZ2h0PSIzMnB4IiB2aWV3Qm94PSIwIDAgMzIgMzIiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDMyIDMyIiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBmaWxsPSIjNjk2OTY5IiBkPSJNNi45NDMsMjguNDUzDQoJYzAuOTA2LDAuNzY1LDIuMDk3LDEuMTI3LDMuMjg2LDEuMTA5YzAuNDMsMC4wMTQsMC44NTItMC4wNjgsMS4yNjUtMC4yMDdjMC42NzktMC4xOCwxLjMyOC0wLjQ1LDEuODY2LTAuOTAyTDI5LjQwMywxNC45DQoJYzEuNzcyLTEuNDk4LDEuNzcyLTMuOTI1LDAtNS40MjJjLTEuNzcyLTEuNDk3LTQuNjQ2LTEuNDk3LTYuNDE4LDBMMTAuMTE5LDIwLjM0OWwtMi4zODktMi40MjRjLTEuNDQtMS40NTctMy43NzItMS40NTctNS4yMTIsMA0KCWMtMS40MzgsMS40Ni0xLjQzOCwzLjgyNSwwLDUuMjgxQzIuNTE4LDIzLjIwNiw1LjQ3NCwyNi45NDcsNi45NDMsMjguNDUzeiIvPg0KPC9zdmc+DQo=", lang: i => i + "*", tooltipUnbind: () => {}, + webserverUrl: "" }; -import {assert, fixture, html} from '@open-wc/testing'; +import {assert, elementUpdated, fixture, html} from '@open-wc/testing'; import * as sinon from 'sinon'; import {inputBasicTests} from "../../Et2InputWidget/test/InputBasicTests"; import {Et2Select} from "../Et2Select"; @@ -43,9 +44,11 @@ describe("Select widget basics", () => assert.instanceOf(element, Et2Select); }); - it('has a label', () => + it('has a label', async() => { element.set_label("Label set"); + // @ts-ignore TypeScript doesn't recognize widgets as Elements + await elementUpdated(element); assert.equal(element.querySelector("[slot='label']").textContent, "Label set"); }) diff --git a/api/js/etemplate/Et2Widget/Et2Widget.ts b/api/js/etemplate/Et2Widget/Et2Widget.ts index f714b10eca..cdfeee3a1b 100644 --- a/api/js/etemplate/Et2Widget/Et2Widget.ts +++ b/api/js/etemplate/Et2Widget/Et2Widget.ts @@ -269,7 +269,7 @@ const Et2WidgetMixin = (superClass) => label.classList.add("et2_label"); label.textContent = this.__label; // We should have a slot in the template for the label - //label.slot="label"; + label.slot = "label"; this.appendChild(label); this.requestUpdate('label', oldValue); }