Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ME]: Fix misc issues with dashboard view #990

Merged
merged 20 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
91efa1a
fix(editor): fix-misc-issues-with-dashboard-views
C2CRomualdCaplier Sep 16, 2024
38569e2
feat(my-records): add a myRecords search state
tkohr Sep 20, 2024
b37468a
feat(dashboard-menu): reset main search when navigating to my records…
tkohr Sep 20, 2024
2dd588b
test(my-records): adapt unit tests
tkohr Sep 20, 2024
03473d8
test(e2e): add e2e tests
tkohr Sep 20, 2024
9a33ea8
fix(search-header): update filters on autocomplete selection
tkohr Sep 23, 2024
a5f8b7b
feat(me): fix mutliple identical searchs in the header + simplify
jahow Sep 23, 2024
8b33a3d
feat(me): remove unused icons in header
jahow Sep 23, 2024
4abfaf1
refactor(record-list): remove duplicate code
tkohr Sep 23, 2024
25f5ef6
fix(dashboard): add y autoscroll for table and content
tkohr Sep 23, 2024
7e683b4
fix(search-header): move cross to right
tkohr Sep 23, 2024
cddc365
refactor(my-records): remove unused method
tkohr Sep 23, 2024
25d27d4
fix code review
C2CRomualdCaplier Sep 24, 2024
5eb5f9f
feat(search): separate search inputs for allRecords and myRecords
tkohr Sep 24, 2024
197304c
feat(search): navigate to record on autocomplete select
tkohr Sep 24, 2024
54cc287
test(search): add and adapt tests
tkohr Sep 25, 2024
5732e95
Merge pull request #1003 from geonetwork/seperate-search-inputs
tkohr Sep 25, 2024
a363ffa
fix(search): address review comments
tkohr Sep 25, 2024
ac0f1dd
fix(badge): adapt dashboard badge font sizes and padding
tkohr Sep 25, 2024
31aad0f
chore(all/myrecords): grey out unimplemented buttons
tkohr Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('dashboard', () => {
cy.get('@draft')
.children('div')
.eq(5)
.should('contain', ' Not published ')
.should('include.text', 'Not published')
cy.get('@draft').children('div').eq(6).should('contain', ' - ')
cy.clearRecordDrafts()
})
Expand All @@ -204,23 +204,44 @@ describe('dashboard', () => {
.find('span')
.invoke('text')
.should('eq', 'admin admin')
cy.get('@record').children('div').eq(5).should('contain', ' Published ')
cy.get('@record')
.children('div')
.eq(5)
.find('span')
.should('include.text', 'Published')
cy.get('@record').children('div').eq(6).should('not.contain', ' - ')
cy.clearRecordDrafts()
})
})
describe('navigation', () => {
function checkDashboardFiltered() {
cy.get('gn-ui-autocomplete').type('Mat')
cy.get('mat-option').first().click()
cy.get('gn-ui-interactive-table')
.find('[data-cy="table-row"]')
.should('have.length', '1')
}
beforeEach(() => {
cy.login('admin', 'admin', false)
cy.visit('/catalog/search')
})
describe('search input', () => {
it('should filter the dashboard based on the search input', () => {
checkDashboardFiltered()
})
it('should navigate to list of all records and filter the dashboard based on the search input when on different page', () => {
cy.visit('/my-space/my-records')
checkDashboardFiltered()
})
it('should clear the search input when navigating to my records', () => {
cy.get('gn-ui-autocomplete').type('Mat')
cy.get('mat-option').first().click()
cy.get('gn-ui-interactive-table')
.find('[data-cy="table-row"]')
.should('have.length', '1')
cy.get('md-editor-dashboard-menu').find('a').eq(5).click()
cy.get('gn-ui-autocomplete').should('have.value', '')
})
it('should clear the search input when navigating to my drafts', () => {
cy.get('gn-ui-autocomplete').type('Mat')
cy.get('md-editor-dashboard-menu').find('a').eq(6).click()
cy.get('gn-ui-autocomplete').should('have.value', '')
})
})
describe('my records', () => {
Expand All @@ -232,6 +253,31 @@ describe('dashboard', () => {
.next()
.should('contain', 'admin admin')
})
it('should display the correct amount of records', () => {
cy.get('md-editor-dashboard-menu').find('a').eq(5).click()
cy.get('gn-ui-results-table')
.find('[data-cy="table-row"]')
.should('have.length', '10')
})
it('should sort the records by title', () => {
cy.get('md-editor-dashboard-menu').find('a').eq(5).click()
cy.get('gn-ui-results-table')
.find('[data-cy="table-row"]')
.first()
.invoke('text')
.then((firstRecord) => {
console.log(firstRecord)
cy.get('gn-ui-results-table')
.find('.table-header-cell')
.eq(1)
.click()
cy.get('gn-ui-results-table')
.find('[data-cy="table-row"]')
.first()
.invoke('text')
.should('not.eq', firstRecord)
})
})
})
})
})
4 changes: 3 additions & 1 deletion apps/metadata-editor-e2e/src/e2e/edit.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable cypress/no-unnecessary-waiting */

describe('editor form', () => {
let recordUuid
let recordUuid: any
before(() => {
cy.login('admin', 'admin', false)
cy.viewport(1920, 2400)

cy.clearRecordDrafts()

Expand Down Expand Up @@ -53,6 +54,7 @@ describe('editor form', () => {
})
beforeEach(() => {
cy.login('admin', 'admin', false)
cy.visit('/catalog/search')
cy.wrap(recordUuid).as('recordUuid')

cy.get('@recordUuid').then((recordUuid) => {
Expand Down
41 changes: 0 additions & 41 deletions apps/metadata-editor-e2e/src/e2e/my-org.cy.ts

This file was deleted.

20 changes: 11 additions & 9 deletions apps/metadata-editor-e2e/src/e2e/record-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('record-actions', () => {
cy.visit('/catalog/search')
})
describe('delete', () => {
const recordId = `TEST_RECORD_${Date.now()}`
describe('record with draft', () => {
it('should delete the record, delete its associated draft and refresh the interface', () => {
// First create a record and its draft
Expand All @@ -13,13 +14,15 @@ describe('record-actions', () => {
.as('abstractField')
.focus()
cy.get('@abstractField').type('record abstract')
cy.get('[data-test="recordTitleInput"]').click()
cy.get('[data-test="recordTitleInput"]').type('{selectAll}{backspace}')
cy.get('[data-test="recordTitleInput"]').type(recordId)
cy.intercept({
method: 'PUT',
pathname: '**/records',
}).as('insertRecord')
cy.get('md-editor-publish-button').click()
cy.wait('@insertRecord')
cy.get('@abstractField').focus()
cy.get('@abstractField').type('draft abstract')
// Assert that the draft exists in the local storage
cy.editor_readFormUniqueIdentifier().then((uniqueIdentifier) =>
Expand All @@ -31,18 +34,17 @@ describe('record-actions', () => {
)
cy.visit('/my-space/my-records')
cy.get('[data-cy="table-row"]')
.contains('My new record')
.contains(recordId)
.should('have.length', 1)
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '1')
// Delete the record
cy.get('[data-test="record-menu-button"]').last().click()
cy.get('[data-test="record-menu-delete-button"]').click()
cy.get('[data-cy="confirm-button"]').click()
cy.get('[data-cy="table-row"]')
.contains('My new record')
.contains(recordId)
.should('have.length', 0)
cy.get('gn-ui-notification').should('contain', 'Delete success')
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '0')
})
})

Expand All @@ -51,6 +53,9 @@ describe('record-actions', () => {
// First create a draft
cy.get('[data-cy="create-record"]').click()
cy.url().should('include', '/create')
cy.get('[data-test="recordTitleInput"]').click()
cy.get('[data-test="recordTitleInput"]').type('{selectAll}{backspace}')
cy.get('[data-test="recordTitleInput"]').type(recordId)
cy.get('gn-ui-form-field[ng-reflect-model=abstract] textarea')
.as('abstractField')
.focus()
Expand All @@ -63,17 +68,14 @@ describe('record-actions', () => {
})
cy.visit('/my-space/my-draft')
cy.get('[data-cy="table-row"]')
.contains('My new record')
.contains(recordId)
.should('have.length', 1)
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '1')
// Delete the draft
cy.get('[data-test="record-menu-button"]').click()
cy.get('[data-test="record-menu-delete-button"]').click()
cy.get('[data-cy="confirm-button"]').click()
cy.get('[data-cy="table-row"]')
.contains('New record')
.should('have.length', 0)
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '0')
cy.get('[data-cy="table-row"]').should('not.exist')
})
})
})
Expand Down
26 changes: 10 additions & 16 deletions apps/metadata-editor/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { DashboardPageComponent } from './dashboard/dashboard-page.component'
import { SignInPageComponent } from './sign-in/sign-in-page.component'
import { EditPageComponent } from './edit/edit-page.component'
import { EditRecordResolver } from './edit-record.resolver'
import { MyRecordsComponent } from './records/my-records/my-records.component'
import { MyDraftComponent } from './records/my-draft/my-draft.component'
import { MyLibraryComponent } from './records/my-library/my-library.component'
import { SearchRecordsComponent } from './records/search-records/search-records-list.component'
import { TemplatesComponent } from './records/templates/templates.component'
import { MyOrgUsersComponent } from './my-org-users/my-org-users.component'
import { MyOrgRecordsComponent } from './records/my-org-records/my-org-records.component'
import { NewRecordResolver } from './new-record.resolver'
import { DuplicateRecordResolver } from './duplicate-record.resolver'
import { AllRecordsComponent } from './records/all-records/all-records.component'
import { MyRecordsStateWrapperComponent } from './records/my-records/my-records-state-wrapper.component'

export const appRoutes: Route[] = [
{ path: '', redirectTo: 'catalog/search', pathMatch: 'prefix' },
Expand All @@ -26,35 +25,30 @@ export const appRoutes: Route[] = [
},
{
path: 'discussion',
component: SearchRecordsComponent,
component: AllRecordsComponent,
pathMatch: 'prefix',
},
{
path: 'calendar',
component: SearchRecordsComponent,
component: AllRecordsComponent,
pathMatch: 'prefix',
},
{
path: 'contacts',
component: SearchRecordsComponent,
component: AllRecordsComponent,
pathMatch: 'prefix',
},
{
path: 'thesaurus',
component: SearchRecordsComponent,
component: AllRecordsComponent,
pathMatch: 'prefix',
},
{
path: 'search',
title: 'Search Records',
component: SearchRecordsComponent,
component: AllRecordsComponent,
pathMatch: 'prefix',
},
{
path: 'my-org',
title: 'My Organisation',
component: MyOrgRecordsComponent,
},
],
},
{
Expand All @@ -66,7 +60,7 @@ export const appRoutes: Route[] = [
{
path: 'my-records',
title: 'My Records',
component: MyRecordsComponent,
component: MyRecordsStateWrapperComponent,
pathMatch: 'prefix',
},
{
Expand All @@ -78,7 +72,7 @@ export const appRoutes: Route[] = [
{
path: 'templates',
title: 'Templates',
component: MyLibraryComponent,
component: TemplatesComponent,
pathMatch: 'prefix',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="menu-title" translate="">dashboard.labels.catalog</div>
<a
class="menu-item"
(click)="resetMainSearch()"
routerLink="/catalog/search"
routerLinkActive="btn-active"
#rlaAll="routerLinkActive"
Expand Down Expand Up @@ -71,11 +72,11 @@
>
<mat-icon class="material-symbols-outlined">edit_note</mat-icon>
<span translate="">dashboard.records.myDraft</span>
<gn-ui-badge
[style.--gn-ui-badge-rounded]="'100px'"
data-cy="dashboard-drafts-count"
>{{ draftsCount$ | async }}</gn-ui-badge
>
<ng-container *ngIf="draftsCount$ | async as draftsCount">
<gn-ui-badge *ngIf="draftsCount > 0" data-cy="dashboard-drafts-count">{{
draftsCount
}}</gn-ui-badge>
</ng-container>
</a>
<a
class="menu-item btn-inactive"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { TranslateModule } from '@ngx-translate/core'
import { cold, hot } from 'jasmine-marbles'
import { MockBuilder, MockProviders } from 'ng-mocks'
import { DashboardMenuComponent } from './dashboard-menu.component'
import { SearchFacade } from '@geonetwork-ui/feature/search'

describe('DashboardMenuComponent', () => {
let component: DashboardMenuComponent
let fixture: ComponentFixture<DashboardMenuComponent>
let recordsRepository: RecordsRepositoryInterface
let searchFacade: SearchFacade

beforeEach(() => {
return MockBuilder(DashboardMenuComponent)
Expand All @@ -18,9 +20,12 @@ describe('DashboardMenuComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DashboardMenuComponent, TranslateModule.forRoot()],
providers: [MockProviders(ActivatedRoute, RecordsRepositoryInterface)],
providers: [
MockProviders(ActivatedRoute, RecordsRepositoryInterface, SearchFacade),
],
}).compileComponents()
recordsRepository = TestBed.inject(RecordsRepositoryInterface)
searchFacade = TestBed.inject(SearchFacade)
fixture = TestBed.createComponent(DashboardMenuComponent)
component = fixture.componentInstance
fixture.detectChanges()
Expand All @@ -45,4 +50,10 @@ describe('DashboardMenuComponent', () => {
// Assert that draftsCount$ behaves as expected
expect(component.draftsCount$).toBeObservable(expected)
})

it('should reset filters in main search', () => {
searchFacade.setFilters = jest.fn()
component.resetMainSearch()
expect(searchFacade.setFilters).toHaveBeenCalledWith({})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TranslateModule } from '@ngx-translate/core'
import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface'
import { map, startWith, switchMap } from 'rxjs/operators'
import { BadgeComponent } from '@geonetwork-ui/ui/inputs'
import { SearchFacade } from '@geonetwork-ui/feature/search'

@Component({
selector: 'md-editor-dashboard-menu',
Expand All @@ -29,5 +30,12 @@ export class DashboardMenuComponent {
)
activeLink = false

constructor(private recordsRepository: RecordsRepositoryInterface) {}
constructor(
private recordsRepository: RecordsRepositoryInterface,
private searchFacade: SearchFacade
) {}

resetMainSearch() {
this.searchFacade.setFilters({})
}
}
Loading
Loading