Skip to content

Commit b7bf8ee

Browse files
Merge pull request #7940 from nextcloud/chore/convert-cy-to-play
Convert print test from cypress to playwright
2 parents 368f7a1 + ff1b7c8 commit b7bf8ee

22 files changed

+294
-166
lines changed

.eslintrc.cjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ module.exports = {
1313
'vue/first-attribute-linebreak': 'off',
1414
},
1515
},
16+
{
17+
files: ['**/*.ts'],
18+
rules: {
19+
// Do not err out on constructors with parameter properties only.
20+
'no-useless-constructor': 'off',
21+
'@typescript-eslint/no-useless-constructor': 'error',
22+
},
23+
},
1624
],
1725
rules: {
1826
'import/no-unresolved': [1, { ignore: ['\\.svg\\?raw$'] }],

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ webpack-stats.json
1818

1919
# js folder, to be updated wth --force
2020
/js
21+
22+
# Playwright snapshots - only keep the ci version in git
23+
playwright/e2e/*-snapshots/**
24+
!playwright/e2e/*-snapshots/*-on-ci-**

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SPDX-FileCopyrightText = "Nils Adermann, Jordi Boggiano"
3030
SPDX-License-Identifier = "MIT"
3131

3232
[[annotations]]
33-
path = ["cypress/fixtures/**", "cypress/snapshots/**", "src/tests/fixtures/**", "src/tests/**/__snapshots__/**"]
33+
path = ["cypress/fixtures/**", "cypress/snapshots/**", "playwright/support/fixtures/files/**", "playwright/e2e/*-snapshots/**", "src/tests/fixtures/**", "src/tests/**/__snapshots__/**"]
3434
precedence = "aggregate"
3535
SPDX-FileCopyrightText = "2019-2025 Nextcloud GmbH and Nextcloud contributors"
3636
SPDX-License-Identifier = "AGPL-3.0-or-later"

cypress/e2e/print.spec.js

Lines changed: 0 additions & 54 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.

playwright/e2e/change-mime-type.spec.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55

66
import { expect, mergeTests } from '@playwright/test'
77
import { test as editorTest } from '../support/fixtures/editor'
8-
import { test as randomUserTest } from '../support/fixtures/random-user'
98
import { test as uploadFileTest } from '../support/fixtures/upload-file'
109

11-
const test = mergeTests(editorTest, randomUserTest, uploadFileTest)
10+
const test = mergeTests(editorTest, uploadFileTest)
1211

13-
test.beforeEach(async ({ file }) => {
14-
await file.open()
12+
test.beforeEach(async ({ open }) => {
13+
await open()
1514
})
1615

1716
test.describe('Changing mimetype from markdown to plaintext', () => {
18-
test('resets the document session and indexed db', async ({ editor, file }) => {
17+
test('resets the document session and indexed db', async ({
18+
close,
19+
editor,
20+
file,
21+
}) => {
1922
await editor.typeHeading('Hello world')
20-
await file.close()
21-
await file.move('test.txt')
22-
await file.open()
23+
await close()
24+
const plaintext = await file.move('test.txt')
25+
await plaintext.open()
2326
await expect(editor.content).toHaveText('## Hello world')
2427
await expect(editor.getHeading()).not.toBeVisible()
2528
})
@@ -28,12 +31,16 @@ test.describe('Changing mimetype from markdown to plaintext', () => {
2831
test.describe('Changing mimetype from plain to markdown', () => {
2932
test.use({ fileName: 'empty.txt' })
3033

31-
test('resets the document session and indexed db', async ({ editor, file }) => {
34+
test('resets the document session and indexed db', async ({
35+
close,
36+
editor,
37+
file,
38+
}) => {
3239
await editor.type('## Hello world')
3340
await expect(editor.content).toHaveText('## Hello world')
34-
await file.close()
35-
await file.move('test.md')
36-
await file.open()
41+
await close()
42+
const markdown = await file.move('test.md')
43+
await markdown.open()
3744
await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible()
3845
})
3946
})

playwright/e2e/mobile.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55

66
import { devices, expect, mergeTests } from '@playwright/test'
77
import { test as editorTest } from '../support/fixtures/editor'
8-
import { test as randomUserTest } from '../support/fixtures/random-user'
98
import { test as uploadFileTest } from '../support/fixtures/upload-file'
109

11-
const test = mergeTests(editorTest, randomUserTest, uploadFileTest)
10+
const test = mergeTests(editorTest, uploadFileTest)
1211

1312
test.use({
1413
...devices['Moto G4'],
1514
})
1615

17-
test.beforeEach(async ({ file }) => {
18-
await file.open()
16+
test.beforeEach(async ({ open }) => {
17+
await open()
1918
})
2019

2120
test('Formatting help', async ({ editor }) => {

playwright/e2e/offline.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
import { expect, mergeTests } from '@playwright/test'
77
import { test as editorTest } from '../support/fixtures/editor'
88
import { test as offlineTest } from '../support/fixtures/offline'
9-
import { test as randomUserTest } from '../support/fixtures/random-user'
109
import { test as uploadFileTest } from '../support/fixtures/upload-file'
1110

12-
const test = mergeTests(editorTest, offlineTest, randomUserTest, uploadFileTest)
11+
const test = mergeTests(editorTest, offlineTest, uploadFileTest)
1312

1413
// As we switch on and off the network
1514
// we cannot run tests in parallel.
1615
test.describe.configure({ mode: 'serial' })
1716

18-
test.beforeEach(async ({ file }) => {
19-
await file.open()
17+
test.beforeEach(async ({ open }) => {
18+
await open()
2019
})
2120

2221
test('Offline state indicator', async ({ editor, setOffline }) => {
@@ -48,7 +47,7 @@ test('typing offline and coming back online', async ({
4847
setOffline,
4948
setOnline,
5049
}) => {
51-
await expect(editor.locator).toBeVisible()
50+
await expect(editor.el).toBeVisible()
5251
await setOffline()
5352
await editor.typeHeading('Hello world')
5453
await setOnline()

playwright/e2e/print.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { expect, mergeTests } from '@playwright/test'
7+
import { hostname } from 'os'
8+
import { test as editorTest } from '../support/fixtures/editor'
9+
import { loadFixture } from '../support/fixtures/loadFixture'
10+
import { test as sharedFileTest } from '../support/fixtures/shared-file'
11+
import { test as uploadFileTest } from '../support/fixtures/upload-file'
12+
13+
const fileTest = mergeTests(editorTest, uploadFileTest)
14+
const shareTest = mergeTests(editorTest, sharedFileTest)
15+
const host = process.env.CI ? 'ci' : hostname()
16+
17+
new Map([
18+
[`Own file on ${host}`, fileTest],
19+
[`Shared file on ${host}`, shareTest],
20+
]).forEach((test, name) => {
21+
test.use({ fileContent: loadFixture('print.md') })
22+
test(name, async ({ open, page }) => {
23+
await open()
24+
await page.emulateMedia({ media: 'print' })
25+
await expect(page).toHaveScreenshot({ fullPage: true })
26+
})
27+
})

0 commit comments

Comments
 (0)