Skip to content

Commit

Permalink
test(list,menu,select)!: clean up internal testing patterns from harn…
Browse files Browse the repository at this point in the history
…esses

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
  • Loading branch information
Elliott Marquez authored and copybara-github committed Aug 31, 2023
1 parent 9647f5e commit fcfc696
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion list/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ListHarness extends Harness<List> {
*/
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. */
Expand Down
7 changes: 3 additions & 4 deletions menu/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class MenuHarness extends Harness<Menu> {
*/
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. */
Expand All @@ -32,9 +32,8 @@ export class MenuHarness extends Harness<Menu> {
(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;
}
Expand Down
4 changes: 1 addition & 3 deletions select/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export class SelectHarness extends Harness<Select> {
(item) => new SelectOptionHarness(item as typeof item&LitElement));
}

async click(quick = true) {
this.element.quick = quick;
await this.element.updateComplete;
async click() {
const field = await this.getField();
field.click();
}
Expand Down

0 comments on commit fcfc696

Please sign in to comment.