Skip to content

Commit

Permalink
fix: fix favoriteRequest test
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Jun 7, 2024
1 parent 4624644 commit 103cb9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
27 changes: 10 additions & 17 deletions apps/datahub-e2e/src/e2e/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,28 @@ describe('search', () => {
describe('User logged in', () => {
beforeEach(() => {
cy.login()
cy.clearFavorites()
cy.visit('/search')
cy.intercept('PUT', '**/geonetwork/srv/api/userselections/**').as(
'addFavoriteRequest'
)
cy.clearFavorites()
cy.get('mel-datahub-results-card-search')
.first()
.eq(1)
.find('mel-datahub-heart-toggle')
.first()
.find('mel-datahub-button')
.first()
.click()
cy.wait('@addFavoriteRequest')
cy.get('mel-datahub-results-card-favorite').as('favoriteCard')
})

it('should display the correct subtitle', () => {
cy.get('mel-datahub-search-header')
.find('.mel-section-title')
.first()
.should('have.text', ' Jeux de données suivis ')
})
it('should display record results in favorite cards inside a carousel', () => {
cy.get('mel-datahub-custom-carousel')
.find('mel-datahub-results-card-favorite')
.first()
cy.get('mel-datahub-results-card-favorite')
.find('h1')
.should(
'have.text',
Expand All @@ -129,16 +128,10 @@ describe('search', () => {
.find('mel-datahub-metadata-quality')
.should('be.visible')
})

describe('interactions with dataset', () => {
beforeEach(() => {
cy.get('mel-datahub-results-card-favorite').first().as('firstResult')
})
it('should open the dataset page in the same application on click', () => {
cy.get('@firstResult').find('h1').click()
cy.url().should('include', 'dataset')
cy.get('mel-datahub-dataset-page').should('be.visible')
})
it('should open the dataset page in the same application on click', () => {
cy.get('@favoriteCard').find('h1').click()
cy.url().should('include', 'dataset')
cy.get('mel-datahub-dataset-page').should('be.visible')
})
})
})
Expand Down
6 changes: 3 additions & 3 deletions apps/datahub-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Cypress.Commands.add('clearFavorites', () => {

cy.window().then(function () {
cy.request({
url: `/geonetwork/srv/api/userselections/0/${this.myId}`,
url: `/geonetwork/srv/api/userselections/0/${this['myId']}`,
headers: { accept: 'application/json' },
})
.its('body')
Expand All @@ -78,10 +78,10 @@ Cypress.Commands.add('clearFavorites', () => {
.getCookie('XSRF-TOKEN')
.its('value')
.then(function (token) {
const favoritesId = this.favoritesId || []
const favoritesId = this['favoritesId'] || []
cy.request({
url: `/geonetwork/srv/api/userselections/0/${
this.myId
this['myId']
}?uuid=${favoritesId.join('&uuid=')}`,
method: 'DELETE',
headers: { accept: 'application/json', 'X-XSRF-TOKEN': token },
Expand Down

0 comments on commit 103cb9d

Please sign in to comment.