diff --git a/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts b/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts index f9329106b9..fa2ed4583b 100644 --- a/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts +++ b/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts @@ -29,7 +29,11 @@ import {Et2VfsPath} from "./Et2VfsPath"; * @summary Select files (including directories) from the VFS * @since 23.1 * + * @dependency et2-box + * @dependency et2-button * @dependency et2-dialog + * @dependency et2-image + * @dependency et2-searchbox * @dependency et2-select * @dependency et2-vfs-select-row * diff --git a/api/js/etemplate/Et2Vfs/test/Et2VfsDialog.test.ts b/api/js/etemplate/Et2Vfs/test/Et2VfsDialog.test.ts new file mode 100644 index 0000000000..c809b1f9c6 --- /dev/null +++ b/api/js/etemplate/Et2Vfs/test/Et2VfsDialog.test.ts @@ -0,0 +1,71 @@ +import {elementUpdated, fixture, html} from '@open-wc/testing'; +import * as sinon from 'sinon'; +import {Et2VfsSelectDialog} from "../Et2VfsSelectDialog"; + +/** + * Test file for Etemplate webComponent Et2VfsSelectDialog + * + */ +window.egw = { + ajaxUrl: () => "", + app: () => "addressbook", + decodePath: (_path : string) => _path, + encodePath: (_path : string) => _path, + image: () => "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkViZW5lXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB3aWR0aD0iMzJweCIgaGVpZ2h0PSIzMnB4IiB2aWV3Qm94PSIwIDAgMzIgMzIiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDMyIDMyIiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBmaWxsPSIjNjk2OTY5IiBkPSJNNi45NDMsMjguNDUzDQoJYzAuOTA2LDAuNzY1LDIuMDk3LDEuMTI3LDMuMjg2LDEuMTA5YzAuNDMsMC4wMTQsMC44NTItMC4wNjgsMS4yNjUtMC4yMDdjMC42NzktMC4xOCwxLjMyOC0wLjQ1LDEuODY2LTAuOTAyTDI5LjQwMywxNC45DQoJYzEuNzcyLTEuNDk4LDEuNzcyLTMuOTI1LDAtNS40MjJjLTEuNzcyLTEuNDk3LTQuNjQ2LTEuNDk3LTYuNDE4LDBMMTAuMTE5LDIwLjM0OWwtMi4zODktMi40MjRjLTEuNDQtMS40NTctMy43NzItMS40NTctNS4yMTIsMA0KCWMtMS40MzgsMS40Ni0xLjQzOCwzLjgyNSwwLDUuMjgxQzIuNTE4LDIzLjIwNiw1LjQ3NCwyNi45NDcsNi45NDMsMjguNDUzeiIvPg0KPC9zdmc+DQo=", + jsonq: () => Promise.resolve({}), + lang: i => i + "*", + link: i => i, + preference: i => "", + tooltipUnbind: () => {}, + webserverUrl: "", +}; + +let element : Et2VfsSelectDialog; + +async function before() +{ + // Create an element to test with, and wait until it's ready + // @ts-ignore + element = await fixture(html` + + + `); + + // Stub egw() + sinon.stub(element, "egw").returns(window.egw); + await elementUpdated(element); + + return element; +} + +/** Cannot use automatic testing as Et2Dialog still uses old widgets, which break all the includes + * + +describe("Vfs Select Dialog widget basics", () => +{ + + // Setup run before each test + beforeEach(before); + + // Make sure it works + it('is defined', () => + { + assert.instanceOf(element, Et2VfsSelectDialog); + }); + + it('has a title', async() => + { + element.title = "Title set"; + await elementUpdated(element); + + assert.equal(element.querySelector("[slot='title']").textContent, "Label set"); + }); + + it("Search gets focus when widget is focused", async() => + { + element.focus(); + await elementUpdated(element); + assert.equal(element.shadowRoot.activeElement, element._searchNode, "Search did not get focus when widget got focus"); + }); +}); + */ \ No newline at end of file