diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts index bfb361377f..01fcd7a4ef 100644 --- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts @@ -53,6 +53,10 @@ describe('dashboard', () => { .then((list) => { newFirstItem = list.trim() expect(newFirstItem).not.to.equal(originalFirstItem) + cy.url().should( + 'include', + 'sort=resourceTitleObject.default.keyword' + ) }) }) }) diff --git a/apps/metadata-editor/src/app/dashboard/dashboard-page.component.spec.ts b/apps/metadata-editor/src/app/dashboard/dashboard-page.component.spec.ts index d3b45b85b6..7bfa3281da 100644 --- a/apps/metadata-editor/src/app/dashboard/dashboard-page.component.spec.ts +++ b/apps/metadata-editor/src/app/dashboard/dashboard-page.component.spec.ts @@ -1,20 +1,36 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { DashboardPageComponent } from './dashboard-page.component' import { CommonModule } from '@angular/common' +import { SearchService } from '@geonetwork-ui/feature/search' + +class SearchServiceMock { + setSortBy = jest.fn() +} describe('DashboardPageComponent', () => { let component: DashboardPageComponent let fixture: ComponentFixture + let searchService: SearchService beforeEach(async () => { - await TestBed.overrideComponent(DashboardPageComponent, { - set: { - imports: [CommonModule], - providers: [], - }, - }).compileComponents() + await TestBed.configureTestingModule({ + providers: [ + { + provide: SearchService, + useClass: SearchServiceMock, + }, + ], + }) + .overrideComponent(DashboardPageComponent, { + set: { + imports: [CommonModule], + providers: [], + }, + }) + .compileComponents() fixture = TestBed.createComponent(DashboardPageComponent) + searchService = TestBed.inject(SearchService) component = fixture.componentInstance fixture.detectChanges() }) @@ -22,4 +38,7 @@ describe('DashboardPageComponent', () => { it('should create', () => { expect(component).toBeTruthy() }) + it('orders the completion column', () => { + expect(searchService.setSortBy).toHaveBeenCalledWith(['desc', 'changeDate']) + }) }) diff --git a/apps/metadata-editor/src/app/records/records-list.component.spec.ts b/apps/metadata-editor/src/app/records/records-list.component.spec.ts index 9e80311330..62c728488c 100644 --- a/apps/metadata-editor/src/app/records/records-list.component.spec.ts +++ b/apps/metadata-editor/src/app/records/records-list.component.spec.ts @@ -118,12 +118,6 @@ describe('RecordsListComponent', () => { expect(pagination.currentPage).toEqual(currentPage) expect(pagination.totalPages).toEqual(totalPages) }) - it('orders the completion column', () => { - expect(searchService.setSortBy).toHaveBeenCalledWith([ - 'desc', - 'changeDate', - ]) - }) describe('when click on a record', () => { beforeEach(() => { table.recordSelect.emit({ uniqueIdentifier: 123 })