From fcfc696c4628fd2f41b09c060e6af4cd8e7658c2 Mon Sep 17 00:00:00 2001 From: Elliott Marquez Date: Thu, 31 Aug 2023 13:33:50 -0700 Subject: [PATCH] test(list,menu,select)!: clean up internal testing patterns from harnesses lots of hard coded stuff to enable our tests. Cleaning this up for generalized client usage. BREAKING CHANGE: menu harnesses will not automatically open menus in quick mode anymore and interactions in menu and list harnesses will not automatically go to the first item but rather the menu roots. PiperOrigin-RevId: 561746073 --- list/harness.ts | 2 +- menu/harness.ts | 7 +++---- select/harness.ts | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/list/harness.ts b/list/harness.ts index 2c20971d1e..84430a4c9a 100644 --- a/list/harness.ts +++ b/list/harness.ts @@ -35,7 +35,7 @@ export class ListHarness extends Harness { */ protected override async getInteractiveElement() { await this.element.updateComplete; - return (await this.getItems())[0].getInteractiveElement(); + return this.element.renderRoot.querySelector('.list') as HTMLElement; } /** @return List item harnesses. */ diff --git a/menu/harness.ts b/menu/harness.ts index e083700de0..6e15f92f51 100644 --- a/menu/harness.ts +++ b/menu/harness.ts @@ -22,8 +22,8 @@ export class MenuHarness extends Harness { */ protected override async getInteractiveElement() { await this.element.updateComplete; - await this.show(); - return (await this.getItems())[0].getInteractiveElement(); + return this.element.renderRoot.querySelector('md-list')!.renderRoot + .querySelector('.list') as HTMLElement; } /** @return ListItem harnesses for the menu's items. */ @@ -32,9 +32,8 @@ export class MenuHarness extends Harness { (item) => new MenuItemHarness(item as typeof item&LitElement)); } - async show(quick = true) { + async show() { const menu = this.element; - menu.quick = quick; if (menu.open) { return; } diff --git a/select/harness.ts b/select/harness.ts index e2e364d0cd..a9a8314610 100644 --- a/select/harness.ts +++ b/select/harness.ts @@ -41,9 +41,7 @@ export class SelectHarness extends Harness