Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6f98de6
feat(pages): add a tabs widget whose tabs hold their own widgets
rubenvdlinde Nov 2, 2026
988d6d5
test(pages): find a table in a tab by the title of its widget
rubenvdlinde Nov 5, 2026
c2226ca
test(pages): send the version of a new page with its widgets in the t…
rubenvdlinde Nov 10, 2026
694e7f7
refactor(pages): render each level of a grid through one GridLevel co…
rubenvdlinde Nov 19, 2026
bdc08cd
fix(pages): keep the grid of a tab apart from the grid of the page
rubenvdlinde Nov 19, 2026
e5280d0
fix(tables): destroy a description editor that is ready after unmount
rubenvdlinde Nov 19, 2026
c03d59d
fix(pages): name the description button after its table and keep its …
rubenvdlinde Nov 19, 2026
250186c
fix(pages): let the canvas of a tab follow the column mode of the page
rubenvdlinde Nov 19, 2026
000aa29
fix(pages): let the headings in a tab follow the level of the tabs wi…
rubenvdlinde Nov 19, 2026
3674656
fix(pages): keep the tabs of a tabs widget mounted once they are opened
rubenvdlinde Nov 19, 2026
003c3ce
fix(pages): name the tab list after its widget and make its panel foc…
rubenvdlinde Nov 19, 2026
25bf340
fix(pages): give an empty tab its own message
rubenvdlinde Nov 19, 2026
2e52049
fix(pages): share the keyboard handling of the page bar and the tabs …
rubenvdlinde Nov 19, 2026
ce91d52
refactor(pages): drop the dead branches around the tabs widget
rubenvdlinde Nov 19, 2026
395edca
test(pages): find the menu of a widget in a tab by its name with the …
rubenvdlinde Nov 19, 2026
258ad79
fix(pages): file the widgets of a tab under the key of the tab
rubenvdlinde Nov 20, 2026
d8496b7
feat(pages): edit the tabs of a tabs widget in a tab editor
rubenvdlinde Nov 20, 2026
c295244
test(pages): add a text widget in the open tab of the tabs spec
rubenvdlinde Nov 22, 2026
c4cff6d
test(pages): pick the widget types of the tabs spec by their accessib…
rubenvdlinde Nov 25, 2026
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
24 changes: 22 additions & 2 deletions cypress/component/AddWidget.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ const nodes = { 4: { id: 4, node_type: 0, node_id: 40, permissions: 1 } }

/**
* @param {object} props props of the dialog besides showModal
* @param {Array} types the widget types the server sends
*/
function mountDialog(props = {}) {
cy.intercept('GET', '**/apps/tables/api/2/widget-types', { ocs: { data: widgetTypes } }).as('widgetTypes')
function mountDialog(props = {}, types = widgetTypes) {
cy.intercept('GET', '**/apps/tables/api/2/widget-types', { ocs: { data: types } }).as('widgetTypes')
cy.mount(AddWidget, { props: { showModal: false, nodes, ...props } }).then(({ wrapper }) => {
const store = useTablesStore()
store.widgetTypes = []
Expand Down Expand Up @@ -190,4 +191,23 @@ describe('AddWidget', () => {
cy.get('[data-cy="iconFieldClear"]').should('not.exist')
cy.focused().should('have.attr', 'data-cy', 'iconFieldPick')
})

it('edits the tabs of a tabs widget and asks for a title for each tab', () => {
const tabsType = { type: 'tabs', title: 'Tabs', defaultWidth: 12, defaultHeight: 8, hasSource: false, settings: { tabs: { type: 'tabs', title: 'Tabs', default: [], required: true, maxItems: 20 } } }
mountDialog({}, [tabsType])

cy.get('[data-cy="widgetFieldTabs"] textarea').should('not.exist')
cy.get('[data-cy="addWidgetMissing"]').should('contain.text', 'Still needed: Tabs')
cy.get('[data-cy="tabsEditorAdd"]').click()
cy.focused().type('\u00A0\u3000', { parseSpecialCharSequences: false })
cy.get('[data-cy="addWidgetSubmit"]').should('be.disabled')
cy.focused().clear().type('Open')
cy.get('[data-cy="addWidgetSubmit"]').should('be.enabled').click()
cy.get('@wrapper').then(wrapper => {
const tabs = wrapper.emitted('submit')[0][0].settings.tabs
expect(tabs).to.have.length(1)
expect(tabs[0]).to.deep.include({ title: 'Open' })
expect(tabs[0].key).to.match(/^[0-9a-f]{12}$/)
})
})
})
57 changes: 57 additions & 0 deletions cypress/component/CollapsibleDescription.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import CollapsibleDescription from '../../src/modules/main/sections/CollapsibleDescription.vue'
import TableDescription from '../../src/modules/main/sections/TableDescription.vue'

describe('CollapsibleDescription', () => {
beforeEach(() => {
// The description is rendered by the editor of the Text app
window.OCA = { ...window.OCA, Text: { createEditor: () => Promise.resolve({ destroy() {}, setReadOnly() {} }) } }
})

it('shows the description behind a button named after its table, whose state is only in aria-expanded', () => {
cy.mount(CollapsibleDescription, { props: { description: 'What this table is for', title: 'Q&A' } })

const toggle = () => cy.get('[data-cy="collapsibleDescriptionToggle"]')
toggle().should('have.attr', 'aria-expanded', 'false').and('contain.text', 'Description of Q&A').and('not.have.attr', 'aria-controls')
cy.get('.element-description').should('not.exist')
toggle().click()
toggle().should('have.attr', 'aria-expanded', 'true').and('contain.text', 'Description of Q&A')
toggle().invoke('attr', 'aria-controls').then(id => cy.get('#' + id).find('.element-description').should('exist'))

// A blank description shows nothing
cy.mount(CollapsibleDescription, { props: { description: ' ' } })
cy.get('[data-cy="collapsibleDescription"]').should('not.exist')
})

it('keeps one panel and one editor when it is opened and closed again', () => {
const createEditor = cy.stub().resolves({ destroy() {}, setReadOnly() {} })
window.OCA.Text.createEditor = createEditor
cy.mount(CollapsibleDescription, { props: { description: 'What this table is for', title: 'Tasks' } })

const toggle = () => cy.get('[data-cy="collapsibleDescriptionToggle"]')
toggle().click()
toggle().invoke('attr', 'aria-controls').then(id => {
toggle().click()
cy.get('#' + id).should('exist').and('not.be.visible')
toggle().click()
cy.get('.collapsible-description__panel').should('have.length', 1).and('have.id', id).and('be.visible')
})
cy.then(() => expect(createEditor).to.have.been.calledOnce)
})
})

describe('TableDescription', () => {
it('destroys an editor that is ready after the description left the page', () => {
let resolveEditor
const editor = { destroy: cy.stub().as('destroy'), setReadOnly() {} }
window.OCA = { ...window.OCA, Text: { createEditor: () => new Promise(resolve => { resolveEditor = resolve }) } }
cy.mount(TableDescription, { props: { description: 'What this table is for', readOnly: true } }).then(({ wrapper }) => {
wrapper.unmount()
resolveEditor(editor)
})
cy.get('@destroy').should('have.been.calledOnce')
})
})
13 changes: 13 additions & 0 deletions cypress/component/ContextPageBar.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ describe('ContextPageBar', () => {
mountBar({ canManage: true })
cy.get('[data-cy="contextPageAdd"]').should('be.visible')
})

it('leaves a key with Alt, Ctrl or Meta to the browser', () => {
mountBar({ selectedPageId: 5 })

cy.get('[role="tab"][tabindex="0"]').then(tab => {
for (const modifier of ['altKey', 'ctrlKey', 'metaKey']) {
const event = new KeyboardEvent('keydown', { key: 'ArrowRight', [modifier]: true, bubbles: true, cancelable: true })
tab[0].dispatchEvent(event)
expect(event.defaultPrevented).to.equal(false)
}
})
cy.get('[role="tab"][tabindex="0"]').should('have.length', 1).and('contain.text', 'Overview')
})
})
38 changes: 37 additions & 1 deletion cypress/component/GridCanvas.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { h } from 'vue'
import { h, ref } from 'vue'
import GridCanvas from '../../src/modules/grid/GridCanvas.vue'

const layout = [
Expand Down Expand Up @@ -140,4 +140,40 @@ describe('GridCanvas', () => {
expect({ x: node.x, y: node.y, w: node.w, h: node.h }).to.deep.equal({ x: 6, y: 4, w: 4, h: 2 })
})
})

it('keeps the grid of a canvas inside a widget apart from the grid around it', () => {
cy.viewport(1400, 800)
const inner = [{ widgetId: 'i1', gridX: 0, gridY: 0, gridWidth: 6, gridHeight: 2 }]
// The nested canvas mounts after the outer grid, as the canvas of a tab that is opened
const showNested = ref(false)
cy.mount(GridCanvas, {
props: { layout: [{ widgetId: 'w1', gridX: 0, gridY: 0, gridWidth: 12, gridHeight: 6 }], editable: false },
slots: { widget: () => showNested.value ? h(GridCanvas, { layout: inner, editable: false }, { widget: ({ item }) => h('span', item.widgetId) }) : null },
}).then(({ wrapper }) => {
cy.get('[gs-id="w1"]').should('exist').then(() => {
showNested.value = true
})
cy.contains('i1').should('exist').then(() => {
const nested = wrapper.findComponent(GridCanvas)
expect(nested.vm.grid.parentGridNode).to.equal(undefined)
expect(wrapper.vm.grid.engine.nodes[0].subGrid).to.equal(undefined)
})
})
})

it('arranges a nested canvas whenever the canvas around it does, however narrow it is', () => {
cy.viewport(1400, 800)
const gridNarrow = ref(false)
cy.mount(() => h('div', { style: 'width: 600px' }, [h(GridCanvas, { layout, editable: true }, { widget: ({ item, narrow }) => h('span', { 'data-cy': 'slotWidget', 'data-narrow': String(narrow) }, item.widgetId) })]), {
global: { provide: { gridNarrow: gridNarrow } },
})

cy.get('[data-cy="slotWidget"]').first().should('have.attr', 'data-narrow', 'false')
cy.get('[data-cy="gridNarrowHint"]').should('not.exist')
cy.get('[data-cy="gridItem"][gs-id="w2"]').should('have.attr', 'gs-w', '6')

cy.then(() => { gridNarrow.value = true })
cy.get('[data-cy="slotWidget"]').first().should('have.attr', 'data-narrow', 'true')
cy.get('[data-cy="gridNarrowHint"]').should('not.exist')
})
})
102 changes: 102 additions & 0 deletions cypress/component/TabsEditor.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import TabsEditor from '../../src/modules/grid/TabsEditor.vue'

/**
* Mounts the editor with v-model: every update becomes its new value and is kept in `@tabs`.
*
* @param {Array<{key: string, title: string}>} tabs the tabs to start with
* @param {object} props other props of the editor
*/
function mountEditor(tabs, props = {}) {
const current = { tabs }
let mounted = null
cy.wrap(current).as('current')
cy.mount(TabsEditor, {
props: {
modelValue: tabs,
label: 'Tabs',
required: true,
...props,
'onUpdate:modelValue': value => {
current.tabs = value
mounted.setProps({ modelValue: value })
},
},
}).then(({ wrapper }) => {
mounted = wrapper
})
}

/**
* @return {Cypress.Chainable} the current tabs
*/
function currentTabs() {
return cy.get('@current').its('tabs')
}

describe('TabsEditor', () => {
it('adds, renames, moves and removes tabs and keeps the key of each tab', () => {
mountEditor([{ key: 'open', title: 'Open' }, { key: 'closed', title: 'Closed' }])

cy.get('[data-cy="tabsEditorAdd"]').click()
cy.focused().should('have.attr', 'type', 'text').type('Later')
currentTabs().then(tabs => {
expect(tabs.map(tab => tab.title)).to.deep.equal(['Open', 'Closed', 'Later'])
expect(tabs[2].key).to.match(/^[0-9a-f]{12}$/)
})

cy.get('[data-cy="tabsEditorTitle"]').eq(0).clear().type('Doing')
cy.get('[data-cy="tabsEditorDown"]').eq(0).click()
currentTabs().then(tabs => {
expect(tabs.slice(0, 2)).to.deep.equal([{ key: 'closed', title: 'Closed' }, { key: 'open', title: 'Doing' }])
})

cy.get('[data-cy="tabsEditorRemove"]').eq(0).click()
currentTabs().then(tabs => expect(tabs.map(tab => tab.key).slice(0, 1)).to.deep.equal(['open']))
cy.get('[data-cy="tabsEditorAnnouncement"]').should('have.text', 'Tab Closed removed.')
cy.focused().should('have.value', 'Doing')
})

it('names each button after its tab, announces a move and keeps the focus on a button that still works', () => {
mountEditor([{ key: 'a', title: 'First' }, { key: 'b', title: 'Second' }, { key: 'c', title: 'Third' }])

cy.get('[data-cy="tabsEditorTab"]').eq(0).find('label').should('contain.text', 'Title of tab 1')
cy.get('[data-cy="tabsEditorUp"]').eq(0).should('be.disabled')
cy.get('[data-cy="tabsEditorDown"]').eq(1).should('have.attr', 'aria-label', 'Move tab Second down').click()
cy.get('[data-cy="tabsEditorAnnouncement"]').should('have.text', 'Tab Second moved to position 3 of 3.')
// The tab is last now, so its down button is disabled and the focus goes to its up button
cy.focused().should('have.attr', 'aria-label', 'Move tab Second up')
cy.focused().click()
cy.get('[data-cy="tabsEditorAnnouncement"]').should('have.text', 'Tab Second moved to position 2 of 3.')
cy.focused().should('have.attr', 'aria-label', 'Move tab Second up')
currentTabs().then(tabs => expect(tabs.map(tab => tab.key)).to.deep.equal(['a', 'b', 'c']))
})

it('marks the list as required without the mark in its name', () => {
mountEditor([])

cy.get('legend').should('contain.text', 'Tabs *')
cy.get('legend [aria-hidden="true"]').should('have.text', ' *')
})

it('stops at the most tabs the schema allows', () => {
mountEditor([{ key: 'a', title: 'First' }], { maxItems: 2 })

cy.get('[data-cy="tabsEditorHint"]').should('contain.text', '1 of at most 2 tabs')
cy.get('[data-cy="tabsEditorAdd"]').should('be.enabled').click()
cy.get('[data-cy="tabsEditorAdd"]').should('be.disabled')
cy.get('[data-cy="tabsEditorHint"]').should('contain.text', '2 of at most 2 tabs')
})

it('marks a title of blanks only, no-break and zero width spaces too, once it was left', () => {
mountEditor([{ key: 'a', title: '\u00A0\u200B\u3000' }])

cy.get('[data-cy="tabsEditor"]').should('not.contain.text', 'Give this tab a title.')
cy.get('[data-cy="tabsEditorTitle"]').focus().blur()
cy.get('[data-cy="tabsEditor"]').should('contain.text', 'Give this tab a title.')
cy.get('[data-cy="tabsEditorRemove"]').should('have.attr', 'aria-label', 'Remove tab 1')
})
})
Loading
Loading