From 7c2ef9fa0a48bbdc02c0b6f98b3e022ea053aa98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 30 Jan 2024 10:47:39 +0100 Subject: [PATCH 1/2] fix: Properly insert rows into views for the new db structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/RowService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Service/RowService.php b/lib/Service/RowService.php index a789cc075..c9b04934c 100644 --- a/lib/Service/RowService.php +++ b/lib/Service/RowService.php @@ -195,6 +195,7 @@ public function create(?int $tableId, ?int $viewId, array $data): Row2 { $data = $this->cleanupData($data, $columns, $tableId, $viewId); // perf + $tableId = $tableId ?? $view->getTableId(); $row2 = new Row2(); $row2->setTableId($tableId); $row2->setData($data); From 0843c53350c24bb4563c59dd87efa8aad2498e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 1 Feb 2024 11:59:01 +0100 Subject: [PATCH 2/2] test(views): Add e2e test for creating new rows in a view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- cypress/e2e/view.cy.js | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 cypress/e2e/view.cy.js diff --git a/cypress/e2e/view.cy.js b/cypress/e2e/view.cy.js new file mode 100644 index 000000000..92a949b90 --- /dev/null +++ b/cypress/e2e/view.cy.js @@ -0,0 +1,77 @@ +let localUser + +describe('Interact with views', () => { + + before(function() { + cy.createRandomUser().then(user => { + localUser = user + }) + }) + + beforeEach(function() { + cy.login(localUser) + cy.visit('apps/tables') + }) + + it('Create view and insert rows in the view', () => { + const title = 'View for adding rows' + cy.createTable('View filtering test table') + cy.createTextLineColumn('title', null, null, true) + cy.createSelectionColumn('selection', ['sel1', 'sel2', 'sel3', 'sel4'], null, false) + + // add row + cy.get('button').contains('Create row').click() + cy.fillInValueTextLine('title', 'first row') + cy.fillInValueSelection('selection', 'sel1') + cy.get('button').contains('Save').click() + + // add row + cy.get('button').contains('Create row').click() + cy.fillInValueTextLine('title', 'second row') + cy.fillInValueSelection('selection', 'sel2') + cy.get('button').contains('Save').click() + + // add row + cy.get('button').contains('Create row').click() + cy.fillInValueTextLine('title', 'sevenths row') + cy.fillInValueSelection('selection', 'sel2') + cy.get('button').contains('Save').click() + + cy.get('[data-cy="customTableAction"] button').click() + cy.get('.v-popper__popper li button span').contains('Create view').click({ force: true }) + cy.get('.modal-container #settings-section_title input').type(title) + + // ## add filter + cy.get('button').contains('Add new filter group').click() + cy.get('.modal-container .filter-group .v-select.select').eq(0).click() + cy.get('ul.vs__dropdown-menu li span[title="selection"]').click() + cy.get('.modal-container .filter-group .v-select.select').eq(1).click() + cy.get('ul.vs__dropdown-menu li span[title="Is equal"]').click() + cy.get('.modal-container .filter-group .v-select.select').eq(2).click() + cy.get('ul.vs__dropdown-menu li span[title="sel2"]').click() + + // ## save view + cy.intercept({ method: 'POST', url: '**/apps/tables/view' }).as('createView') + cy.intercept({ method: 'PUT', url: '**/apps/tables/view/*' }).as('updateView') + cy.contains('button', 'Create View').click() + cy.wait('@createView') + cy.wait('@updateView') + cy.contains('.app-navigation-entry-link span', title).should('exist') + + const expected = ['sevenths row', 'second row'] + expected.forEach(item => { + cy.get('.custom-table table tr td div').contains(item).should('be.visible') + }) + + // Add new row in the views + cy.get('button').contains('Create row').click() + cy.fillInValueTextLine('title', 'new row') + cy.fillInValueSelection('selection', 'sel2') + cy.get('button').contains('Save').click() + + expected.push('new row') + expected.forEach(item => { + cy.get('.custom-table table tr td div').contains(item).should('be.visible') + }) + }) +}) \ No newline at end of file