[go: nahoru, domu]

[lighthouse] Add locale e2e test expectations

Test expectations updated downstream:
https://github.com/GoogleChrome/lighthouse/pull/14294

Removes obsolete web tests.

Bug: None
Change-Id: I340f34a09fdf4d918c3a8398e3cf90f003a70528
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3876583
Reviewed-by: Andres Olivares <andoli@chromium.org>
Reviewed-by: Connor Clark <cjamcl@chromium.org>
Commit-Queue: Connor Clark <cjamcl@chromium.org>
diff --git a/test/e2e/helpers/lighthouse-helpers.ts b/test/e2e/helpers/lighthouse-helpers.ts
index cadc91f..079ef14 100644
--- a/test/e2e/helpers/lighthouse-helpers.ts
+++ b/test/e2e/helpers/lighthouse-helpers.ts
@@ -8,13 +8,9 @@
 
 import {type ElementHandle} from 'puppeteer';
 
-export async function waitForLighthousePanelContentLoaded() {
-  await waitFor('.view-container[aria-label="Lighthouse panel"]');
-}
-
 export async function navigateToLighthouseTab(path?: string): Promise<ElementHandle<Element>> {
   await click('#tab-lighthouse');
-  await waitForLighthousePanelContentLoaded();
+  await waitFor('.view-container > .lighthouse');
   if (path) {
     await goToResource(path);
   }
@@ -72,9 +68,9 @@
   });
 }
 
-export async function setClearStorage(enabled: boolean) {
+export async function setToolbarCheckboxWithText(enabled: boolean, textContext: string) {
   const toolbarHandle = await waitFor('.lighthouse-settings-pane .toolbar');
-  const label = await waitForElementWithTextContent('Clear storage', toolbarHandle);
+  const label = await waitForElementWithTextContent(textContext, toolbarHandle);
   await label.evaluate((label, enabled: boolean) => {
     const rootNode = label.getRootNode() as ShadowRoot;
     const checkboxId = label.getAttribute('for') as string;
@@ -85,15 +81,7 @@
 }
 
 export async function setLegacyNavigation(enabled: boolean) {
-  const toolbarHandle = await waitFor('.lighthouse-settings-pane .toolbar');
-  const label = await waitForElementWithTextContent('Legacy navigation', toolbarHandle);
-  await label.evaluate((label, enabled: boolean) => {
-    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);
+  return setToolbarCheckboxWithText(enabled, 'Legacy navigation');
 }
 
 export async function setThrottlingMethod(throttlingMethod: 'simulate'|'devtools') {
diff --git a/test/e2e/lighthouse/navigation_test.ts b/test/e2e/lighthouse/navigation_test.ts
index e5c93a4..a86b060 100644
--- a/test/e2e/lighthouse/navigation_test.ts
+++ b/test/e2e/lighthouse/navigation_test.ts
@@ -5,6 +5,7 @@
 import {assert} from 'chai';
 
 import {expectError} from '../../conductor/events.js';
+import {setDevToolsSettings} from '../../shared/helper.js';
 import {describe, it} from '../../shared/mocha-extensions.js';
 import {
   clickStartButton,
@@ -12,9 +13,9 @@
   navigateToLighthouseTab,
   selectCategories,
   selectMode,
-  setClearStorage,
   setLegacyNavigation,
   setThrottlingMethod,
+  setToolbarCheckboxWithText,
   waitForResult,
 } from '../helpers/lighthouse-helpers.js';
 
@@ -133,16 +134,17 @@
       });
 
       it('successfully returns a Lighthouse report when settings changed', async () => {
+        await setDevToolsSettings({language: 'en-XL'});
         await navigateToLighthouseTab('lighthouse/hello.html');
 
-        await setLegacyNavigation(mode === 'legacy');
-        await setClearStorage(false);
+        await setToolbarCheckboxWithText(mode === 'legacy', 'L̂éĝáĉý n̂áv̂íĝát̂íôń');
+        await setToolbarCheckboxWithText(false, 'Ĉĺêár̂ śt̂ór̂áĝé');
         await selectCategories(['performance', 'best-practices']);
         await selectMode('desktop');
 
         await clickStartButton();
 
-        const {lhr, artifacts} = await waitForResult();
+        const {reportEl, lhr, artifacts} = await waitForResult();
 
         const {innerWidth, innerHeight, devicePixelRatio} = artifacts.ViewportDimensions;
         // TODO: Figure out why outerHeight can be different depending on OS
@@ -156,6 +158,13 @@
         assert.deepStrictEqual(Object.keys(lhr.categories), ['performance', 'best-practices']);
         assert.strictEqual(lhr.configSettings.disableStorageReset, true);
         assert.strictEqual(lhr.configSettings.formFactor, 'desktop');
+
+        const viewTraceText = await reportEl.$eval('.lh-button--trace', viewTraceEl => {
+          return viewTraceEl.textContent;
+        });
+        assert.strictEqual(viewTraceText, 'V̂íêẃ Ôŕîǵîńâĺ T̂ŕâćê');
+
+        assert.strictEqual(lhr.i18n.rendererFormattedStrings.footerIssue, 'F̂íl̂é âń îśŝúê');
       });
     });
   }
diff --git a/test/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run-expected.txt b/test/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run-expected.txt
deleted file mode 100644
index b8cc8b3..0000000
--- a/test/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run-expected.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-Tests that Lighthouse report is translated.
-
-
-========== Lighthouse Start Audit State ==========
-[x] Performance
-[ ] Accessibility
-[ ] Best practices
-[ ] SEO
-[ ] Progressive Web App
-[ ] Publisher Ads
-[x] Legacy navigation
-[x] Clear storage
-Throttling method: simulate
-Analyze page load: enabled visible
-resolved to locale es
-
-i18n footerIssue: "Notificar un problema"
-
-Footer Issue Link Text: "Notificar un problema"
-
diff --git a/test/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run.js b/test/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run.js
deleted file mode 100644
index 21a91f2..0000000
--- a/test/webtests/http/tests/devtools/lighthouse/lighthouse-i18n-run.js
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(async function() {
-  TestRunner.addResult('Tests that Lighthouse report is translated.\n');
-  await TestRunner.navigatePromise('resources/lighthouse-basic.html');
-
-  await TestRunner.loadTestModule('lighthouse_test_runner');
-  await TestRunner.showPanel('lighthouse');
-
-  const containerElement = LighthouseTestRunner.getContainerElement();
-  const ensureDisabledNames = ['Accessibility', 'Best practices', 'SEO', 'Progressive Web App'];
-  const checkboxes = Array.from(containerElement.querySelectorAll('.checkbox'));
-  for (const checkbox of checkboxes) {
-    if (!ensureDisabledNames.includes(checkbox.textElement.textContent)) {
-      continue;
-    }
-
-    if (checkbox.checkboxElement.checked) {
-      checkbox.checkboxElement.click();
-    }
-  }
-
-  TestRunner.override(LighthouseTestRunner._panel().protocolService, 'getLocales', overrideLookupLocale, true);
-
-  const locales = ['invalid-locale', 'es'];
-  function overrideLookupLocale() {
-    return locales;
-  }
-
-  LighthouseTestRunner.dumpStartAuditState();
-  LighthouseTestRunner.getRunButton().click();
-
-  const {lhr} = await LighthouseTestRunner.waitForResults();
-
-  TestRunner.addResult(`resolved to locale ${lhr.configSettings.locale}`);
-  TestRunner.addResult(`\ni18n footerIssue: "${lhr.i18n.rendererFormattedStrings.footerIssue}"`);
-
-  const footerIssueLink = LighthouseTestRunner.getResultsElement().querySelector('.lh-footer__version_issue');
-  TestRunner.addResult(`\nFooter Issue Link Text: "${footerIssueLink.textContent}"`);
-
-  TestRunner.completeTest();
-})();
diff --git a/test/webtests/http/tests/devtools/lighthouse/lighthouse-limited-run-expected.txt b/test/webtests/http/tests/devtools/lighthouse/lighthouse-limited-run-expected.txt
deleted file mode 100644
index 180af44..0000000
--- a/test/webtests/http/tests/devtools/lighthouse/lighthouse-limited-run-expected.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-Tests that audits panel works when only the pwa category is selected.
-
-
-========== Lighthouse Start Audit State ==========
-[ ] Performance
-[ ] Accessibility
-[ ] Best practices
-[ ] SEO
-[x] Progressive Web App
-[ ] Publisher Ads
-[x] Legacy navigation
-[x] Clear storage
-Throttling method: simulate
-Analyze page load: enabled visible
-
-=============== Audits run ===============
-apple-touch-icon
-content-width
-full-page-screenshot
-installable-manifest
-maskable-icon
-pwa-cross-browser
-pwa-each-page-has-url
-pwa-page-transitions
-service-worker
-splash-screen
-themed-omnibox
-viewport
-
diff --git a/test/webtests/http/tests/devtools/lighthouse/lighthouse-limited-run.js b/test/webtests/http/tests/devtools/lighthouse/lighthouse-limited-run.js
deleted file mode 100644
index 26c5cda..0000000
--- a/test/webtests/http/tests/devtools/lighthouse/lighthouse-limited-run.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(async function() {
-  TestRunner.addResult('Tests that audits panel works when only the pwa category is selected.\n');
-  await TestRunner.navigatePromise('resources/lighthouse-basic.html');
-
-  await TestRunner.loadTestModule('lighthouse_test_runner');
-  await TestRunner.showPanel('lighthouse');
-
-  const containerElement = LighthouseTestRunner.getContainerElement();
-  const ensureDisabledNames = ['Performance', 'Accessibility', 'Best practices', 'SEO'];
-  const checkboxes = Array.from(containerElement.querySelectorAll('.checkbox'));
-  for (const checkbox of checkboxes) {
-    if (!ensureDisabledNames.includes(checkbox.textElement.textContent)) {
-      continue;
-    }
-
-    if (checkbox.checkboxElement.checked) {
-      checkbox.checkboxElement.click();
-    }
-  }
-
-  LighthouseTestRunner.dumpStartAuditState();
-  LighthouseTestRunner.getRunButton().click();
-
-  const {lhr} = await LighthouseTestRunner.waitForResults();
-  TestRunner.addResult('\n=============== Audits run ===============');
-  TestRunner.addResult(Object.keys(lhr.audits).sort().join('\n'));
-
-  TestRunner.completeTest();
-})();