Skip to content

Commit cf70a05

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[test] Fix types for selectors
Bug: none Change-Id: I84974d640a005fbbf0f1aed3c802202731b40381 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6404073 Commit-Queue: Benedikt Meurer <[email protected]> Auto-Submit: Nikolay Vitkov <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]>
1 parent 0a63c31 commit cf70a05

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

front_end/ui/legacy/components/data_grid/DataGridElement.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,12 @@ class DataGridElementNode extends SortableDataGridNode<DataGridElementNode> {
505505

506506
customElements.define('devtools-data-grid', DataGridElement);
507507

508+
declare global {
509+
interface HTMLElementTagNameMap {
510+
'devtools-data-grid': DataGridElement;
511+
}
512+
}
513+
508514
function hasBooleanAttribute(element: Element, name: string): boolean {
509515
return element.hasAttribute(name) && element.getAttribute(name) !== 'false';
510516
}

test/e2e/application/window-controls_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('The Window Controls Overlay', () => {
2929

3030
// Verify selecting an option
3131
void selectOption(await controlsDropDown.toElement('select'), 'Linux');
32-
const selectedOption = await controlsDropDown.evaluate(input => (input as HTMLInputElement).value);
32+
const selectedOption = await controlsDropDown.evaluate(input => input.value);
3333
assert.strictEqual(selectedOption, 'Linux');
3434

3535
// Verify clicking the checkbox

test/e2e/helpers/datagrid-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function getDataGridRows(
2424
});
2525
})();
2626

27-
return await Promise.all(handlers.map(handler => $$<HTMLTableCellElement>('td[jslog]:not(.hidden)', handler)));
27+
return await Promise.all(handlers.map(handler => $$('td[jslog]:not(.hidden)', handler)));
2828
}
2929

3030
export async function getDataGrid(root?: ElementHandle) {

test/e2e_non_hosted/shared/frontend-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ export class DevToolsPage extends PageWrapper {
151151
});
152152
}
153153

154-
async waitFor<ElementType extends Element = Element>(
155-
selector: string, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(), handler?: string) {
154+
async waitFor<ElementType extends Element|null = null, Selector extends string = string>(
155+
selector: Selector, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(), handler?: string) {
156156
return await asyncScope.exec(() => this.waitForFunction(async () => {
157157
const element = await this.$<ElementType, typeof selector>(selector, root, handler);
158158
return (element || undefined);

test/shared/helper.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,26 +224,26 @@ export const getVisibleTextContents = async (selector: string) => {
224224
return texts.filter(content => typeof (content) === 'string');
225225
};
226226

227-
export const waitFor = async<ElementType extends Element = Element>(
228-
selector: string, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(), handler?: string) => {
227+
export const waitFor = async<ElementType extends Element|null = null, Selector extends string = string>(
228+
selector: Selector, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(), handler?: string) => {
229229
const {devToolsPage} = getBrowserAndPagesWrappers();
230-
return await devToolsPage.waitFor<ElementType>(selector, root, asyncScope, handler);
230+
return await devToolsPage.waitFor<ElementType, Selector>(selector, root, asyncScope, handler);
231231
};
232232

233-
export const waitForVisible = async<ElementType extends Element = Element>(
234-
selector: string, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(), handler?: string) => {
233+
export const waitForVisible = async<ElementType extends Element|null = null, Selector extends string = string>(
234+
selector: Selector, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(), handler?: string) => {
235235
return await asyncScope.exec(() => waitForFunction(async () => {
236236
const element = await $<ElementType, typeof selector>(selector, root, handler);
237237
const visible = await element.evaluate(node => node.checkVisibility());
238238
return visible ? element : undefined;
239239
}, asyncScope), `Waiting for element matching selector '${selector}' to be visible`);
240240
};
241241

242-
export const waitForMany = async (
243-
selector: string, count: number, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(),
242+
export const waitForMany = async<ElementType extends Element|null = null, Selector extends string = string>(
243+
selector: Selector, count: number, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(),
244244
handler?: string) => {
245245
return await asyncScope.exec(() => waitForFunction(async () => {
246-
const elements = await $$(selector, root, handler);
246+
const elements = await $$<ElementType, typeof selector>(selector, root, handler);
247247
return elements.length >= count ? elements : undefined;
248248
}, asyncScope), `Waiting for ${count} elements to match selector '${selector}'`);
249249
};

0 commit comments

Comments
 (0)