-
Notifications
You must be signed in to change notification settings - Fork 50
1769 views set mandatory state of a column #2053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8b740a9
add mandatory key to ViewColumnInformation
silverkszlo 97dd915
add mandatory key to viewsettings
silverkszlo 60e2c80
check for mandatory in view col in rowhelper
silverkszlo 402e6ba
check for mandatory view cols in different types
silverkszlo c10b4fb
check for mandatory view cols in row creation and editing
silverkszlo 19a9774
fix: implement mandatory column validation in row data processing
enjeck 05e3afc
fix: redundant check
enjeck aa74524
refactor mandatory columns validation
silverkszlo f78a5c9
correct typo in viewsettings
silverkszlo b9fb79e
fix: mandatory datetime fields can not be cleared and saved anymore
silverkszlo 6ec6dc1
refactor rowHelper
silverkszlo 805577d
add column watchers and fix viewColumnInformation reactivity in views…
silverkszlo acabde9
add cypress tests for mandatory state in view columns
silverkszlo d02e0f5
add mandatory to ResponseDefinitions and generate openapi spec
silverkszlo d8240af
run php cs linter
silverkszlo d5fe8d2
remove side effects of mandatory and readonly states
silverkszlo 4176bb2
adjust cypress tests after previous typo correction in viewsettings
silverkszlo 3dcac43
fix unrelated failing view cypress test by restructuring
silverkszlo 35722be
add individual view titles in view cypress test
silverkszlo 89e4edb
reduce amount of tests in mandatory state testing
silverkszlo aa67d6c
validate mandatory usergroup types
silverkszlo 2f19064
fix: Properly validate selection-check type
enjeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
| let localUser | ||
|
|
||
| describe('Mandatory Column Functionality', () => { | ||
|
|
||
| before(function() { | ||
| cy.createRandomUser().then(user => { | ||
| localUser = user | ||
| }) | ||
| }) | ||
|
|
||
| beforeEach(function() { | ||
| cy.login(localUser) | ||
| cy.visit('apps/tables') | ||
| }) | ||
|
|
||
| it('Setup table with mandatory test columns and one row', () => { | ||
| cy.createTable('Mandatory test table') | ||
| cy.createTextLineColumn('title', null, null, true) | ||
| cy.createTextLineColumn('description', null, null, false) | ||
|
|
||
| // create one row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', 'first row') | ||
| cy.fillInValueTextLine('description', 'desc 1') | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
|
|
||
| // create a default view | ||
| cy.get('[data-cy="customTableAction"] button').click() | ||
| cy.get('.v-popper__popper li button span') | ||
| .contains('Create view') | ||
| .click({ force: true }) | ||
| cy.get('[data-cy="viewSettingsDialog"]').should('be.visible') | ||
| cy.get('[data-cy="viewSettingsDialogSection"] input').type('Mandatory test view') | ||
| cy.get('[data-cy="modifyViewBtn"]').click() | ||
| cy.get('.icon-loading').should('not.exist') | ||
| }) | ||
|
|
||
| describe('SelectedViewColumns - Mandatory Checkbox', () => { | ||
| beforeEach(() => { | ||
| cy.loadTable('Mandatory test table') | ||
|
|
||
| // create a new view | ||
| cy.get('[data-cy="customTableAction"] button').click() | ||
| cy.get('[data-cy="dataTableCreateViewBtn"]').contains('Create view').click({ force: true }) | ||
| cy.get('[data-cy="viewSettingsDialogSection"] input').type('Mandatory test view') | ||
|
|
||
| // ensure dialog is visible | ||
| cy.get('[data-cy="viewSettingsDialog"]').should('be.visible') | ||
| }) | ||
|
|
||
| const openColumnMenu = (columnTitle) => { | ||
| cy.contains('.column-entry', columnTitle) | ||
| .find('[data-cy="customColumnAction"] button') | ||
| .click({ force: true }) | ||
| } | ||
|
|
||
| const getMandatoryCheckbox = () => cy.get('[data-cy="columnMandatoryCheckbox"]').contains('Mandatory') | ||
|
|
||
| const getReadonlyCheckbox = () => cy.get('[data-cy="columnReadonlyCheckbox"]').contains('Read only') | ||
|
|
||
| it('should display mandatory checkbox for selected columns', () => { | ||
| openColumnMenu('title') | ||
| getMandatoryCheckbox().should('be.visible') | ||
| }) | ||
|
|
||
| it('should disable mandatory checkbox when readonly is enabled', () => { | ||
| openColumnMenu('title') | ||
|
|
||
| getReadonlyCheckbox().should('be.visible').click({ force: true }) | ||
|
|
||
| // Check that the readonly checkbox is checked | ||
| cy.get('[data-cy="columnReadonlyCheckbox"] input').should('be.checked') | ||
|
|
||
| // Check that mandatory checkbox input is disabled | ||
| cy.get('[data-cy="columnMandatoryCheckbox"] input').should('be.disabled') | ||
| }) | ||
|
|
||
| it('should disable readonly checkbox when mandatory is enabled', () => { | ||
| openColumnMenu('title') | ||
|
|
||
| getMandatoryCheckbox().should('be.visible').click({ force: true }) | ||
|
|
||
| // Check that the mandatory checkbox is checked | ||
| cy.get('[data-cy="columnMandatoryCheckbox"] input').should('be.checked') | ||
|
|
||
| // Check that readonly checkbox input is disabled | ||
| cy.get('[data-cy="columnReadonlyCheckbox"] input').should('be.disabled') | ||
| }) | ||
| }) | ||
|
|
||
| describe('EditRow - Mandatory Field Validation', () => { | ||
| beforeEach(() => { | ||
| cy.loadTable('Mandatory test table') | ||
|
|
||
| // Create a view with mandatory settings first | ||
| cy.get('[data-cy="customTableAction"] button').click() | ||
| cy.get('[data-cy="dataTableCreateViewBtn"]').contains('Create view').click({ force: true }) | ||
| cy.get('[data-cy="viewSettingsDialogSection"] input').type('Mandatory validation test view') | ||
|
|
||
| // Set title column as mandatory in the view | ||
| cy.contains('.column-entry', 'title') | ||
| .find('[data-cy="customColumnAction"] button') | ||
| .click({ force: true }) | ||
| cy.get('[data-cy="columnMandatoryCheckbox"]').contains('Mandatory').click({ force: true }) | ||
|
|
||
| // Save the view | ||
| cy.get('[data-cy="modifyViewBtn"]').click() | ||
| cy.get('.icon-loading').should('not.exist') | ||
|
|
||
| // Now open edit row dialog | ||
| cy.get('[data-cy="editRowBtn"]').first().click() | ||
| cy.get('[data-cy="editRowModal"]').should('be.visible') | ||
| }) | ||
|
|
||
| it('should show error when mandatory field is empty', () => { | ||
| cy.get('[data-cy="editRowModal"] input').first().clear().blur() | ||
|
|
||
| // Try multiple possible selectors for NcNoteCard with type="error" | ||
| cy.get('[data-cy="editRowModal"]').within(() => { | ||
| // Try different possible selectors | ||
| cy.get('.notecard--error, .note-card--error, [type="error"], .notecard[type="error"], .error', { timeout: 5000 }) | ||
| .should('exist') | ||
| }) | ||
| }) | ||
|
|
||
| it('should disable save button when mandatory field is empty', () => { | ||
| // Clear the mandatory field (should be the title field which is mandatory) | ||
| cy.get('[data-cy="editRowModal"] input').first().clear() | ||
|
|
||
| // Trigger validation by blurring and maybe clicking somewhere else | ||
| cy.get('[data-cy="editRowModal"] input').first().blur() | ||
|
|
||
| // Wait a bit for validation to process | ||
| cy.wait(500) | ||
|
|
||
| // Check that save button is disabled | ||
| cy.get('[data-cy="editRowSaveButton"]', { timeout: 5000 }).should('be.disabled') | ||
| }) | ||
|
|
||
| it('should enable save button when mandatory field is filled', () => { | ||
| cy.get('[data-cy="editRowModal"] input').first().type('filled value') | ||
| cy.get('[data-cy="editRowSaveButton"]', { timeout: 5000 }).should('not.be.disabled') | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.