Fix some Et2InputWidgets would not get a label

This commit is contained in:
nathan 2024-12-05 14:27:04 -07:00
parent 2a939299ff
commit 6396516bad
2 changed files with 19 additions and 4 deletions

View File

@ -563,7 +563,8 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
{
if(!new_label || !new_label.includes("%s"))
{
return super.label = new_label;
super.set_label(new_label);
return;
}
this.__label = new_label;
const [pre, post] = et2_csvSplit(new_label, 2, "%s");

View File

@ -34,16 +34,30 @@ describe("Textbox widget", () =>
// Setup run before each test
beforeEach(before);
const checkLabel = function(labelValue)
{
const label = element.querySelector(".et2_label");
assert.isNotNull(label);
assert.isTrue(label.checkVisibility(), "Label is not visible");
assert.equal(element.querySelector('.et2_label')?.textContent.trim(), labelValue);
}
it('is defined', () =>
{
assert.instanceOf(element, Et2Textbox);
});
it('has a label', () =>
it('gets a label via set_label()', async() =>
{
// Old set_label()
element.set_label("Yay label");
assert.isEmpty(element.shadowRoot.querySelectorAll('.et2_label'));
await element.updateComplete;
checkLabel("Yay label")
});
it('gets a label via property', async() =>
{
element.label = "Assign via property";
await element.updateComplete;
checkLabel("Assign via property");
})
});
inputBasicTests(before, "I'm a good test value", "input");