Skip to content

Commit 5731044

Browse files
authored
Merge pull request #61513 from nextcloud/chore/eslint-pw
chore(tests): adjust PlayWright tests to follow ESLint rules
2 parents c5d088c + 1394f99 commit 5731044

62 files changed

Lines changed: 213 additions & 253 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/src/OC/msg.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export default {
9797
return
9898
}
9999

100-
// eslint-disable-next-line @stylistic/exp-list-style
101100
const animation = el.animate?.(
102101
[
103102
{ opacity: 1 },

dist/core-login.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,19 @@ export default defineConfig([
7373
},
7474
},
7575

76+
// Playwright tests setup
77+
{
78+
name: 'server/playwright',
79+
files: ['tests/playwright/**'],
80+
rules: {
81+
'no-empty-pattern': 'off', // PW needs the destructuring syntax {} for fixtures!
82+
},
83+
},
84+
7685
// Forbid commiting .only in test files (skipping tests is very unexpected)
7786
{
7887
name: 'server/no-only-in-tests',
79-
files: ['cypress/**', 'apps/**/*.spec.*', 'core/**/*.spec.*'],
88+
files: ['cypress/**', 'tests/playwright/**', 'apps/**/*.spec.*', 'core/**/*.spec.*'],
8089
plugins: {
8190
'no-only-tests': noOnlyTests,
8291
},
@@ -96,7 +105,7 @@ export default defineConfig([
96105
'composer.json',
97106
'**/*.php',
98107
'3rdparty/',
99-
'tests/', // PHP tests
108+
'tests/!(playwright)/', // PHP tests, but not Playwright tests
100109
'**/js/',
101110
'**/l10n/', // all translations (config only ignored in root)
102111
'**/vendor/', // different vendors

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"postinstall": "build/demi.sh ci",
2424
"lint": "eslint --suppressions-location build/eslint-baseline.json --no-error-on-unmatched-pattern ./cypress ./tests/playwright",
2525
"postlint": "build/demi.sh lint",
26-
"lint:fix": "build/demi.sh lint:fix",
26+
"lint:fix": "concurrently 'npm run lint -- --fix' 'build/demi.sh lint:fix'",
2727
"playwright": "playwright test",
2828
"playwright:install": "playwright install chromium-headless-shell",
2929
"sass": "sass --style compressed --load-path core/css core/css/ $(for cssdir in $(find apps -mindepth 2 -maxdepth 2 -name \"css\"); do if ! $(git check-ignore -q $cssdir); then printf \"$cssdir \"; fi; done)",

tests/playwright/e2e/appstore/admin-settings-apps.spec.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import { runOcc } from '@nextcloud/e2e-test-server'
67
import { expect } from '@playwright/test'
78
import { test } from '../../support/fixtures/admin-appstore-page.ts'
89
import { handlePasswordConfirmation } from '../../support/utils/password-confirmation.ts'
9-
import { runOcc } from '@nextcloud/e2e-test-server'
1010

1111
test.describe('Settings: App management', () => {
12-
test.beforeEach(async ({ page, appstorePage }) => {
12+
test.beforeEach(async ({ appstorePage }) => {
1313
// Disable QA testing app if already enabled
1414
expect(await runOcc(['app:disable', 'testing']))
1515
.toMatch(/(No such app enabled|testing .+ disabled)/)
@@ -19,22 +19,20 @@ test.describe('Settings: App management', () => {
1919

2020
// Open the installed apps page
2121
await appstorePage.openInstalledApps()
22-
22+
2323
// Wait for the apps table to load
2424
await appstorePage.appsTable().waitFor({ state: 'visible', timeout: 10000 })
2525
})
2626

2727
test('Can enable an installed app', async ({ page, appstorePage }) => {
2828
// Intercept the enable app request
29-
const enableRequest = page.waitForResponse(
30-
(response) => response.url().includes('/ocs/v2.php/apps/appstore/api/v1/apps/enable'),
31-
)
29+
const enableRequest = page.waitForResponse((response) => response.url().includes('/ocs/v2.php/apps/appstore/api/v1/apps/enable'))
3230

3331
// Find and click the enable button for the QA testing app
3432
await expect(appstorePage.appsTable()).toBeVisible()
3533
const qaTestingRow = appstorePage.appRow('QA testing')
3634
await expect(qaTestingRow).toBeVisible({ timeout: 10000 })
37-
35+
3836
await appstorePage.enableButton('QA testing').click({ force: true })
3937

4038
// Handle password confirmation if needed
@@ -57,15 +55,13 @@ test.describe('Settings: App management', () => {
5755

5856
test('Can disable an installed app', async ({ page, appstorePage }) => {
5957
// Intercept the disable app request
60-
const disableRequest = page.waitForResponse(
61-
(response) => response.url().includes('/ocs/v2.php/apps/appstore/api/v1/apps/disable'),
62-
)
58+
const disableRequest = page.waitForResponse((response) => response.url().includes('/ocs/v2.php/apps/appstore/api/v1/apps/disable'))
6359

6460
// Find and click the disable button for the Update notification app
6561
await expect(appstorePage.appsTable()).toBeVisible()
6662
const updateRow = appstorePage.appRow('Update notification')
6763
await expect(updateRow).toBeVisible({ timeout: 10000 })
68-
64+
6965
await appstorePage.disableButton('Update notification').click({ force: true })
7066

7167
// Handle password confirmation if needed
@@ -95,15 +91,15 @@ test.describe('Settings: App management', () => {
9591

9692
// Verify that there are only enabled apps (all have "Disable" button, no "Enable" button)
9793
await expect(appstorePage.appsTable()).toBeVisible()
98-
94+
9995
// Get all rows and verify each has a disable button and no enable button
10096
const rows = appstorePage.appsTable().locator('tr')
10197
const rowCount = await rows.count()
102-
103-
for (let i = 1; i < rowCount; i++) { // Skip header row
98+
99+
for (let i = 1; i < rowCount; i++) { // Skip header row
104100
const row = rows.nth(i)
105101
const enableButton = row.getByRole('button', { name: 'Enable' })
106-
102+
107103
// Enabled apps should not have an "Enable" button
108104
await expect(enableButton).not.toBeVisible()
109105
}
@@ -118,15 +114,15 @@ test.describe('Settings: App management', () => {
118114

119115
// Verify that there are only disabled apps (all have "Enable" button, no "Disable" button)
120116
await expect(appstorePage.appsTable()).toBeVisible()
121-
117+
122118
// Get all rows and verify each has an enable button and no disable button
123119
const rows = appstorePage.appsTable().locator('tr')
124120
const rowCount = await rows.count()
125-
126-
for (let i = 1; i < rowCount; i++) { // Skip header row
121+
122+
for (let i = 1; i < rowCount; i++) { // Skip header row
127123
const row = rows.nth(i)
128124
const disableButton = row.getByRole('button', { name: 'Disable' })
129-
125+
130126
// Disabled apps should not have a "Disable" button
131127
await expect(disableButton).not.toBeVisible()
132128
}
@@ -152,12 +148,12 @@ test.describe('Settings: App management', () => {
152148
const sidebar = appstorePage.appSidebar()
153149
await expect(sidebar).toBeVisible()
154150
await expect(appstorePage.appSidebarHeader()).toContainText('QA testing')
155-
151+
156152
// Verify the sidebar contains expected elements
157153
await expect(appstorePage.viewInStoreLink()).toBeVisible()
158154
await expect(appstorePage.appSidebarEnableButton()).toBeVisible()
159155
await expect(appstorePage.removeButton()).toBeVisible()
160-
156+
161157
// Verify version information is displayed
162158
await expect(appstorePage.versionText()).toBeVisible()
163159
})

tests/playwright/e2e/core/404-error.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { test, expect } from '@playwright/test'
6+
import { expect, test } from '@playwright/test'
77

88
test.describe('404 error page', () => {
99
test('renders 404 page with a link back to login', async ({ page }) => {

tests/playwright/e2e/core/header-access-levels.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import { expect } from '@playwright/test'
7-
import { test as userTest } from '../../support/fixtures/random-user-session.ts'
87
import { test as adminTest } from '../../support/fixtures/admin-session.ts'
8+
import { test as userTest } from '../../support/fixtures/random-user-session.ts'
99
import { AccountMenuPage } from '../../support/sections/AccountMenuPage.ts'
1010

1111
// Regular user tests — the page fixture is logged in as a fresh random user.

tests/playwright/e2e/core/header-app-menu.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import { expect } from '@playwright/test'
7-
import { test as userTest } from '../../support/fixtures/random-user-session.ts'
87
import { test as adminTest } from '../../support/fixtures/admin-session.ts'
8+
import { test as userTest } from '../../support/fixtures/random-user-session.ts'
99
import { NavigationHeaderPage } from '../../support/sections/NavigationHeaderPage.ts'
1010

1111
// Regular-user tests — logged in as a fresh random user.
@@ -65,7 +65,7 @@ adminTest.describe('Header: App menu (waffle launcher) – admin', () => {
6565
*/
6666
async function expectWaffleMenuContainsApps(
6767
navigationHeader: NavigationHeaderPage,
68-
apps: Array<{ name: string; href: string }>,
68+
apps: Array<{ name: string, href: string }>,
6969
): Promise<void> {
7070
await navigationHeader.openMenu()
7171
await expect(navigationHeader.popover()).toBeVisible()

tests/playwright/e2e/core/header-contacts-menu.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import type { User } from '@nextcloud/e2e-test-server'
7+
78
import { runOcc } from '@nextcloud/e2e-test-server/docker'
89
import { createRandomUser } from '@nextcloud/e2e-test-server/playwright'
910
import { expect } from '@playwright/test'

0 commit comments

Comments
 (0)