From 1662fed5ef9018a272995d58d5c887d5c2b3244f Mon Sep 17 00:00:00 2001 From: "Enjeck C." Date: Wed, 21 May 2025 05:34:33 +0100 Subject: [PATCH 1/6] test(Cypress): Fix component tests Signed-off-by: Enjeck C. --- cypress/support/component.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/support/component.js b/cypress/support/component.js index 55cb0dc519..3ac56c022c 100644 --- a/cypress/support/component.js +++ b/cypress/support/component.js @@ -4,8 +4,8 @@ */ import { mount } from 'cypress/vue2' import { translate as t, translatePlural as n } from '@nextcloud/l10n' -import store from '../../src/store/store.js' -import data from '../../src/store/data.js' +import { useTablesStore as store } from '../../src/store/store.js' +import { useDataStore as data } from '../../src/store/data.js' // Styles necessary for rendering the component import '../styleguide/assets/default.css' From 3ef4e282bcfc3711b50de7055404a84d5f0831d1 Mon Sep 17 00:00:00 2001 From: "Enjeck C." Date: Mon, 28 Jul 2025 21:11:21 +0100 Subject: [PATCH 2/6] fix(tests): Update ContentReferenceWidget and scripts Signed-off-by: Enjeck C. --- cypress/component/ContentReferenceWidget.cy.js | 13 +++++++------ cypress/styleguide/global.requires.js | 5 +---- cypress/support/component.js | 13 ++++++++----- package.json | 4 +++- src/views/ContentReferenceWidget.vue | 2 +- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/cypress/component/ContentReferenceWidget.cy.js b/cypress/component/ContentReferenceWidget.cy.js index 27862b07e1..a2fa0627c5 100644 --- a/cypress/component/ContentReferenceWidget.cy.js +++ b/cypress/component/ContentReferenceWidget.cy.js @@ -22,7 +22,7 @@ describe('ContentReferenceWidget', () => { // Verify the table loaded the richObject // by checking the title - cy.get('.tables-content-widget h2').as('heading') + cy.get('[data-cy="contentReferenceWidget"] h2').as('heading') cy.get('@heading').contains(title) }) @@ -32,7 +32,7 @@ describe('ContentReferenceWidget', () => { const searchTerm = 'cat' // Search for the row including the above search term - cy.get('@options').find('input').type(searchTerm) + cy.get('@options').find('input').first().type(searchTerm) // Ensure there is only one resultant row and // verify the row correctly includes the search term @@ -47,11 +47,11 @@ describe('ContentReferenceWidget', () => { // Load a fixture used to reply to the create row request cy.fixture('widgets/createRow.json') .then((rowData) => { - cy.reply('**/index.php/apps/tables/row', rowData) + cy.reply('**/ocs/v2.php/apps/tables/api/2/tables/*/rows', rowData) }) // Click the Create Row button - cy.get('@options').find('button').click() + cy.get('@options').find('button').first().click() // Input row data cy.get('[data-cy="Name"] input').type('Hello') @@ -62,6 +62,7 @@ describe('ContentReferenceWidget', () => { cy.get('.modal__content').should('not.exist') // Make sure the row was added and is visible + cy.wait(1000) // Wait for the row to be added cy.get('@rows').last().children().as('createdRow') cy.get('@createdRow').first().contains('Hello') cy.get('@createdRow').next().contains('World') @@ -108,7 +109,7 @@ function mountContentWidget(richObject) { }) // Get some often used elements - cy.get('.tables-content-widget > .options').as('options') - cy.get('.tables-content-widget .NcTable table').as('table') + cy.get('[data-cy="contentReferenceWidget"] .options').as('options') + cy.get('[data-cy="contentReferenceWidget"] .NcTable table').as('table') cy.get('@table').find('tbody tr[data-cy="customTableRow"]').as('rows') } diff --git a/cypress/styleguide/global.requires.js b/cypress/styleguide/global.requires.js index 553f45cba3..3ce16d67b5 100644 --- a/cypress/styleguide/global.requires.js +++ b/cypress/styleguide/global.requires.js @@ -5,7 +5,6 @@ /* eslint-disable-next-line */ import 'core-js/stable' import Vue from 'vue' -import VTooltip from './../src/directives/Tooltip/index.js' import axios from '@nextcloud/axios' @@ -141,7 +140,7 @@ window.OC = { webroot: '', } window.OCA = {} -window.appName = 'nextcloud-vue' +window.appName = 'tables' Vue.prototype.OC = window.OC Vue.prototype.OCA = window.OCA @@ -149,5 +148,3 @@ Vue.prototype.OCA = window.OCA window.NextcloudVueDocs = { tags: '/remote.php/dav/systemtags/HTTP/1.1 404 Not Found/remote.php/dav/systemtags/77tag1truetruetrueHTTP/1.1 200 OK/remote.php/dav/systemtags/22tag2falsetruetrueHTTP/1.1 200 OK/remote.php/dav/systemtags/33tag3truetruetrueHTTP/1.1 200 OK/remote.php/dav/systemtags/44importanttruetruetrueHTTP/1.1 200 OK/remote.php/dav/systemtags/11secrettruefalsetrueHTTP/1.1 200 OK/remote.php/dav/systemtags/55testtruefalsetrueHTTP/1.1 200 OK/remote.php/dav/systemtags/66test2falsefalsetrueHTTP/1.1 200 OK', } - -Vue.directive('tooltip', VTooltip) diff --git a/cypress/support/component.js b/cypress/support/component.js index 3ac56c022c..767b6be52b 100644 --- a/cypress/support/component.js +++ b/cypress/support/component.js @@ -4,8 +4,13 @@ */ import { mount } from 'cypress/vue2' import { translate as t, translatePlural as n } from '@nextcloud/l10n' -import { useTablesStore as store } from '../../src/store/store.js' -import { useDataStore as data } from '../../src/store/data.js' +import { createPinia, PiniaVuePlugin } from 'pinia' +import Vue from 'vue' + +import '../styleguide/global.requires.js' + +Vue.use(PiniaVuePlugin) +const pinia = createPinia() // Styles necessary for rendering the component import '../styleguide/assets/default.css' @@ -13,13 +18,11 @@ import '../styleguide/assets/additional.css' import '../styleguide/assets/icons.css' const prepareOptions = (options = {}) => { - store.data = data - const defaultOptions = { + pinia, extensions: { mixins: [ { methods: { t, n } }, - { store, }, ], plugins: [], components: {}, diff --git a/package.json b/package.json index d46d52890b..01e3bdd60d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,9 @@ "lint": "eslint --ext .js,.vue src", "lint:fix": "eslint --ext .js,.vue src --fix", "stylelint": "stylelint 'css/*.css' 'css/*.scss' 'src/**/*.scss' 'src/**/*.vue'", - "stylelint:fix": "stylelint 'css/*.css' 'css/*.scss' 'src/**/*.scss' 'src/**/*.vue' --fix" + "stylelint:fix": "stylelint 'css/*.css' 'css/*.scss' 'src/**/*.scss' 'src/**/*.vue' --fix", + "tests": "npx cypress run", + "tests:component": "npx cypress run --component" }, "dependencies": { "@mdi/svg": "^7.4.47", diff --git a/src/views/ContentReferenceWidget.vue b/src/views/ContentReferenceWidget.vue index 64c20b9b5d..30e9e5ee69 100644 --- a/src/views/ContentReferenceWidget.vue +++ b/src/views/ContentReferenceWidget.vue @@ -3,7 +3,7 @@ - SPDX-License-Identifier: AGPL-3.0-or-later -->