* web: bump ws, @wdio/browser-runner and @wdio/cli in /web Bumps [ws](https://github.com/websockets/ws) to 8.18.0 and updates ancestor dependencies [ws](https://github.com/websockets/ws), [@wdio/browser-runner](https://github.com/webdriverio/webdriverio/tree/HEAD/packages/wdio-browser-runner) and [@wdio/cli](https://github.com/webdriverio/webdriverio/tree/HEAD/packages/wdio-cli). These dependencies need to be updated together. Updates `ws` from 8.16.0 to 8.18.0 - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.16.0...8.18.0) Updates `@wdio/browser-runner` from 8.40.2 to 9.0.9 - [Release notes](https://github.com/webdriverio/webdriverio/releases) - [Changelog](https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md) - [Commits](https://github.com/webdriverio/webdriverio/commits/v9.0.9/packages/wdio-browser-runner) Updates `@wdio/cli` from 8.40.2 to 9.0.9 - [Release notes](https://github.com/webdriverio/webdriverio/releases) - [Changelog](https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md) - [Commits](https://github.com/webdriverio/webdriverio/commits/v9.0.9/packages/wdio-cli) --- updated-dependencies: - dependency-name: ws dependency-type: indirect - dependency-name: "@wdio/browser-runner" dependency-type: direct:development - dependency-name: "@wdio/cli" dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
109 lines
4.0 KiB
TypeScript
109 lines
4.0 KiB
TypeScript
import { $, browser, expect } from "@wdio/globals";
|
|
import { slug } from "github-slugger";
|
|
import { Key } from "webdriverio";
|
|
|
|
import { html, render } from "lit";
|
|
|
|
import "../ak-search-select-view.js";
|
|
import { sampleData } from "../stories/sampleData.js";
|
|
import { AkSearchSelectViewDriver } from "./ak-search-select-view.comp.js";
|
|
|
|
const longGoodForYouPairs = {
|
|
grouped: false,
|
|
options: sampleData.map(({ produce }) => [slug(produce), produce]),
|
|
};
|
|
|
|
describe("Search select: Test Input Field", () => {
|
|
let select: AkSearchSelectViewDriver;
|
|
|
|
beforeEach(async () => {
|
|
render(
|
|
html`<ak-search-select-view .options=${longGoodForYouPairs}> </ak-search-select-view>`,
|
|
document.body,
|
|
);
|
|
select = await AkSearchSelectViewDriver.build(
|
|
await $("ak-search-select-view").getElement(),
|
|
);
|
|
});
|
|
|
|
it("should open the menu when the input is clicked", async () => {
|
|
expect(await select.open).toBe(false);
|
|
expect(await select.menuIsVisible()).toBe(false);
|
|
await select.clickInput();
|
|
expect(await select.open).toBe(true);
|
|
// expect(await select.menuIsVisible()).toBe(true);
|
|
});
|
|
|
|
it("should not open the menu when the input is focused", async () => {
|
|
expect(await select.open).toBe(false);
|
|
await select.focusOnInput();
|
|
expect(await select.open).toBe(false);
|
|
expect(await select.menuIsVisible()).toBe(false);
|
|
});
|
|
|
|
it("should close the menu when the input is clicked a second time", async () => {
|
|
expect(await select.open).toBe(false);
|
|
expect(await select.menuIsVisible()).toBe(false);
|
|
await select.clickInput();
|
|
expect(await select.menuIsVisible()).toBe(true);
|
|
expect(await select.open).toBe(true);
|
|
await select.clickInput();
|
|
expect(await select.open).toBe(false);
|
|
expect(await select.open).toBe(false);
|
|
});
|
|
|
|
it("should open the menu from a focused but closed input when a search is begun", async () => {
|
|
expect(await select.open).toBe(false);
|
|
await select.focusOnInput();
|
|
expect(await select.open).toBe(false);
|
|
expect(await select.menuIsVisible()).toBe(false);
|
|
await browser.keys("A");
|
|
select = await AkSearchSelectViewDriver.build(
|
|
await $("ak-search-select-view").getElement(),
|
|
);
|
|
expect(await select.open).toBe(true);
|
|
expect(await select.menuIsVisible()).toBe(true);
|
|
});
|
|
|
|
it("should update the list as the user types", async () => {
|
|
await select.focusOnInput();
|
|
await browser.keys("Ap");
|
|
await expect(await select.menuIsVisible()).toBe(true);
|
|
const elements = Array.from(await select.listElements());
|
|
await expect(elements.length).toBe(2);
|
|
});
|
|
|
|
it("set the value when a match is close", async () => {
|
|
await select.focusOnInput();
|
|
await browser.keys("Ap");
|
|
await expect(await select.menuIsVisible()).toBe(true);
|
|
const elements = Array.from(await select.listElements());
|
|
await expect(elements.length).toBe(2);
|
|
await browser.keys(Key.Tab);
|
|
await expect(await (await select.input()).getValue()).toBe("Apples");
|
|
});
|
|
|
|
it("should close the menu when the user clicks away", async () => {
|
|
document.body.insertAdjacentHTML(
|
|
"afterbegin",
|
|
'<input id="a-separate-component" type="text" />',
|
|
);
|
|
const input = await browser.$("#a-separate-component");
|
|
|
|
await select.clickInput();
|
|
expect(await select.open).toBe(true);
|
|
await input.click();
|
|
expect(await select.open).toBe(false);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
document.body.querySelector("#a-separate-component")?.remove();
|
|
document.body.querySelector("ak-search-select-view")?.remove();
|
|
// @ts-expect-error expression of type '"_$litPart$"' is added by Lit
|
|
if (document.body["_$litPart$"]) {
|
|
// @ts-expect-error expression of type '"_$litPart$"' is added by Lit
|
|
delete document.body["_$litPart$"];
|
|
}
|
|
});
|
|
});
|