Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Add the new VR tests
Browse files Browse the repository at this point in the history
Remove the Chrome search input cross in tailwind.css
Move the `self-center` class to weblink button
Add updated snapshots

Extract changes from #1930
  • Loading branch information
obulat committed Oct 25, 2022
1 parent 976ee8e commit 28798f1
Show file tree
Hide file tree
Showing 194 changed files with 78 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/components/VCopyButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
type="button"
variant="secondary-filled"
size="disabled"
class="py-2 px-3 text-sr"
class="py-2 px-3 text-sr font-bold"
:data-clipboard-target="el"
>
<span v-if="!success">
Expand Down
1 change: 0 additions & 1 deletion src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
>
<VInputModal
class="flex w-full"
variant="recent-searches"
:is-active="isRecentSearchesModalOpen"
@close="deactivate"
>
Expand Down
10 changes: 0 additions & 10 deletions src/components/VHeader/VSearchBar/VSearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,3 @@ export default defineComponent({
},
})
</script>

<style>
/* Removes the cross icon to clear the field */
.search-field input[type='search']::-webkit-search-decoration,
.search-field input[type='search']::-webkit-search-cancel-button,
.search-field input[type='search']::-webkit-search-results-button,
.search-field input[type='search']::-webkit-search-results-decoration {
-webkit-appearance: none;
}
</style>
5 changes: 2 additions & 3 deletions src/components/VHeaderOld/VHeaderFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import {
watch,
computed,
onMounted,
inject,
Ref,
toRef,
onBeforeUnmount,
} from '@nuxtjs/composition-api'
Expand All @@ -49,6 +47,7 @@ import { Portal as VTeleport } from 'portal-vue'
import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'
import { useFilterSidebarVisibility } from '~/composables/use-filter-sidebar-visibility'
import { useFocusFilters } from '~/composables/use-focus-filters'
import { isMinScreen } from '~/composables/use-media-query'
import { Focus } from '~/utils/focus-management'
import { defineEvent } from '~/types/emits'
Expand Down Expand Up @@ -90,7 +89,7 @@ export default defineComponent({
const filterSidebar = useFilterSidebarVisibility()
const disabledRef = toRef(props, 'disabled')
const isMinScreenMd: Ref<boolean> = inject('isMinScreenMd')
const isMinScreenMd = isMinScreen('md')
const open = () => (visibleRef.value = true)
const close = () => (visibleRef.value = false)
Expand Down
1 change: 1 addition & 0 deletions src/components/VHeaderOld/VHeaderOld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:is-fetching="isFetching"
:is-header-scrolled="isHeaderScrolled"
:is-search-route="isSearchRoute"
class="md:h-12"
/>

<VSearchBarOld
Expand Down
2 changes: 1 addition & 1 deletion src/components/VMediaInfo/VMediaLicense.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="media-attribution">
<h3 class="description md:heading-6 mb-4">
<h3 class="description-bold md:heading-6 mb-4">
{{ headerText }}
</h3>

Expand Down
5 changes: 4 additions & 1 deletion src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ const embeddedPage = {
mounted.value = true
})
const isMinScreenMd = isMinScreen('md')
/**
* If we use the `isMinScreen('lg')` composable for conditionally
* rendering components, we get a server-client side rendering
Expand All @@ -124,6 +123,10 @@ const embeddedPage = {
const isMinScreenLg = computed(() =>
Boolean(innerIsMinScreenLg.value && mounted.value)
)
const innerIsMinScreenMd = isMinScreen('md')
const isMinScreenMd = computed(() =>
Boolean(innerIsMinScreenMd.value && mounted.value)
)
const isSidebarVisible = computed(() => {
return isNewHeaderEnabled.value
Expand Down
11 changes: 4 additions & 7 deletions src/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
import { isShallowEqualObjects } from '@wordpress/is-shallow-equal'
import { computed, defineComponent, inject, ref } from '@nuxtjs/composition-api'
import { Context } from '@nuxt/types'
import { isMinScreen } from '~/composables/use-media-query'
import { useFilterSidebarVisibility } from '~/composables/use-filter-sidebar-visibility'
import { Focus, focusIn } from '~/utils/focus-management'
import { useMediaStore } from '~/stores/media'
Expand All @@ -49,6 +46,8 @@ import VSearchGrid from '~/components/VSearchGrid.vue'
import VSkipToContentContainer from '~/components/VSkipToContentContainer.vue'
import VScrollButton from '~/components/VScrollButton.vue'
import type { Context } from '@nuxt/types'
export default defineComponent({
name: 'BrowsePage',
components: {
Expand All @@ -68,7 +67,6 @@ export default defineComponent({
scrollToTop: false,
setup() {
const searchGridRef = ref(null)
const isMinScreenMd = isMinScreen('md')
const { isVisible: isFilterSidebarVisible } = useFilterSidebarVisibility()
const showScrollButton = inject('showScrollButton')
const mediaStore = useMediaStore()
Expand Down Expand Up @@ -99,7 +97,6 @@ export default defineComponent({
return {
searchGridRef,
isMinScreenMd,
isFilterSidebarVisible,
showScrollButton,
searchTerm,
Expand Down Expand Up @@ -156,9 +153,9 @@ export default defineComponent({
}
focusIn(document.getElementById('__layout'), Focus.First)
},
fetchMedia(...args: unknown[]) {
fetchMedia({ shouldPersistMedia } = { shouldPersistMedia: false }) {
const mediaStore = useMediaStore(this.$pinia)
return mediaStore.fetchMedia(...args)
return mediaStore.fetchMedia({ shouldPersistMedia })
},
},
})
Expand Down
6 changes: 4 additions & 2 deletions src/pages/search/audio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ import {
defineComponent,
useMeta,
ref,
inject,
} from '@nuxtjs/composition-api'
import { isMinScreen } from '~/composables/use-media-query'
import { useBrowserIsMobile } from '~/composables/use-browser-detection'
import { useFocusFilters } from '~/composables/use-focus-filters'
import { Focus } from '~/utils/focus-management'
import { useUiStore } from '~/stores/ui'
import { IsMinScreenMdKey } from '~/types/provides'
import VSnackbar from '~/components/VSnackbar.vue'
import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
import VLoadMore from '~/components/VLoadMore.vue'
Expand All @@ -69,7 +71,7 @@ export default defineComponent({
const results = computed(() => props.resultItems.audio)
const isMinScreenMd = isMinScreen('md', { shouldPassInSSR: true })
const isMinScreenMd = inject(IsMinScreenMdKey)
// On SSR, we set the size to small if the User Agent is mobile, otherwise we set the size to medium.
const isMobile = useBrowserIsMobile()
Expand Down
8 changes: 4 additions & 4 deletions test/playwright/e2e/search-query-client-old.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
changeContentType,
goToSearchTerm,
OLD_HEADER,
searchFromHeader,
} from '~~/test/playwright/utils/navigation'
import { mockProviderApis } from '~~/test/playwright/utils/route'

Expand Down Expand Up @@ -70,8 +71,8 @@ test('url filter types not used by current mediaType are discarded', async ({

test('can search for a different term', async ({ page }) => {
await goToSearchTerm(page, 'cat', { searchType: IMAGE })
await page.fill('header input[type="search"]', 'dog')
await page.keyboard.press('Enter')
await searchFromHeader(page, 'dog')

await expect(page).toHaveURL('/search/image?q=dog')
})

Expand All @@ -80,7 +81,6 @@ test('search for a different term keeps query parameters', async ({ page }) => {
searchType: IMAGE,
query: 'license=by&extension=jpg',
})
await page.fill('header input[type="search"]', 'dog')
await page.keyboard.press('Enter')
await searchFromHeader(page, 'dog')
await expect(page).toHaveURL('/search/image?q=dog&license=by&extension=jpg')
})
2 changes: 1 addition & 1 deletion test/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const config: PlaywrightTestConfig = {
expect: {
toMatchSnapshot: {
// To avoid flaky tests, we allow a small amount of pixel difference.
maxDiffPixelRatio: 0.06,
maxDiffPixelRatio: 0.02,
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions test/playwright/utils/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ const describeEachDesktopWithMd = describeEachBreakpoint(desktopBreakpoints)
const describeEachDesktop = describeEachBreakpoint(
desktopBreakpoints.filter((b) => b !== 'md')
)
const describeEachMobile = describeEachBreakpoint(mobileBreakpoints)
const describeEachMobile = describeEachBreakpoint([...mobileBreakpoints, 'md'])
const describeEachMobileWithoutMd = describeEachBreakpoint(mobileBreakpoints)

export default {
...breakpointTests,
describeEachBreakpoint,
describeEvery,
describeEachDesktop,
// TODO: remove describeEachDesktopWithMd after the new_header is merged
// Used for VHeaderInternal
describeEachDesktopWithMd,
describeEachMobile,
// TODO: remove describeEachMobileWithoutMd after the new_header is merged
// Used for VHeaderInternal
describeEachMobileWithoutMd,
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions test/playwright/visual-regression/components/audio-results.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { test } from '@playwright/test'

import breakpoints from '~~/test/playwright/utils/breakpoints'
import {
closeFilters,
enableNewHeader,
} from '~~/test/playwright/utils/navigation'

test.describe.configure({ mode: 'parallel' })

test.describe('audio results', () => {
test.beforeEach(async ({ page }) => {
await enableNewHeader(page)
await page.goto('/search/audio?q=birds')
})

breakpoints.describeEachMobile({ uaMocking: false }, ({ expectSnapshot }) => {
test('should render small row layout desktop UA with narrow viewport', async ({
page,
}) => {
await expectSnapshot('audio-results-narrow-viewport-desktop-UA', page)
})
})

breakpoints.describeEachMobile({ uaMocking: true }, ({ expectSnapshot }) => {
test('should render small row layout mobile UA with narrow viewport', async ({
page,
}) => {
await expectSnapshot('audio-results-narrow-viewport-mobile-UA', page)
})
})

breakpoints.describeEachDesktop(({ expectSnapshot }) => {
test('desktop audio results', async ({ page }) => {
await closeFilters(page)
// Make sure filters button is not hovered
await page.mouse.move(0, 150)
await expectSnapshot('audio-results-desktop', page)
})
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions test/playwright/visual-regression/components/media-reuse.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Route, test } from '@playwright/test'
import { test } from '@playwright/test'

import breakpoints from '~~/test/playwright/utils/breakpoints'
import {
dismissTranslationBanner,
pathWithDir,
languageDirections,
pathWithDir,
scrollDownAndUp,
t,
} from '~~/test/playwright/utils/navigation'
import { mockProviderApis } from '~~/test/playwright/utils/route'

test.describe.configure({ mode: 'parallel' })

Expand All @@ -16,22 +18,24 @@ const tabs = [
{ id: 'plain', name: 'Plain text' },
]

const cancelImageRequests = (route: Route) =>
route.request().resourceType() === 'image' ? route.abort() : route.continue()

test.describe('media-reuse', () => {
for (const tab of tabs) {
for (const dir of languageDirections) {
breakpoints.describeEvery(({ expectSnapshot }) => {
test(`Should render a ${dir} media reuse section with "${tab.name}" tab open`, async ({
context,
page,
}) => {
await page.route('**/*', cancelImageRequests)
await mockProviderApis(context)

await page.goto(
pathWithDir('/image/f9384235-b72e-4f1e-9b05-e1b116262a29', dir)
)
await dismissTranslationBanner(page)
// The image is loading from provider, so we need to wait for it to
// finish loaded to prevent the shift of the component during snapshots.
await scrollDownAndUp(page)
await page.waitForLoadState('networkidle')

await page.locator(`#tab-${tab.id}`).click()
// Make sure the tab is not focused and doesn't have a pink ring
Expand Down
4 changes: 2 additions & 2 deletions test/storybook/visual-regression/v-header-internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const pageUrl = (dir: typeof languageDirections[number]) =>

test.describe('VHeaderInternal', () => {
for (const dir of languageDirections) {
breakpoints.describeEachDesktop(({ expectSnapshot }) => {
breakpoints.describeEachDesktopWithMd(({ expectSnapshot }) => {
test(`desktop-header-internal-${dir}`, async ({ page }) => {
await page.goto(pageUrl(dir))
await page.mouse.move(0, 150)
Expand All @@ -21,7 +21,7 @@ test.describe('VHeaderInternal', () => {
)
})
})
breakpoints.describeEachMobile(({ expectSnapshot }) => {
breakpoints.describeEachMobileWithoutMd(({ expectSnapshot }) => {
test(`mobile-header-internal-${dir}`, async ({ page }) => {
await page.goto(pageUrl(dir))
await page.mouse.move(0, 150)
Expand Down

0 comments on commit 28798f1

Please sign in to comment.