From 8afa59d054f4d55cba23767fe73c54718399147b Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Mon, 15 Aug 2022 12:53:19 -0700 Subject: [PATCH 1/2] wip --- .../e2e/lighthouse/navigation_test.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts b/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts index c5cba99d6877..d48bc925f92b 100644 --- a/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts +++ b/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts @@ -14,10 +14,25 @@ import { setThrottlingMethod, waitForResult, } from '../helpers/lighthouse-helpers.js'; +import {click, goToResource, waitFor, setDevToolsSettings} from '../../shared/helper.js'; + +import type {ElementHandle} from 'puppeteer'; // This test will fail (by default) in headful mode, as the target page never gets painted. // To resolve this when debugging, just make sure the target page is visible during the lighthouse run. +// TODO: update upstream. +async function navigateToLighthouseTab_2(path?: string): Promise> { + await click('#tab-lighthouse'); + // await waitForLighthousePanelContentLoaded(); + await waitFor('.view-container > .lighthouse'); + if (path) { + await goToResource(path); + } + + return waitFor('.lighthouse-start-view-fr'); +} + describe('Navigation', async function() { // The tests in this suite are particularly slow this.timeout(60_000); @@ -35,7 +50,8 @@ describe('Navigation', async function() { }); it('successfully returns a Lighthouse report', async () => { - await navigateToLighthouseTab('lighthouse/hello.html'); + await setDevToolsSettings({language: 'en-XL'}); + await navigateToLighthouseTab_2('lighthouse/hello.html'); await setLegacyNavigation(mode === 'legacy'); await clickStartButton(); From 51fb1cb6208bbeae26ca2ec1c72dc55674d162a2 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Mon, 15 Aug 2022 13:16:34 -0700 Subject: [PATCH 2/2] fix --- .../e2e/lighthouse/navigation_test.ts | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts b/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts index d48bc925f92b..5c9290855cd3 100644 --- a/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts +++ b/third-party/devtools-tests/e2e/lighthouse/navigation_test.ts @@ -14,7 +14,7 @@ import { setThrottlingMethod, waitForResult, } from '../helpers/lighthouse-helpers.js'; -import {click, goToResource, waitFor, setDevToolsSettings} from '../../shared/helper.js'; +import {click, goToResource, waitFor, setDevToolsSettings, waitForElementWithTextContent} from '../../shared/helper.js'; import type {ElementHandle} from 'puppeteer'; @@ -33,6 +33,18 @@ async function navigateToLighthouseTab_2(path?: string): Promise { + const rootNode = label.getRootNode() as ShadowRoot; + const checkboxId = label.getAttribute('for') as string; + const checkboxElem = rootNode.getElementById(checkboxId) as HTMLInputElement; + checkboxElem.checked = enabled; + checkboxElem.dispatchEvent(new Event('change')); // Need change event to update the backing setting. + }, enabled); +} + describe('Navigation', async function() { // The tests in this suite are particularly slow this.timeout(60_000); @@ -53,7 +65,7 @@ describe('Navigation', async function() { await setDevToolsSettings({language: 'en-XL'}); await navigateToLighthouseTab_2('lighthouse/hello.html'); - await setLegacyNavigation(mode === 'legacy'); + await setLegacyNavigation_2(mode === 'legacy', 'L̂éĝáĉý n̂áv̂íĝát̂íôń'); await clickStartButton(); const {lhr, artifacts, reportEl} = await waitForResult(); @@ -93,7 +105,9 @@ describe('Navigation', async function() { const viewTraceText = await reportEl.$eval('.lh-button--trace', viewTraceEl => { return viewTraceEl.textContent; }); - assert.strictEqual(viewTraceText, 'View Original Trace'); + assert.strictEqual(viewTraceText, 'V̂íêẃ Ôŕîǵîńâĺ T̂ŕâćê'); + + assert.strictEqual(lhr.i18n.rendererFormattedStrings.footerIssue, 'F̂íl̂é âń îśŝúê'); }); it('successfully returns a Lighthouse report with DevTools throttling', async () => {