Skip to content

Commit 4aa7528

Browse files
committed
fix(tests): Update ContentReferenceWidget and scripts
Signed-off-by: Enjeck C. <[email protected]>
1 parent 9fda371 commit 4aa7528

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

cypress/component/ContentReferenceWidget.cy.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('ContentReferenceWidget', () => {
2222

2323
// Verify the table loaded the richObject
2424
// by checking the title
25-
cy.get('.tables-content-widget h2').as('heading')
25+
cy.get('[data-cy="contentReferenceWidget"] h2').as('heading')
2626
cy.get('@heading').contains(title)
2727
})
2828

@@ -32,7 +32,7 @@ describe('ContentReferenceWidget', () => {
3232
const searchTerm = 'cat'
3333

3434
// Search for the row including the above search term
35-
cy.get('@options').find('input').type(searchTerm)
35+
cy.get('@options').find('input').first().type(searchTerm)
3636

3737
// Ensure there is only one resultant row and
3838
// verify the row correctly includes the search term
@@ -47,11 +47,11 @@ describe('ContentReferenceWidget', () => {
4747
// Load a fixture used to reply to the create row request
4848
cy.fixture('widgets/createRow.json')
4949
.then((rowData) => {
50-
cy.reply('**/index.php/apps/tables/row', rowData)
50+
cy.reply('**/ocs/v2.php/apps/tables/api/2/tables/*/rows', rowData)
5151
})
5252

5353
// Click the Create Row button
54-
cy.get('@options').find('button').click()
54+
cy.get('@options').find('button').first().click()
5555

5656
// Input row data
5757
cy.get('[data-cy="Name"] input').type('Hello')
@@ -62,6 +62,7 @@ describe('ContentReferenceWidget', () => {
6262
cy.get('.modal__content').should('not.exist')
6363

6464
// Make sure the row was added and is visible
65+
cy.wait(1000) // Wait for the row to be added
6566
cy.get('@rows').last().children().as('createdRow')
6667
cy.get('@createdRow').first().contains('Hello')
6768
cy.get('@createdRow').next().contains('World')
@@ -108,7 +109,7 @@ function mountContentWidget(richObject) {
108109
})
109110

110111
// Get some often used elements
111-
cy.get('.tables-content-widget > .options').as('options')
112-
cy.get('.tables-content-widget .NcTable table').as('table')
112+
cy.get('[data-cy="contentReferenceWidget"] .options').as('options')
113+
cy.get('[data-cy="contentReferenceWidget"] .NcTable table').as('table')
113114
cy.get('@table').find('tbody tr[data-cy="customTableRow"]').as('rows')
114115
}

cypress/styleguide/global.requires.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/* eslint-disable-next-line */
66
import 'core-js/stable'
77
import Vue from 'vue'
8-
import VTooltip from './../src/directives/Tooltip/index.js'
98

109
import axios from '@nextcloud/axios'
1110

@@ -141,13 +140,11 @@ window.OC = {
141140
webroot: '',
142141
}
143142
window.OCA = {}
144-
window.appName = 'nextcloud-vue'
143+
window.appName = 'tables'
145144

146145
Vue.prototype.OC = window.OC
147146
Vue.prototype.OCA = window.OCA
148147

149148
window.NextcloudVueDocs = {
150149
tags: '<?xml version="1.0"?><d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/dav/systemtags/</d:href><d:propstat><d:prop><oc:id/><oc:display-name/><oc:user-visible/><oc:user-assignable/><oc:can-assign/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/7</d:href><d:propstat><d:prop><oc:id>7</oc:id><oc:display-name>tag1</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/2</d:href><d:propstat><d:prop><oc:id>2</oc:id><oc:display-name>tag2</oc:display-name><oc:user-visible>false</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/3</d:href><d:propstat><d:prop><oc:id>3</oc:id><oc:display-name>tag3</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/4</d:href><d:propstat><d:prop><oc:id>4</oc:id><oc:display-name>important</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/1</d:href><d:propstat><d:prop><oc:id>1</oc:id><oc:display-name>secret</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>false</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/5</d:href><d:propstat><d:prop><oc:id>5</oc:id><oc:display-name>test</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>false</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/6</d:href><d:propstat><d:prop><oc:id>6</oc:id><oc:display-name>test2</oc:display-name><oc:user-visible>false</oc:user-visible><oc:user-assignable>false</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>',
151150
}
152-
153-
Vue.directive('tooltip', VTooltip)

cypress/support/component.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@
44
*/
55
import { mount } from 'cypress/vue2'
66
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
7-
import { useTablesStore as store } from '../../src/store/store.js'
8-
import { useDataStore as data } from '../../src/store/data.js'
7+
import { createPinia, PiniaVuePlugin } from 'pinia'
8+
import Vue from 'vue'
9+
10+
import '../styleguide/global.requires.js'
11+
12+
Vue.use(PiniaVuePlugin)
13+
const pinia = createPinia()
914

1015
// Styles necessary for rendering the component
1116
import '../styleguide/assets/default.css'
1217
import '../styleguide/assets/additional.css'
1318
import '../styleguide/assets/icons.css'
1419

1520
const prepareOptions = (options = {}) => {
16-
store.data = data
17-
1821
const defaultOptions = {
22+
pinia,
1923
extensions: {
2024
mixins: [
2125
{ methods: { t, n } },
22-
{ store, },
2326
],
2427
plugins: [],
2528
components: {},

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"lint": "eslint --ext .js,.vue src",
2424
"lint:fix": "eslint --ext .js,.vue src --fix",
2525
"stylelint": "stylelint 'css/*.css' 'css/*.scss' 'src/**/*.scss' 'src/**/*.vue'",
26-
"stylelint:fix": "stylelint 'css/*.css' 'css/*.scss' 'src/**/*.scss' 'src/**/*.vue' --fix"
26+
"stylelint:fix": "stylelint 'css/*.css' 'css/*.scss' 'src/**/*.scss' 'src/**/*.vue' --fix",
27+
"tests": "npx cypress run",
28+
"tests:component": "npx cypress run --component"
2729
},
2830
"dependencies": {
2931
"@mdi/svg": "^7.4.47",

src/views/ContentReferenceWidget.vue

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
<template>
6-
<div v-if="richObject" class="tables-content-widget">
6+
<div v-if="richObject" class="tables-content-widget" data-cy="contentReferenceWidget">
77
<div class="header">
88
<h2>
99
<NcLoadingIcon v-if="!rows || rows.length === 0" :size="30" />

0 commit comments

Comments
 (0)