From cea1d3a5899e903de348e74ad2fdbc1070c2b505 Mon Sep 17 00:00:00 2001 From: Florian Steffens Date: Mon, 11 Sep 2023 23:17:27 +0200 Subject: [PATCH] add cypress test for unified search test with a shared via user table Signed-off-by: Florian Steffens --- cypress/e2e/tables-unified-search.cy.js | 31 +++++++++++++++++++++++++ cypress/support/commands.js | 17 +++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/tables-unified-search.cy.js b/cypress/e2e/tables-unified-search.cy.js index e2fcd9d73..c5e32536a 100644 --- a/cypress/e2e/tables-unified-search.cy.js +++ b/cypress/e2e/tables-unified-search.cy.js @@ -1,4 +1,5 @@ let localUser +let localUser2 describe('The Home Page', () => { @@ -6,6 +7,9 @@ describe('The Home Page', () => { cy.createRandomUser().then(user => { localUser = user }) + cy.createRandomUser().then(user => { + localUser2 = user + }) }) beforeEach(function() { @@ -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') + }) }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 51f84247a..56a2f53c0 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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) => { @@ -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)