-
Notifications
You must be signed in to change notification settings - Fork 50
feat: add additional date filter options #2099
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
4 commits
Select commit
Hold shift + click to select a range
4aaefef
feat: add additional date filter options
benjaminfrueh 97a881a
Merge branch 'main' into feat/additional-date-filter-options
benjaminfrueh 3313eca
Merge branch 'main' into feat/additional-date-filter-options
benjaminfrueh 008d353
test: use UTC date in cypress e2e test
benjaminfrueh 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
| let localUser | ||
| const tableTitle = 'View datetime filtering test table' | ||
|
|
||
| const today = new Date() | ||
| const [tomorrow, yesterday, daysAhead30, daysAhead60, daysAgo30, daysAgo60] = [1, -1, 30, 60, -30, -60].map(days => { | ||
| const d = new Date() | ||
| d.setUTCDate(d.getUTCDate() + days) | ||
| return d | ||
| }) | ||
|
|
||
| const formatDate = (date) => date.toISOString().split('T')[0] | ||
|
|
||
| describe('Filtering in a view by datetime', () => { | ||
|
|
||
| before(function () { | ||
| cy.createRandomUser().then(user => { | ||
| localUser = user | ||
| }) | ||
| }) | ||
|
|
||
| beforeEach(function () { | ||
| cy.login(localUser) | ||
| cy.visit('apps/tables') | ||
| }) | ||
|
|
||
| it('Setup table', () => { | ||
| cy.createTable(tableTitle) | ||
| cy.createTextLineColumn('title', null, null, true) | ||
| cy.createDatetimeDateColumn('date', false, false) | ||
|
|
||
| // add row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', 'today') | ||
| cy.get('.modal__content input.native-datetime-picker--input').clear().type(formatDate(today)) | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
|
|
||
| // add row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', 'tomorrow') | ||
| cy.get('.modal__content input.native-datetime-picker--input').type(formatDate(tomorrow)) | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
|
|
||
| // add row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', 'yesterday') | ||
| cy.get('.modal__content input.native-datetime-picker--input').type(formatDate(yesterday)) | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
|
|
||
| // add row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', '30 days ahead') | ||
| cy.get('.modal__content input.native-datetime-picker--input').type(formatDate(daysAhead30)) | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
|
|
||
| // add row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', '60 days ahead') | ||
| cy.get('.modal__content input.native-datetime-picker--input').type(formatDate(daysAhead60)) | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
|
|
||
| // add row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', '30 days ago') | ||
| cy.get('.modal__content input.native-datetime-picker--input').type(formatDate(daysAgo30)) | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
|
|
||
| // add row | ||
| cy.get('[data-cy="createRowBtn"]').click() | ||
| cy.fillInValueTextLine('title', '60 days ago') | ||
| cy.get('.modal__content input.native-datetime-picker--input').type(formatDate(daysAgo60)) | ||
| cy.get('[data-cy="createRowSaveButton"]').click() | ||
| }) | ||
|
|
||
| it('Filter view for dates 1-30 days ahead', () => { | ||
| cy.loadTable(tableTitle) | ||
|
|
||
| // create view | ||
| const title = 'Next 30 days' | ||
| 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(title) | ||
|
|
||
| // add filter for >= 1 day ahead | ||
| cy.get('[data-cy="filterFormFilterGroupBtn"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(0).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="date"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(1).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Is greater than or equal"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(2).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Number of days ahead"]').click() | ||
| cy.get('[data-cy="filterEntryNumber"]').eq(0).type('1') | ||
|
|
||
| // add filter for <= 30 days ahead | ||
| cy.get('[data-cy="filterGroupAddFilterBtn"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(3).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="date"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(4).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Is lower than or equal"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(5).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Number of days ahead"]').click() | ||
| cy.get('[data-cy="filterEntryNumber"]').eq(1).type('30') | ||
|
|
||
| // 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') | ||
|
|
||
| // check for existing rows | ||
| cy.get('.custom-table table tr td div').contains('tomorrow').should('be.visible') | ||
| cy.get('.custom-table table tr td div').contains('30 days ahead').should('be.visible') | ||
|
|
||
| // check for not existing rows | ||
| cy.get('.custom-table table tr td div').contains('today').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('yesterday').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('60 days ahead').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('30 days ago').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('60 days ago').should('not.exist') | ||
| }) | ||
|
|
||
| it('Filter view for dates 1-30 days ago', () => { | ||
| cy.loadTable(tableTitle) | ||
|
|
||
| // create view | ||
| const title = 'Last 30 days' | ||
| 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(title) | ||
|
|
||
| // add filter for <= 1 day ago | ||
| cy.get('[data-cy="filterFormFilterGroupBtn"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(0).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="date"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(1).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Is lower than or equal"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(2).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Number of days ago"]').click() | ||
| cy.get('[data-cy="filterEntryNumber"]').eq(0).type('1') | ||
|
|
||
| // add filter for >= 30 days ago | ||
| cy.get('[data-cy="filterGroupAddFilterBtn"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(3).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="date"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(4).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Is greater than or equal"]').click() | ||
| cy.get('.modal-container .filter-group .v-select.select').eq(5).click() | ||
| cy.get('ul.vs__dropdown-menu li span[title="Number of days ago"]').click() | ||
| cy.get('[data-cy="filterEntryNumber"]').eq(1).type('30') | ||
|
|
||
| // 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') | ||
|
|
||
| // check for existing rows | ||
| cy.get('.custom-table table tr td div').contains('yesterday').should('be.visible') | ||
| cy.get('.custom-table table tr td div').contains('30 days ago').should('be.visible') | ||
|
|
||
| // check for not existing rows | ||
| cy.get('.custom-table table tr td div').contains('today').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('tomorrow').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('30 days ahead').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('60 days ahead').should('not.exist') | ||
| cy.get('.custom-table table tr td div').contains('60 days ago').should('not.exist') | ||
| }) | ||
| }) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine that this test breaks if we use a different timezone? Should be fine, since it's just a test. Just confirming that the server logic itself is timezone-proof