Skip to content

Commit

Permalink
test(filters): add e2e tests for date range search filter
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Nov 5, 2024
1 parent d040434 commit 8b8d1d2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
36 changes: 33 additions & 3 deletions apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,33 @@ describe('dashboard (authenticated)', () => {
})
})
})
describe('search filters', () => {
describe.only('search filters', () => {
function checkFilterByChangeDate() {
cy.get('mat-calendar-header').find('button').first().click()
cy.get('mat-multi-year-view').contains('button', '2024').click()
cy.get('mat-year-view').contains('button', 'AUG').click()
cy.get('mat-month-view').contains('button', '1').click()
cy.get('mat-month-view').contains('button', '30').click()
cy.get('gn-ui-interactive-table')
.find('[data-cy="table-row"]')
.should('have.length', '1')
cy.get('gn-ui-results-table')
.find('[data-cy="resultItemTitle"]')
.each(($resultItemTitle) => {
cy.wrap($resultItemTitle)
.invoke('text')
.should('eq', 'Accroches vélos MEL')
})
}
describe('allRecords search filter', () => {
beforeEach(() => {
cy.visit('/catalog/search')
})
it('should contain filter component with one search filter', () => {
cy.get('md-editor-search-filters')
.find('gn-ui-button')
.should('have.length', 2)
})
it('should filter the record list by editor (Barbara Roberts)', () => {
cy.get('md-editor-search-filters').find('gn-ui-button').first().click()
cy.get('.cdk-overlay-container')
Expand All @@ -333,15 +355,23 @@ describe('dashboard (authenticated)', () => {
cy.wrap($ownerInfo).invoke('text').should('eq', 'Barbara Roberts')
})
})
it('should filter the record list by last update (changeDate)', () => {
cy.get('md-editor-search-filters').find('gn-ui-button').eq(1).click()
checkFilterByChangeDate()
})
})
describe('myRecords search filters', () => {
beforeEach(() => {
cy.visit('/my-space/my-records')
})
it('should contain filter component with no search filter for now', () => {
it('should contain filter component with one search filter', () => {
cy.get('md-editor-search-filters')
.find('gn-ui-button')
.should('not.exist')
.should('have.length', 1)
})
it('should filter the record list by last update (changeDate)', () => {
cy.get('md-editor-search-filters').find('gn-ui-button').first().click()
checkFilterByChangeDate()
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
</ng-template>
<ng-template #cell let-item>
<div class="flex flex-row items-center gap-2 max-w-full font-semibold">
<span class="overflow-hidden text-ellipsis">{{ item.title }}</span>
<span data-cy="resultItemTitle" class="overflow-hidden text-ellipsis">{{
item.title
}}</span>
<gn-ui-badge
*ngIf="hasDraft(item)"
[style.--gn-ui-badge-padding]="'0.2em 0.6em'"
Expand Down

0 comments on commit 8b8d1d2

Please sign in to comment.