|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { runOcc } from '@nextcloud/e2e-test-server' |
| 7 | +import { expect } from '@playwright/test' |
| 8 | +import { test } from '../../support/fixtures/random-user-session.ts' |
| 9 | + |
| 10 | +/** The endpoint the dashboard uses to load the data of its widgets. */ |
| 11 | +const WIDGET_ITEMS_API = /\/dashboard\/api\/v2\/widget-items\?widgets/ |
| 12 | + |
| 13 | +/** |
| 14 | + * Regression test of https://github.com/nextcloud/server/issues/48403: the |
| 15 | + * dashboard must only fetch data for the widgets it actually shows. |
| 16 | + */ |
| 17 | +test('dashboard: only loads the data of enabled widgets', async ({ page, user }) => { |
| 18 | + // A layout with a single widget — so exactly one data request is expected |
| 19 | + await runOcc(['user:setting', '--', user.userId, 'dashboard', 'layout', 'files-favorites']) |
| 20 | + |
| 21 | + const requests: string[] = [] |
| 22 | + page.on('request', (request) => { |
| 23 | + if (WIDGET_ITEMS_API.test(request.url())) { |
| 24 | + requests.push(request.url()) |
| 25 | + } |
| 26 | + }) |
| 27 | + |
| 28 | + const loaded = page.waitForResponse((r) => WIDGET_ITEMS_API.test(r.url())) |
| 29 | + await page.goto('apps/dashboard') |
| 30 | + await expect(page.getByRole('heading', { name: /Good (morning|afternoon|evening|night)/ })).toBeVisible() |
| 31 | + await loaded |
| 32 | + |
| 33 | + // Give any further (unwanted) widget request time to be fired … |
| 34 | + await page.waitForTimeout(2000) |
| 35 | + // … and confirm the favorites widget was the only one that loaded data |
| 36 | + expect(requests).toHaveLength(1) |
| 37 | +}) |
0 commit comments