Skip to content

Commit

Permalink
add cypress test for unified search test with a shared via user table
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
  • Loading branch information
Florian Steffens committed Sep 11, 2023
1 parent 58cc255 commit cea1d3a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
31 changes: 31 additions & 0 deletions cypress/e2e/tables-unified-search.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
let localUser
let localUser2

describe('The Home Page', () => {

before(function() {
cy.createRandomUser().then(user => {
localUser = user
})
cy.createRandomUser().then(user => {
localUser2 = user
})
})

beforeEach(function() {
Expand All @@ -22,4 +26,31 @@ describe('The Home Page', () => {
cy.loadTable('Tutorial')
cy.unifiedSearch('Tutorial')
})

it('Search for shared table via user share', () => {
cy.login(localUser)
cy.visit('apps/tables')

// create table to share
cy.contains('.app-menu-entry--label', 'Tables').click()
cy.createTable('Share for user')
cy.createTextLineColumn('any', true)

cy.get('.app-navigation-entry-link').contains('Share for user').click({ force: true })
cy.get('.NcTable table tr th').last().find('button').click({ force: true })
cy.get('.v-popper__popper.v-popper--theme-dropdown.action-item__popper.v-popper__popper--shown').contains('Share').click({ force: true })

cy.intercept({ method: 'GET', url: '**/ocs/v2.php/apps/files_sharing/api/v1/sharees*' }).as('searchShareUsers')
cy.get('.sharing input').type(localUser2.userId)
cy.wait('@searchShareUsers')
cy.get('.sharing input').type('{enter}')

cy.get('h3').contains('Shares').parent().find('ul').contains(localUser2.userId).should('exist')
})

it('Search for shared table', () => {
cy.login(localUser2)
cy.visit('apps/tables')
cy.unifiedSearch('Share for user')
})
})
17 changes: 16 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Cypress.Commands.add('createTable', (title) => {
cy.get('.modal__content input[type="text"]').clear().type(title)
cy.contains('button', 'Create table').click()

cy.contains('h1', 'Test text-link').should('be.visible')
cy.contains('h1', title).should('be.visible')
})

Cypress.Commands.add('createView', (title) => {
Expand Down Expand Up @@ -89,6 +89,21 @@ Cypress.Commands.add('createTextLinkColumn', (title, ressourceProvider, firstCol
cy.get('.custom-table table tr th .cell').contains(title).should('exist')
})

Cypress.Commands.add('createTextLineColumn', (title, firstColumn) => {
if (firstColumn) {
cy.get('.button-vue__text').contains('Create column').click({ force: true })
} else {
cy.get('[data-cy="customTableAction"] button').click()
cy.get('.v-popper__popper li button span').contains('Create column').click({ force: true })
}

cy.get('.modal-container').get('input[placeholder*="Enter a column title"]').clear().type(title)
cy.get('.modal-container button').contains('Save').click()

cy.wait(10).get('.toastify.toast-success').should('be.visible')
cy.get('.custom-table table tr th .cell').contains(title).should('exist')
})

Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => {
return cy.fixture(fileName, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
Expand Down

0 comments on commit cea1d3a

Please sign in to comment.