| 2 | import type { Playwright } from '../../../lib/next-webdriver' |
| 3 | |
| 4 | async function getMetadataLinks(browser: Playwright) { |
| 5 | const links = await browser.locator('link').evaluateAll((elements: any[]) => { |
| 6 | return elements |
| 7 | .filter((el) => { |
| 8 | if (el.href.includes('/_next/static')) { |
| 9 | return false |
| 10 | } |
| 11 | |
| 12 | return [ |
| 13 | '/favicon.ico', |
| 14 | '/manifest.json', |
| 15 | '/manifest.webmanifest', |
| 16 | // Below may have suffixes like /icon1.png, /icon2.png, etc. |
| 17 | // Or has suffixes like /icon-xxxxxx.png, /icon-image-yyyyyy.jpg, etc. |
| 18 | '/icon', |
| 19 | '/apple-icon', |
| 20 | '/opengraph-image', |
| 21 | '/twitter-image', |
| 22 | ].some((file) => |
| 23 | new URL(el.href, window.location.origin).pathname.includes(file) |
| 24 | ) |
| 25 | }) |
| 26 | .map((el) => ({ |
| 27 | href: new URL(el.href, window.location.origin).pathname, |
| 28 | rel: el.rel, |
| 29 | ...(el.type && { type: el.type }), |
| 30 | })) |
| 31 | .sort((a, b) => a.href.localeCompare(b.href)) |
| 32 | }) |
| 33 | return links |
| 34 | } |
| 35 | |
| 36 | async function getMetadataMetas(browser: Playwright) { |
| 37 | const metas = await browser.locator('meta').evaluateAll((elements: any[]) => { |