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 all 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
96 changes: 88 additions & 8 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,26 @@ 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', () => {
beforeEach(() => {
cy.login('admin', 'admin', false)
cy.visit('/catalog/search')
})
describe('search input', () => {
it('should filter the dashboard based on the search input', () => {
cy.get('gn-ui-autocomplete').type('Mat')
cy.get('mat-option').first().click()
cy.get('gn-ui-interactive-table')
describe('all records', () => {
it('should display the correct amount of records', () => {
cy.get('gn-ui-results-table')
.find('[data-cy="table-row"]')
.should('have.length', '1')
.should('have.length', '15')
})
})
describe('my records', () => {
Expand All @@ -232,6 +235,83 @@ 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)
})
})
})
})

describe('search', () => {
function checkDashboardFiltered() {
cy.get('gn-ui-autocomplete').type('velo{enter}')
cy.get('gn-ui-interactive-table')
.find('[data-cy="table-row"]')
.should('have.length', '1')
}
function checkAutocompleteSelected() {
cy.get('gn-ui-autocomplete').type('velo')
cy.get('mat-option').first().click()
cy.url().should('include', '/edit/accroche_velos')
}
describe('allRecords search input', () => {
beforeEach(() => {
cy.login('admin', 'admin', false)
cy.visit('/catalog/search')
})
it('should filter the dashboard based on the search input', () => {
checkDashboardFiltered()
})
it('should navigate to the record selected in the autocomplete', () => {
checkAutocompleteSelected()
})
it('should clear the search input when navigating to my records', () => {
cy.get('gn-ui-autocomplete').type('velo')
cy.get('md-editor-dashboard-menu').find('a').eq(5).click()
cy.get('gn-ui-autocomplete').should('have.value', '')
})
it('should hide the search input when navigating to my drafts', () => {
cy.get('md-editor-dashboard-menu').find('a').eq(6).click()
cy.get('gn-ui-autocomplete').should('not.exist')
})
})
describe('myRecords search input', () => {
beforeEach(() => {
cy.login('admin', 'admin', false)
cy.visit('/my-space/my-records')
})
it('should filter the dashboard based on the search input', () => {
checkDashboardFiltered()
})
it('should navigate to the record selected in the autocomplete', () => {
checkAutocompleteSelected()
})
it('should clear the search input when navigating to all records', () => {
cy.get('gn-ui-autocomplete').type('velo')
cy.get('md-editor-dashboard-menu').find('a').first().click()
cy.get('gn-ui-autocomplete').should('have.value', '')
})
})
})
})
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 @@ -71,11 +71,15 @@
>
<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
[style.--gn-ui-badge-padding]="'0.375em 0.875em'"
[style.--gn-ui-badge-text-size]="'12px'"
*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 @@ -3,16 +3,11 @@
<aside class="w-[370px] shrink-0 border-r">
<md-editor-sidebar></md-editor-sidebar>
</aside>
<div class="grow flex flex-col">
<header class="shrink-0 border-b border-blue-300">
<md-editor-search-header></md-editor-search-header>
</header>
<div class="relative">
<div class="absolute top-0 left-0 w-2/3 z-10 pointer-events-none">
<gn-ui-notifications-container></gn-ui-notifications-container>
</div>
<router-outlet></router-outlet>
<div class="relative grow flex flex-col">
<div class="absolute top-0 left-0 w-2/3 z-10 pointer-events-none">
<gn-ui-notifications-container></gn-ui-notifications-container>
</div>
<router-outlet></router-outlet>
</div>
</div>
</div>
Loading
Loading