Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(dashboard): Add regression test for loading unneeded data #50179

Merged
merged 1 commit into from
Jan 16, 2025
Merged
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
41 changes: 41 additions & 0 deletions cypress/e2e/dashboard/widget-performance.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

/**
* Regression test of https://github.com/nextcloud/server/issues/48403
* Ensure that only visible widget data is loaded
*/
describe('dashboard: performance', () => {
before(() => {
cy.createRandomUser().then((user) => {
// Enable one widget
cy.runOccCommand(`user:setting -- '${user.userId}' dashboard layout files-favorites`)
cy.login(user)
})
})

it('Only load needed widgets', () => {
cy.intercept('**/dashboard/api/v2/widget-items?widgets*').as('loadedWidgets')

const now = new Date(2025, 0, 14, 15)
cy.clock(now)

// The dashboard is loaded
cy.visit('/apps/dashboard')
cy.get('#app-dashboard')
.should('be.visible')
.contains('Good afternoon')
.should('be.visible')

// Wait that one data is loaded (ensure the API works), this should be the favorite files.
cy.wait('@loadedWidgets')
// Wait and check no requests are made (ensure that the user statuses data is NOT loaded)
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(4000, { timeout: 8000 })
cy.get('@loadedWidgets.all').then((interceptions) => {
expect(interceptions).to.have.length(1)
})
})
})
Loading