Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions playwright/e2e/oddname/oddname-video.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { OGV_UNSUPPORTED } from '../../support/codecs.ts'
import { oddnameTest } from '../../mixins/oddname.ts'

// [file, mimeType, decodable] — see mediaTest's `decodable` param in media.ts.
// Ogg Theora isn't decodable by Chromium's open-source build.
const files: [string, string, boolean?][] = [
const files: [string, string, string?][] = [
['video1.mp4', 'video/mp4'],
['video.mkv', 'video/mkv'],
['video.ogv', 'video/ogv', false],
['video.ogv', 'video/ogv', OGV_UNSUPPORTED],
['video.webm', 'video/webm'],
]

for (const [file, mimeType, decodable] of files) {
oddnameTest(file, mimeType, false, decodable)
for (const [file, mimeType, skipReason] of files) {
oddnameTest(file, mimeType, false, skipReason)
}
6 changes: 2 additions & 4 deletions playwright/e2e/videos/video.ogv.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { OGV_UNSUPPORTED } from '../../support/codecs.ts'
import { videoTest } from '../../mixins/media.ts'

// Ogg Theora isn't decodable by Chromium's open-source build (canPlayType
// returns '' for `video/ogg; codecs="theora"`), unlike Electron's Cypress
// browser which had it. See mediaTest's `decodable` param.
videoTest('video.ogv', 'video/ogv', false)
videoTest('video.ogv', 'video/ogv', OGV_UNSUPPORTED)
19 changes: 7 additions & 12 deletions playwright/mixins/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
getViewerName,
} from '../support/viewerUtils.ts'

/**

Check warning on line 21 in playwright/mixins/media.ts

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @PARAM "skipReason" declaration
* Generate the standard viewer checks for a single video/audio file. The media
* is streamed directly from DAV (partial `206` responses), unlike images which
* go through the preview endpoint.
Expand All @@ -26,14 +26,11 @@
* @param type the media element to assert on
* @param fileName the media file to upload and test against
* @param mimeType the media mime type
* @param decodable whether the CI browser can actually decode this codec. Set
* to false for formats Chromium's open-source build can't play (e.g. Ogg
* Theora): the loading spinner never clears since `canplay` never fires, so
* asserting on it would block every later test in this `describe.serial`
* block instead of just the one check that can't pass here.
*/
function mediaTest(type: 'video' | 'audio', fileName: string, mimeType: string, decodable = true) {
function mediaTest(type: 'video' | 'audio', fileName: string, mimeType: string, skipReason?: string) {
test.describe.serial(`Open ${fileName} in viewer`, () => {
test.skip(!!skipReason, skipReason)

let page: Page
let user: User

Expand All @@ -58,9 +55,7 @@
await expect(getViewer(page)).toBeVisible()

await sourceResponse
if (decodable) {
await expectViewerLoaded(page)
}
await expectViewerLoaded(page)
})

test('See the menu icon and title on the viewer header', async () => {
Expand All @@ -85,10 +80,10 @@
*
* @param fileName the video to upload and test against
* @param mimeType the video mime type
* @param decodable whether the CI browser can decode this codec, see {@link mediaTest}
* @param skipReason if set, the whole group is skipped with this reason
*/
export function videoTest(fileName: string, mimeType: string, decodable = true) {
mediaTest('video', fileName, mimeType, decodable)
export function videoTest(fileName: string, mimeType: string, skipReason?: string) {
mediaTest('video', fileName, mimeType, skipReason)
}

/**
Expand Down
14 changes: 6 additions & 8 deletions playwright/mixins/oddname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ function naughtyFileName(realName: string): string {
* @param file the fixture file to upload
* @param mimeType the fixture mime type
* @param sidebar whether to also exercise the sidebar
* @param decodable whether the CI browser can decode this codec, see {@link mediaTest} in media.ts
* @param skipReason if set, the whole group is skipped with this reason
*/
export function oddnameTest(file: string, mimeType: string, sidebar = false, decodable = true) {
export function oddnameTest(file: string, mimeType: string, sidebar = false, skipReason?: string) {
const placedName = naughtyFileName(file)
const folderName = 'Nextcloud "%27%22%60%25%21%23" >`⛰️<' + file + "><` e*'rocks!#?#%~"

Expand All @@ -63,6 +63,8 @@ export function oddnameTest(file: string, mimeType: string, sidebar = false, dec
}

test.describe.serial(`Open ${file} in viewer with a naughty name ${sidebar ? 'with sidebar' : ''}`, () => {
test.skip(!!skipReason, skipReason)

let page: Page
let user: User

Expand Down Expand Up @@ -90,9 +92,7 @@ export function oddnameTest(file: string, mimeType: string, sidebar = false, dec
})

test('Does not see a loading animation', async () => {
if (decodable) {
await expectViewerLoaded(page)
}
await expectViewerLoaded(page)
})

test('See the menu icon and title on the viewer header', async () => {
Expand Down Expand Up @@ -124,9 +124,7 @@ export function oddnameTest(file: string, mimeType: string, sidebar = false, dec
})

test('Does not see a loading animation (public)', async () => {
if (decodable) {
await expectViewerLoaded(page)
}
await expectViewerLoaded(page)
})

test('See the menu icon and title on the viewer header (public)', async () => {
Expand Down
10 changes: 10 additions & 0 deletions playwright/support/codecs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

// Playwright's bundled Chromium ships without the Ogg/Theora decoder (verified
// on CI: canPlayType returns "" and the <video> raises MEDIA_ERR_SRC_NOT_SUPPORTED),
// so the viewer never leaves its loading state for .ogv files. The previous
// Cypress runner used Electron, which bundles the proprietary FFmpeg codecs.
export const OGV_UNSUPPORTED = 'Ogg/Theora is not supported by Playwright\'s bundled Chromium'
Loading