Skip to content

Commit

Permalink
review(search-filters): address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Oct 17, 2024
1 parent 0edb25a commit c31e2cf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
13 changes: 4 additions & 9 deletions apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,10 @@ describe('dashboard (authenticated)', () => {
.find('[data-cy="table-row"]')
.should('have.length', '5')
cy.get('gn-ui-results-table')
.find('[data-cy="table-row"]')
.first()
.as('record')
cy.get('@record')
.children('div')
.eq(4)
.find('span')
.invoke('text')
.should('eq', 'Barbara Roberts')
.find('[data-cy="ownerInfo"]')
.each(($ownerInfo) => {
cy.wrap($ownerInfo).invoke('text').should('eq', 'Barbara Roberts')
})
})
})
describe('myRecords search filters', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { SearchFiltersComponent } from './search-filters.component'
import { MockBuilder } from 'ng-mocks'
import { TranslateModule } from '@ngx-translate/core'

describe('SearchFiltersComponent', () => {
let component: SearchFiltersComponent
Expand All @@ -10,13 +11,34 @@ describe('SearchFiltersComponent', () => {
return MockBuilder(SearchFiltersComponent)
})

beforeEach(() => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SearchFiltersComponent, TranslateModule.forRoot()],
}).compileComponents()
fixture = TestBed.createComponent(SearchFiltersComponent)
component = fixture.componentInstance
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy()
})

describe('searchFields', () => {
it('should correctly read searchFields and create searchConfig', () => {
const searchFields = ['user', 'publisherOrg', 'format', 'isSpatial']
component.searchFields = searchFields
fixture.detectChanges()
expect(component.searchConfig).toEqual([
{ fieldName: 'user', title: 'search.filters.user' },
{ fieldName: 'publisherOrg', title: 'search.filters.publisherOrg' },
{ fieldName: 'format', title: 'search.filters.format' },
{ fieldName: 'isSpatial', title: 'search.filters.isSpatial' },
])
})
it('should read empty searchFields and create empty searchConfig', () => {
component.searchFields = []
fixture.detectChanges()
expect(component.searchConfig).toEqual([])
})
})
})
4 changes: 2 additions & 2 deletions libs/feature/search/src/lib/utils/service/fields.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ describe('search fields implementations', () => {
beforeEach(async () => {
values = await lastValueFrom(searchField.getAvailableValues())
})
it('orders results by ascending key', () => {
it('calls aggregate with expected payload', () => {
expect(repository.aggregate).toHaveBeenCalledWith({
'userinfo.keyword': {
type: 'terms',
Expand All @@ -705,7 +705,7 @@ describe('search fields implementations', () => {
},
})
})
it('returns the available editors, order by ascending key (alphabetical)', () => {
it('returns the available users, in expected format', () => {
expect(values).toEqual([
{
label: 'admin admin (10)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
</ng-template>
<ng-template #cell let-item>
<mat-icon class="material-symbols-outlined">person</mat-icon>
<span class="text-xs">{{ formatUserInfo(item.extras?.ownerInfo) }}</span>
<span data-cy="ownerInfo" class="text-xs">{{
formatUserInfo(item.extras?.ownerInfo)
}}</span>
</ng-template>
</gn-ui-interactive-table-column>

Expand Down

0 comments on commit c31e2cf

Please sign in to comment.