Skip to content
Merged
Show file tree
Hide file tree
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
32 changes: 24 additions & 8 deletions cypress/e2e/tables-import.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ describe('Import csv', () => {
})

describe('Import csv from Files file action', () => {
const rowActionsButton = '[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button'
const importToTablesAction = '[data-cy-files-list-row-action="import-to-tables"]'

const openImportToTablesAction = (retries = 8) => {
cy.get(rowActionsButton).click()
cy.get('body').then($body => {
if ($body.find(importToTablesAction).length > 0) {
cy.get(importToTablesAction).first().click()
return
}

if (retries <= 0) {
throw new Error('Import to Tables action did not become available in file actions menu')
}

cy.get('body').click(0, 0)
cy.wait(1000)
openImportToTablesAction(retries - 1)
})
}

before(function() {
cy.createRandomUser().then(user => {
Expand All @@ -115,15 +135,12 @@ describe('Import csv from Files file action', () => {

beforeEach(function() {
cy.login(localUser)
// Tables file actions register via init script; wait for the bundle before opening menus.
cy.intercept({ method: 'GET', url: '**/tables-files*' }).as('tablesFilesBundle')
cy.visit('apps/files/files')
cy.wait('@tablesFilesBundle', { timeout: 120000 })
cy.visit('apps/files/files', { timeout: 120000 })
cy.get('[data-cy-files-list-row-name="test-import.csv"]', { timeout: 120000 }).should('be.visible')
})

it('Import to new table', () => {
cy.get('[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button').click()
cy.get('[data-cy-files-list-row-action="import-to-tables"]').click()
openImportToTablesAction()

cy.intercept({
method: 'POST',
Expand All @@ -141,8 +158,7 @@ describe('Import csv from Files file action', () => {
})

it('Import to existing table', () => {
cy.get('[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button').click()
cy.get('[data-cy-files-list-row-action="import-to-tables"]').click()
openImportToTablesAction()

cy.get('.modal__content [data-cy="importAsNewTableSwitch"] input').uncheck({ force: true })
cy.get('[data-cy="selectExistingTableDropdown"]').type('Welcome to Nextcloud Tables!')
Expand Down
53 changes: 37 additions & 16 deletions cypress/e2e/view-filtering-selection-row-removal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ describe('Filtering in a view by selection columns (Cypress supplement – row r
})

it('Filter view remove row when it no longer matches filter', () => {
const waitForRowPresenceCheck = (alias, rowId, expectedPresent, retries = 10) => {
cy.wait(alias).then(({ request, response }) => {
if (request.url.includes(`/row/${rowId}/present`)) {
expect(response.body.present).to.equal(expectedPresent)
return
}

if (retries <= 0) {
throw new Error(`Did not receive /present check for row ${rowId}`)
}

waitForRowPresenceCheck(alias, rowId, expectedPresent, retries - 1)
})
}

let checkedRowId = null

// # create view with filter
// ## create view and set title
const title = 'Filter for check enabled'
Expand All @@ -110,30 +127,32 @@ describe('Filtering in a view by selection columns (Cypress supplement – row r
cy.contains('.app-navigation-entry-link span', title).should('exist')

// # insert a checked row
cy.intercept({ method: 'POST', url: '**/apps/tables/api/2/views/*/rows' }).as('insertRowInView')
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresentChecked')
cy.get('[data-cy="createRowBtn"]').click()
cy.fillInValueTextLine('title', 'checked row')
cy.fillInValueSelectionCheck('check')
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresent')
cy.get('[data-cy="createRowSaveButton"]').click()

// ## check server response for /view/{viewId}/row/{id}/present
cy.wait('@isRowInViewPresent').then(({ response: { body: { present } } }) => {
expect(present).to.equal(true)
cy.wait('@insertRowInView').then(({ response }) => {
checkedRowId = response.body.ocs.data.id
waitForRowPresenceCheck('@isRowInViewPresentChecked', checkedRowId, true)
})

// ## check if row is visible
cy.contains('[data-cy="ncTable"] [data-cy="customTableRow"]', 'checked row').should('be.visible')
cy.get('[data-cy="createRowModal"]').should('not.exist')

// # insert a unchecked row
cy.intercept({ method: 'POST', url: '**/apps/tables/api/2/views/*/rows' }).as('insertUncheckedRowInView')
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresentUnchecked')
cy.get('[data-cy="createRowBtn"]').click()
cy.fillInValueTextLine('title', 'unchecked row')
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresent')
cy.get('[data-cy="createRowSaveButton"]').click()

// ## check server response for /view/{viewId}/row/{id}/present
cy.wait('@isRowInViewPresent').then(({ response: { body: { present } } }) => {
expect(present).to.equal(false)
cy.wait('@insertUncheckedRowInView').then(({ response }) => {
const uncheckedRowId = response.body.ocs.data.id
waitForRowPresenceCheck('@isRowInViewPresentUnchecked', uncheckedRowId, false)
})

// ## check if row does not exist
Expand All @@ -142,14 +161,15 @@ describe('Filtering in a view by selection columns (Cypress supplement – row r

// # edit checked row
// ## uncheck
cy.intercept({ method: 'PUT', url: '**/apps/tables/row/*' }).as('updateCheckedRow')
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresentAfterEdit')
cy.contains('[data-cy="ncTable"] [data-cy="customTableRow"]', 'checked row').closest('[data-cy="customTableRow"]').find('[data-cy="editRowBtn"]').click()
cy.get('[data-cy="editRowModal"] .checkbox-radio-switch').click()
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresent')
cy.get('[data-cy="editRowSaveButton"]').click()

// ## check server response for /view/{viewId}/row/{id}/present
cy.wait('@isRowInViewPresent').then(({ response: { body: { present } } }) => {
expect(present).to.equal(false)
cy.wait('@updateCheckedRow')
cy.then(() => {
waitForRowPresenceCheck('@isRowInViewPresentAfterEdit', checkedRowId, false)
})

// ## check if row does not exist
Expand All @@ -158,12 +178,13 @@ describe('Filtering in a view by selection columns (Cypress supplement – row r

// # inline edit row
// ## uncheck row
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresent')
cy.intercept({ method: 'PUT', url: '**/apps/tables/row/*' }).as('inlineUpdateRow')
cy.intercept({ method: 'GET', url: '**/apps/tables/view/*/row/*/present' }).as('isRowInViewPresentAfterInlineEdit')
cy.contains('[data-cy="ncTable"] [data-cy="customTableRow"]', 'first row').closest('[data-cy="customTableRow"]').find('.inline-editing-container input').click({ force: true })

// ## check server response for /view/{viewId}/row/{id}/present
cy.wait('@isRowInViewPresent').then(({ response: { body: { present } } }) => {
expect(present).to.equal(false)
cy.wait('@inlineUpdateRow').then(({ request }) => {
const inlineUpdatedRowId = request.url.split('/').pop()
waitForRowPresenceCheck('@isRowInViewPresentAfterInlineEdit', inlineUpdatedRowId, false)
})

// ## check if row does not exist
Expand Down
Loading
Loading