Skip to content

Commit

Permalink
Merge pull request #847 from geonetwork/fix-dh-favorite-e2e-test
Browse files Browse the repository at this point in the history
e2e(datahub): wait more precisely for favorite to be registered
  • Loading branch information
jahow authored Apr 9, 2024
2 parents 1b3d989 + 2c1d78d commit 4fbb164
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion apps/datahub-e2e/src/e2e/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ describe('home', () => {
.invoke('text')
.as('favoriteTitle')
cy.get('@favoriteItem').find('gn-ui-favorite-star button').click()
cy.wait(100)

// wait for the favorite count to change before filtering
cy.get('@favoriteItem')
.find('[data-test=favorite-count]')
.invoke('text')
.should('eq', '1')

// show my favorites only
cy.get('datahub-header-badge-button[label$=favorites] button').click({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="flex flex-row items-center">
<span
class="align-text-top mr-1.5 favorite-count"
class="align-text-top mr-1.5"
data-test="favorite-count"
*ngIf="hasFavoriteCount && displayCount"
>{{ favoriteCount }}</span
>
Expand All @@ -10,7 +11,8 @@
[disabled]="loading || (isAnonymous$ | async)"
></gn-ui-star-toggle>
<span
class="align-text-top ml-1.5 favorite-count"
class="align-text-top ml-1.5"
data-test="favorite-count"
*ngIf="!displayCount"
translate="datahub.record.addToFavorites"
></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('FavoriteStarComponent', () => {
})
it('shows the amount of favorites on the record', () => {
favoriteCountHTMLEl = fixture.debugElement.query(
By.css('.favorite-count')
By.css('[data-test=favorite-count]')
).nativeElement
expect(favoriteCountHTMLEl).toBeTruthy()
expect(favoriteCountHTMLEl.textContent).toEqual(
Expand All @@ -103,7 +103,7 @@ describe('FavoriteStarComponent', () => {
})
it('does not show the amount of favorites on the record', () => {
const favoriteCountEl = fixture.debugElement.query(
By.css('.favorite-count')
By.css('[data-test=favorite-count]')
)
expect(favoriteCountEl).toBeFalsy()
})
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('FavoriteStarComponent', () => {
}
fixture.detectChanges()
favoriteCountHTMLEl = fixture.debugElement.query(
By.css('.favorite-count')
By.css('[data-test=favorite-count]')
).nativeElement
})
describe('When my record is part of the updates', () => {
Expand Down

0 comments on commit 4fbb164

Please sign in to comment.