Skip to content

Commit

Permalink
test: add e2e for search filters x url
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitaBernachot committed Jan 15, 2025
1 parent eb255ac commit 3c7a4e1
Show file tree
Hide file tree
Showing 9 changed files with 840 additions and 10 deletions.
39 changes: 33 additions & 6 deletions apps/datahub-e2e/src/e2e/dataset.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ describe('datasets', () => {

describe('Information block', () => {
beforeEach(() => {
cy.visit('/dataset/ee965118-2416-4d48-b07e-bbc696f002c2')
cy.interceptDataset('775b7660-b03b-443a-9817-be82ecd0ef07')
cy.visit('/dataset/775b7660-b03b-443a-9817-be82ecd0ef07')
cy.get('mel-datahub-dataset-information')
.children('div')
.first()
Expand All @@ -146,7 +147,7 @@ describe('datasets', () => {
.children('div')
.eq(1)
.find('div')
.children('span')
.children('button')
.should('have.length.gt', 0)
})

Expand All @@ -155,7 +156,7 @@ describe('datasets', () => {
.children('div')
.eq(1)
.find('div')
.children('span')
.children('button')
.should('have.length.gt', 0)
})

Expand All @@ -171,10 +172,10 @@ describe('datasets', () => {
it('should display the producer', () => {
cy.get('@mainInfo')
.children('div')
.eq(3)
.eq(4)
.find('span')
.eq(1)
.should('have.text', 'Région Hauts-de-France')
.should('have.text', 'Métropole Européenne de Lille')
})

it('should display the social media share btns', () => {
Expand All @@ -191,11 +192,37 @@ describe('datasets', () => {
it('should display the detailed file link and lead to it', () => {
cy.get('@mainInfo')
.children('div')
.eq(4)
.eq(5)
.find('a')
.invoke('attr', 'href')
.should('include', '/geonetwork/srv/fre/catalog.search#/metadata')
})

describe('When clicking on a category tag', () => {
it('should navigate to home page with and search query parameters should be assigned a value', () => {
cy.get('@mainInfo')
.children('div')
.eq(1)
.find('div')
.children('button')
.eq(0)
.click()
cy.url().should('include', '/search?categoryKeyword=https:%2F%2Fdata.lillemetropole.fr%2Fthematique%2Fcategories%2Fadministration_action_publique')
})
})

describe('When clicking on a territory tag', () => {
it('should navigate to home page with and search query parameters should be assigned a value', () => {
cy.get('@mainInfo')
.children('div')
.eq(2)
.find('div')
.children('button')
.eq(0)
.click()
cy.url().should('include', '/search?territories=https:%2F%2Fdata.lillemetropole.fr%2Fplace%2FmelTerritories%231')
})
})
})

describe('API block', () => {
Expand Down
60 changes: 58 additions & 2 deletions apps/datahub-e2e/src/e2e/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('search', () => {
cy.get('mel-datahub-filter-dropdown').should('have.length', 3)
})
})
describe.only('Filters from config', () => {
describe('Filters from config', () => {
beforeEach(() => {
// this will enable all available filters
cy.intercept('GET', '/assets/configuration/default.toml', {
Expand All @@ -280,7 +280,7 @@ describe('search', () => {
})
it('should display all filters', () => {
cy.get('[data-cy="filterExpandBtn"]').click()
cy.get('@filters').filter(':visible').should('have.length', 12)
cy.get('@filters').filter(':visible').should('have.length', 13)
cy.get('@filters')
.children()
.then(($dropdowns) =>
Expand All @@ -301,10 +301,66 @@ describe('search', () => {
'representationType',
'revisionYear',
'categoryKeyword',
'territories'
])
})

describe('Search filters and query params from url', () => {
describe('When searching for a category in the url', () => {
beforeEach(() => {
cy.visit('/search?categoryKeyword=https:%2F%2Fdata.lillemetropole.fr%2Fthematique%2Fcategories%2Fadministration_action_publique')
})

it('should not display the pagination', () => {
cy.get('mel-datahub-pagination-buttons').should('not.exist')
})
})
})
})
})

describe.only('Search filters and query params from url', () => {
describe('When searching for a category in the url', () => {
beforeEach(() => {
cy.interceptSearchAggr('th_thesaurus_mot_cle_thematique_categories.link')
cy.wait('@interceptSearchAggr')
cy.visit('/search?categoryKeyword=https:%2F%2Fdata.lillemetropole.fr%2Fthematique%2Fcategories%2Fadministration_action_publique')
})

it('should select the value in the list', () => {
cy.get('mel-datahub-dropdown-multiselect')
.eq(1)
.click()

cy.get('#cdk-overlay-0 button[title="https://data.lillemetropole.fr/thematique/categories/administration_action_publique (58)"]')
.should('exist')

cy.get('#cdk-overlay-0 label[title="https://data.lillemetropole.fr/thematique/categories/administration_action_publique (58)"] input[type="checkbox"]')
.should('be.checked')
})
})

describe('When searching for a territory in the url', () => {
beforeEach(() => {
cy.interceptSearchAggr('th_mel.link')
cy.wait('@interceptSearchAggr')
cy.visit('/search?territories=https:%2F%2Fdata.lillemetropole.fr%2Fplace%2FmelTerritories%231')
})

it('should select the value in the list', () => {
cy.get('mel-datahub-dropdown-multiselect')
.eq(2)
.click()

cy.get('#cdk-overlay-0 button[title="https://data.lillemetropole.fr/place/melTerritories#1 (96)"]')
.should('exist')

cy.get('#cdk-overlay-0 label[title="https://data.lillemetropole.fr/place/melTerritories#1 (96)"] input[type="checkbox"]')
.should('be.checked')
})
})
})

describe('pagination', () => {
beforeEach(() => {
cy.visit('/search')
Expand Down
54 changes: 54 additions & 0 deletions apps/datahub-e2e/src/fixtures/aggregations/th_mel.link.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 346,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"th_mel.link": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "https://data.lillemetropole.fr/place/melTerritories#1",
"doc_count": 96
},
{
"key": "https://data.lillemetropole.fr/place/melTerritories#198",
"doc_count": 7
},
{
"key": "https://data.lillemetropole.fr/place/melTerritories#38",
"doc_count": 2
},
{
"key": "https://data.lillemetropole.fr/place/melTerritories#53",
"doc_count": 2
},
{
"key": "https://data.lillemetropole.fr/place/melTerritories#55",
"doc_count": 2
},
{
"key": "https://data.lillemetropole.fr/place/melTerritories#74",
"doc_count": 2
},
{
"key": "https://data.lillemetropole.fr/place/melTerritories#89",
"doc_count": 1
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 346,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"th_thesaurus_mot_cle_thematique_categories.link": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "https://data.lillemetropole.fr/thematique/categories/administration_action_publique",
"doc_count": 58
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/amenagement_urbanisme_foncier",
"doc_count": 43
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/culture_tourisme_sport",
"doc_count": 16
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/economie_emploi",
"doc_count": 6
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/education_formation_enseignement",
"doc_count": 2
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/environnement_energie",
"doc_count": 19
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/espace_public",
"doc_count": 30
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/habitat_logement",
"doc_count": 1
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/mobilite_transports_deplacement",
"doc_count": 35
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/participation_citoyenne_democratie_locale",
"doc_count": 3
},
{
"key": "https://data.lillemetropole.fr/thematique/categories/services_social_sante",
"doc_count": 14
}
]
}
}
}
2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/fixtures/config-with-all-filters.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[search]
advanced_filters = ['publisher', 'format', 'publicationYear', 'inspireKeyword', 'keyword', 'topic', 'isSpatial', 'license', 'resourceType', 'representationType', 'revisionYear', 'categoryKeyword']
advanced_filters = ['publisher', 'format', 'publicationYear', 'inspireKeyword', 'keyword', 'topic', 'isSpatial', 'license', 'resourceType', 'representationType', 'revisionYear', 'categoryKeyword', 'territories']
Loading

0 comments on commit 3c7a4e1

Please sign in to comment.