Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fix unruly URLs in source page table for small viewports (#1241)
sarayourfriend32ce30625757
diff --git a/bin/playwright.sh b/bin/playwright.shindex f075a24bd..10d264aef 100755--- a/bin/playwright.sh+++ b/bin/playwright.sh@@ -10,4 +10,4 @@ export PLAYWRIGHT_VERSION=$(version)echo Running Playwright v$PLAYWRIGHT_VERSION as $USER_ID with Playwright arguments $PLAYWRIGHT_ARGS-docker-compose -f docker-compose.playwright.yml up --abort-on-container-exit --exit-code-from playwright+docker-compose -f docker-compose.playwright.yml up --build --force-recreate --abort-on-container-exit --exit-code-from playwrightdiff --git a/package.json b/package.jsonindex d4963b902..e17122999 100644--- a/package.json+++ b/package.json@@ -101,7 +101,7 @@"@nuxtjs/storybook": "^4.3.0","@nuxtjs/style-resources": "^1.0.0","@pinia/testing": "^0.0.11",- "@playwright/test": "^1.16.2",+ "@playwright/test": "^1.20.2","@testing-library/jest-dom": "^5.16.1","@testing-library/user-event": "^13.5.0","@testing-library/vue": "^5.8.2",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex fa9280d96..2d4e19531 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -20,7 +20,7 @@ specifiers:'@nuxtjs/svg': ^0.3.0'@pinia/nuxt': ^0.1.8'@pinia/testing': ^0.0.11- '@playwright/test': ^1.16.2+ '@playwright/test': ^1.20.2'@popperjs/core': ^2.11.2'@tailwindcss/line-clamp': ^0.3.1'@tailwindcss/typography': ^0.5.2diff --git a/src/pages/sources.vue b/src/pages/sources.vueindex 3f18c55cf..74800ed22 100644--- a/src/pages/sources.vue+++ b/src/pages/sources.vue@@ -122,9 +122,9 @@<td>{{ imageProvider.display_name }}</td>- <td class="font-semibold">+ <td class="font-semibold truncate"><VLink :href="imageProvider.source_url">- {{ imageProvider.source_url }}+ {{ cleanSourceUrlForPresentation(imageProvider.source_url) }}</VLink></td><td class="number-cell">@@ -183,6 +183,14 @@ const SourcePage = {this.sort = { direction, field }},+ cleanSourceUrlForPresentation(url) {+ const stripProtocol = (s) => s.replace(/https?:\/\//, '')+ const stripLeadingWww = (s) =>+ s.startsWith('www.') ? s.replace('www.', '') : s+ const stripTrailingSlash = (s) => (s.endsWith('/') ? s.slice(0, -1) : s)++ return stripTrailingSlash(stripLeadingWww(stripProtocol(url)))+ },},head() {return {diff --git a/test/playwright/utils/breakpoints.ts b/test/playwright/utils/breakpoints.tsindex fd2975df6..93ad1af93 100644--- a/test/playwright/utils/breakpoints.ts+++ b/test/playwright/utils/breakpoints.ts@@ -8,10 +8,15 @@ import {type Breakpoint = Exclude<AllBreakpoints, 'mob'>type ScreenshotAble = {- screenshot(): Promise<Buffer>+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ screenshot(...args: any[]): Promise<Buffer>}-type ExpectSnapshot = (name: string, s: ScreenshotAble) => Promise<Buffer>+type ExpectSnapshot = <T extends ScreenshotAble>(+ name: string,+ s: T,+ options?: Parameters<T['screenshot']>[0]+) => Promise<Buffer>type BreakpointBlock = (options: {getConfigValues: (name: string) => {@@ -46,15 +51,20 @@ const makeBreakpointDescribe =viewport: { width: screenWidth, height: 700 },userAgent: mockUaStrings[breakpoint],})+const getConfigValues = (name: string) => ({name: `${name}-${breakpoint}.png` as const,})- const expectSnapshot = async (++ const expectSnapshot = async <T extends ScreenshotAble>(name: string,- screenshotAble: ScreenshotAble+ screenshotAble: T,+ options?: Parameters<T['screenshot']>[0]) => {const { name: snapshotName } = getConfigValues(name)- return expect(await screenshotAble.screenshot()).toMatchSnapshot({+ return expect(+ await screenshotAble.screenshot(options)+ ).toMatchSnapshot({name: snapshotName,})}diff --git a/test/playwright/utils/page.ts b/test/playwright/utils/page.tsnew file mode 100644index 000000000..0a8c03ebf--- /dev/null+++ b/test/playwright/utils/page.ts@@ -0,0 +1,19 @@+import type { Page } from '@playwright/test'++export const removeHiddenOverflow = async (page: Page) => {+ const mainElement = await page.$('.main.embedded.overflow-x-hidden')+ await mainElement?.evaluate((node) =>+ node.classList.remove('main', 'embedded', 'overflow-x-hidden')+ )+ mainElement?.dispose()++ const appElement = await page.$('.app.grid.h-screen.overflow-hidden.relative')+ await appElement?.evaluate((node) => node.classList.remove('overflow-hidden'))+ appElement?.dispose()+}++export const hideInputCursors = (page: Page) => {+ return page.addStyleTag({+ content: '* { caret-color: transparent !important; }',+ })+}diff --git a/test/playwright/visual-regression/homepage.spec.ts b/test/playwright/visual-regression/homepage.spec.tsindex f3b8dae3e..96b386988 100644--- a/test/playwright/visual-regression/homepage.spec.ts+++ b/test/playwright/visual-regression/homepage.spec.ts@@ -1,6 +1,7 @@import { test, Page } from '@playwright/test'import breakpoints from '~~/test/playwright/utils/breakpoints'+import { hideInputCursors } from '~~/test/playwright/utils/page'const deleteImageCarousel = async (page: Page) => {const element = await page.$('[data-testid="image-carousel"]')@@ -32,6 +33,7 @@ test.describe('homepage snapshots', () => {test('focused', async ({ page }) => {await page.focus('input')+ await hideInputCursors(page)await expectSnapshot('focused-search-ltr',page.locator('form:has(input)')@@ -64,6 +66,7 @@ test.describe('homepage snapshots', () => {test('focused', async ({ page }) => {await page.focus('input')+ await hideInputCursors(page)await expectSnapshot('focused-search-rtl',page.locator('form:has(input)')diff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-2xl-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-2xl-linux.pngindex 4f6079fd6..9bf574502 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-2xl-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-2xl-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-lg-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-lg-linux.pngindex 2563a4268..daba1bc13 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-lg-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-lg-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-md-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-md-linux.pngindex 3b64f56f5..c47aef271 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-md-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-md-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-sm-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-sm-linux.pngindex ad30069a1..dce349ec2 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-sm-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-sm-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xl-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xl-linux.pngindex dfc5e6aff..e33a6ecf3 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xl-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xl-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xs-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xs-linux.pngindex f01e25836..95c643329 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xs-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-ltr-xs-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-2xl-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-2xl-linux.pngindex 2203c3395..16d69b150 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-2xl-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-2xl-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-lg-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-lg-linux.pngindex d379754c7..fb5e4faab 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-lg-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-lg-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-md-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-md-linux.pngindex 29b1ae3f5..b4a7e09ad 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-md-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-md-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-sm-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-sm-linux.pngindex 39d1288ec..85f3232c9 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-sm-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-sm-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xl-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xl-linux.pngindex 93145ffdc..b4a7e09ad 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xl-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xl-linux.png differdiff --git a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xs-linux.png b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xs-linux.pngindex fe064b6b4..c0ba29813 100644Binary files a/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xs-linux.png and b/test/playwright/visual-regression/homepage.spec.ts-snapshots/focused-search-rtl-xs-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts b/test/playwright/visual-regression/sources.spec.tsnew file mode 100644index 000000000..d30c853e2--- /dev/null+++ b/test/playwright/visual-regression/sources.spec.ts@@ -0,0 +1,32 @@+import { test } from '@playwright/test'++import breakpoints from '~~/test/playwright/utils/breakpoints'+import { removeHiddenOverflow } from '~~/test/playwright/utils/page'++test.describe('sources page snapshots', () => {+ test.describe('ltr', () => {+ test.beforeEach(async ({ page }) => {+ await page.goto('/sources')+ })++ breakpoints.describeEvery(({ expectSnapshot }) => {+ test('top', async ({ page }) => {+ await removeHiddenOverflow(page)+ await expectSnapshot('sources-ltr', page, { fullPage: true })+ })+ })+ })++ test.describe('rtl', () => {+ test.beforeEach(async ({ page }) => {+ await page.goto('/ar/sources')+ })++ breakpoints.describeEvery(({ expectSnapshot }) => {+ test('top', async ({ page }) => {+ await removeHiddenOverflow(page)+ await expectSnapshot('sources-rtl', page, { fullPage: true })+ })+ })+ })+})diff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-2xl-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-2xl-linux.pngnew file mode 100644index 000000000..23d04d1cfBinary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-2xl-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-lg-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-lg-linux.pngnew file mode 100644index 000000000..a07c47ca5Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-lg-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-md-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-md-linux.pngnew file mode 100644index 000000000..4f5817f83Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-md-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-sm-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-sm-linux.pngnew file mode 100644index 000000000..ea4d7a104Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-sm-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-xl-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-xl-linux.pngnew file mode 100644index 000000000..6a0209782Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-xl-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-xs-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-xs-linux.pngnew file mode 100644index 000000000..c009fd04fBinary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-ltr-xs-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-2xl-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-2xl-linux.pngnew file mode 100644index 000000000..2c4bbebd6Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-2xl-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-lg-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-lg-linux.pngnew file mode 100644index 000000000..e9171cd74Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-lg-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-md-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-md-linux.pngnew file mode 100644index 000000000..fc2a1a458Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-md-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-sm-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-sm-linux.pngnew file mode 100644index 000000000..9c375655eBinary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-sm-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-xl-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-xl-linux.pngnew file mode 100644index 000000000..6456bd246Binary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-xl-linux.png differdiff --git a/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-xs-linux.png b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-xs-linux.pngnew file mode 100644index 000000000..0a002d34bBinary files /dev/null and b/test/playwright/visual-regression/sources.spec.ts-snapshots/sources-rtl-xs-linux.png differdiff --git a/test/proxy.js b/test/proxy.jsindex 33c26e4b9..8463bf333 100644--- a/test/proxy.js+++ b/test/proxy.js@@ -152,7 +152,7 @@ const opts = /** @type {Partial<TalkbackOptions>} */ ({record: recordMode,fallbackMode: talkback.Options.FallbackMode.NOT_FOUND,ignoreBody: true,- ignoreHeaders: ['user-agent', 'origin', 'referrer', 'content-length', 'host'],+ allowHeaders: ['connection'],name: 'Openverse e2e proxy',summary: false,tapeNameGenerator,