Skip to content
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

Persist dashboard filters in query params #3406

Merged
merged 26 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
30477fa
persist dashboard filters in query params
DeNic0la Apr 9, 2023
f46a437
show only id in url params and add period
DeNic0la Apr 9, 2023
1f8a558
add Dashboard test
DeNic0la Apr 9, 2023
5d35136
add Unittests for implemented functionality
DeNic0la Apr 9, 2023
1e4a2d0
Merge remote-tracking branch 'original/devel' into dashboard-filters-…
DeNic0la Jun 4, 2023
a40967f
move formatting utilities to helper
DeNic0la Jun 5, 2023
5acb42d
fix jsdoc
DeNic0la Jun 5, 2023
d7f9eed
inline variable
DeNic0la Jun 5, 2023
0daa6b7
Merge pull request #1 from DeNic0la/devel
DeNic0la Jun 5, 2023
cc76582
Merge pull request #2 from DeNic0la/devel
DeNic0la Jun 11, 2023
e57d0cc
fix: dont redirect after unload
DeNic0la Jun 11, 2023
501d962
remove debug info and wrap all promises into one
DeNic0la Jun 11, 2023
17ecc42
update unittests
DeNic0la Jun 11, 2023
27857a9
minor fix
DeNic0la Jun 11, 2023
1ed96ba
minor fix
DeNic0la Jun 11, 2023
aecb048
simplify and lint
DeNic0la Jun 11, 2023
14b7788
Merge branch 'devel' into dashboard-filters-in-url-#3155
DeNic0la Aug 1, 2023
0536fdd
use window history to persist query params
DeNic0la Aug 1, 2023
0663adf
improve querySyncHelper and add unit tests
DeNic0la Aug 2, 2023
ede3e68
refactor and add tests
DeNic0la Aug 3, 2023
9719413
refactor and add tests
DeNic0la Aug 3, 2023
fbc0250
minor fix
DeNic0la Aug 3, 2023
46d4a10
Add Cypress-Tests and refactor
DeNic0la Aug 6, 2023
80d1eb3
Lint and fix
DeNic0la Aug 6, 2023
00938d1
Merge branch 'devel' into dashboard-filters-in-url-#3155
DeNic0la Aug 6, 2023
8aee5d2
fix
DeNic0la Aug 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions e2e/specs/persistDashboardFilter.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
describe('Persist Dashboard Filter', () => {
it('should add Category-Filters to query', () => {
cy.login('[email protected]')
cy.visit('/camps')
cy.get('a:contains("GRGR")').click()
cy.get('span.v-chip:contains("Category")').click()
clickOnItemWithLabel("Essen")
clickOnItemWithLabel("Lagersport")
cy.wait(500)
cy.url().should('include','category')
cy.url().should('include','6adced5270de')
cy.url().should('include','9af703a10a9c')
})
it('should remove Category-Filters from query', () => {
cy.login('[email protected]')
cy.visit('/camps')
cy.get('a:contains("GRGR")').click()
cy.get('span.v-chip:contains("Category")').click()
clickOnItemWithLabel("Essen")
clickOnItemWithLabel("Lagersport")
cy.wait(500)
clickOnItemWithLabel("Essen")
clickOnItemWithLabel("Lagersport")
cy.wait(500)

cy.url().should('not.include','category')
cy.url().should('not.include','6adced5270de')
cy.url().should('not.include','9af703a10a9c')
})
it('should add Filters to query', () => {
cy.login('[email protected]')
cy.visit('/camps')
cy.get('a:contains("GRGR")').click()
cy.get('span.v-chip:contains("Category")').click()
clickOnItemWithLabel("Essen")
clickOnItemWithLabel("Lagersport")
cy.wait(500)
cy.get('span.v-chip:contains("State")').click()
clickOnItemWithLabel("Geplant")
clickOnItemWithLabel("Coach OK")
cy.wait(500)


cy.url().should('include','category')
cy.url().should('include','6adced5270de')
cy.url().should('include','9af703a10a9c')

cy.url().should('include','progressLabel')
cy.url().should('include','56d24f5359de')
cy.url().should('include','c50da81e0cfc')

cy.reload(true)
cy.wait(500)

cy.get('span.v-chip:contains("Category: ES or LS")')
cy.get('span.v-chip:contains("State: Geplant or Coach OK")')
})
it('should add Responsible-Filters to query', () => {
cy.login('[email protected]')
cy.visit('/camps')
cy.get('a:contains("GRGR")').click()
cy.get('span.v-chip:contains("Responsible")').click()
clickOnItemWithLabel("No responsibles")
cy.url().should('include','responsible=none')
cy.wait(500)
cy.reload(true)
cy.wait(10000)
cy.get('span.v-chip:contains("Responsible: No responsibles")')
})
})

function clickOnItemWithLabel(label) {
cy.get(`div.v-list-item:contains("${label}")`).find('.v-input--selection-controls__ripple').click()
}
229 changes: 229 additions & 0 deletions frontend/src/helpers/__tests__/querySyncHelper.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
import {
halUriToId,
idToHalUri,
processRouteQuery,
transformQueryParam,
transformValuesToHalId,
} from '@/helpers/querySyncHelper'

describe('querySyncHelper', () => {
describe('halUriToId', () => {
it.each([
['/camp_collaborations/73558f9c6483', '73558f9c6483'],
['/camp_collaborations/fe6557a4b89f', 'fe6557a4b89f'],
['/categories/3a54634a4', '3a54634a4'],
['/activity_progress_labels/456sfs56sus', '456sfs56sus'],
['/periods/45sz56sz5z6', '45sz56sz5z6'],
['/categories/56sf5654t', '56sf5654t'],
['/periods/65klsdfg59', '65klsdfg59'],
['/categories/se456sfs6df6', 'se456sfs6df6'],
['/camp_collaborations/sd6fh45z5', 'sd6fh45z5'],
['/categories/6s567t7k7i9k', '6s567t7k7i9k'],
['/periods/d453atz67', 'd453atz67'],
['/camp_collaborations/9234hn45asd850345', '9234hn45asd850345'],
['/activity_progress_labels/54s6sdf6f', '54s6sdf6f'],
['/periods/548dt6456', '548dt6456'],
['/activity_progress_labels/345fgbthsdt4', '345fgbthsdt4'],
])('should transform %p to %p', (input, expected) => {
const result = halUriToId(input)

expect(result).toEqual(expected)
})
})
describe('idToHalUri', () => {
it.each([
[['camp_collaborations', '73558f9c6483'], '/camp_collaborations/73558f9c6483'],
[['camp_collaborations', 'fe6557a4b89f'], '/camp_collaborations/fe6557a4b89f'],
[['categories', '3a54634a4'], '/categories/3a54634a4'],
[
['activity_progress_labels', '456sfs56sus'],
'/activity_progress_labels/456sfs56sus',
],
[['periods', '45sz56sz5z6'], '/periods/45sz56sz5z6'],
[['categories', '56sf5654t'], '/categories/56sf5654t'],
])('should transform %p to %p', (input, expected) => {
const result = idToHalUri(...input)

expect(result).toEqual(expected)
})
})
describe('transformQueryParam', () => {
it.each([
[
['responsible', ['73558f9c6483', 'fe6557a4b89f'], 'camp_collaborations'],
[
'responsible',
['/camp_collaborations/73558f9c6483', '/camp_collaborations/fe6557a4b89f'],
],
],
[
['period', '73558f9c6483', 'periods'],
['period', '/periods/73558f9c6483'],
],
[
['category', ['73558f9c6483', 'fe6557a4b89f'], 'categories'],
['category', ['/categories/73558f9c6483', '/categories/fe6557a4b89f']],
],
[
['progressLabels', ['73558f9c6483', 'fe6557a4b89f'], 'activity_progress_labels'],
[
'progressLabels',
[
'/activity_progress_labels/73558f9c6483',
'/activity_progress_labels/fe6557a4b89f',
],
],
],
[
['responsible', ['73558f9c6483', 'fe6557a4b89f'], 'camp_collaborations'],
[
'responsible',
['/camp_collaborations/73558f9c6483', '/camp_collaborations/fe6557a4b89f'],
],
],
[
['category', ['73558f9c6483', 'fe6557a4b89f'], 'categories'],
['category', ['/categories/73558f9c6483', '/categories/fe6557a4b89f']],
],
[
['progressLabels', ['73558f9c6483', 'fe6557a4b89f'], 'activity_progress_labels'],
[
'progressLabels',
[
'/activity_progress_labels/73558f9c6483',
'/activity_progress_labels/fe6557a4b89f',
],
],
],
[
['responsible', ['73558f9c6483', 'fe6557a4b89f'], 'camp_collaborations'],
[
'responsible',
['/camp_collaborations/73558f9c6483', '/camp_collaborations/fe6557a4b89f'],
],
],
[
['period', 'fe6557a4b89f', 'periods'],
['period', '/periods/fe6557a4b89f'],
],
[
['responsible', null, 'camp_collaborations'],
['responsible', null],
],
])('should transform %p to %p', (input, expected) => {
const result = transformQueryParam(...input)

expect(result).toEqual(expected)
})
})
describe('processRouteQuery', () => {
it.each([
[
{
category: ['505e3fdf9e90', 'a47a60594096'],
},
{
category: ['/categories/505e3fdf9e90', '/categories/a47a60594096'],
},
],
[
{
category: ['34az4a5a'],
},
{
category: ['/categories/34az4a5a'],
},
],
[
{
progressLabel: ['34az4a5a'],
},
{
progressLabel: ['/activity_progress_labels/34az4a5a'],
},
],
[
{
period: '34az4a5a',
},
{
period: '/periods/34az4a5a',
},
],
[
{
category: ['505e3fdf9e90', 'a47a60594096'],
responsible: ['3a5azag84', 'a5aaf4a5', '5asd5as5', 'ad45a45ag'],
},
{
category: ['/categories/505e3fdf9e90', '/categories/a47a60594096'],
responsible: [
'/camp_collaborations/3a5azag84',
'/camp_collaborations/a5aaf4a5',
'/camp_collaborations/5asd5as5',
'/camp_collaborations/ad45a45ag',
],
},
],
])('should transform %p to %p', (input, expected) => {
const result = processRouteQuery(input)

expect(result).toEqual(expected)
})
})
describe('transformValuesToHalId', () => {
it.each([
[
{
category: ['/categories/505e3fdf9e90', '/categories/a47a60594096'],
},
{
category: ['505e3fdf9e90', 'a47a60594096'],
},
],
[
{
category: ['/categories/34az4a5a'],
},
{
category: ['34az4a5a'],
},
],
[
{
progressLabel: ['/activity_progress_labels/34az4a5a'],
},
{
progressLabel: ['34az4a5a'],
},
],
[
{
period: '/periods/34az4a5a',
},
{
period: '34az4a5a',
},
],
[
{
category: ['/categories/505e3fdf9e90', '/categories/a47a60594096'],
responsible: [
'/camp_collaborations/3a5azag84',
'/camp_collaborations/a5aaf4a5',
'/camp_collaborations/5asd5as5',
'/camp_collaborations/ad45a45ag',
],
},
{
category: ['505e3fdf9e90', 'a47a60594096'],
responsible: ['3a5azag84', 'a5aaf4a5', '5asd5as5', 'ad45a45ag'],
},
],
])('should transform %p to %p', (input, expected) => {
const result = transformValuesToHalId(input)

expect(result).toEqual(expected)
})
})
})
Loading
Loading