-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
440 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
describe('my-org', () => { | ||
beforeEach(() => { | ||
cy.loginGN('barbie', 'p4ssworD_', false) | ||
cy.visit(`/records/my-org`) | ||
cy.get('md-editor-dashboard-menu').find('a').first().click() | ||
cy.get('main').children('div').first().children('div').eq(1).as('linkGroup') | ||
}) | ||
describe('my-org display', () => { | ||
it('should show my-org name and logo', () => { | ||
cy.get('h1').should('not.have.text', '') | ||
cy.get('gn-ui-thumbnail') | ||
}) | ||
it('should show the user and record count', () => { | ||
cy.get('@linkGroup') | ||
.find('a') | ||
.children('span') | ||
.first() | ||
.should('not.have.text', '') | ||
cy.get('@linkGroup') | ||
.find('gn-ui-button') | ||
.children('span') | ||
.first() | ||
.should('not.have.text', '') | ||
}) | ||
it('should show my-org records', () => { | ||
cy.get('.grid').should('have.length.above', 0) | ||
}) | ||
}) | ||
describe('routing', () => { | ||
it('should access the datahub with a filter', () => { | ||
cy.get('@linkGroup').find('a').click() | ||
cy.url().should('include', 'search/publisher=') | ||
}) | ||
it('should access the user list page and show my-org users', () => { | ||
cy.visit(`/records/my-org`) | ||
cy.get('md-editor-dashboard-menu').find('a').first().click() | ||
cy.get('@linkGroup').find('gn-ui-button').click() | ||
cy.url().should('include', '/users/my-org') | ||
cy.get('.grid').should('have.length.above', 0) | ||
cy.get('h1').should('not.have.text', '') | ||
cy.get('gn-ui-thumbnail') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
apps/metadata-editor/src/app/my-org-users/my-org-users.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.record-table-col { | ||
@apply px-5 py-3 items-center truncate; | ||
} | ||
|
||
.record-table-header { | ||
@apply record-table-col capitalize; | ||
} |
2 changes: 2 additions & 0 deletions
2
apps/metadata-editor/src/app/my-org-users/my-org-users.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<md-editor-records-list [users]="userList" [logo]="logoUrl" [title]="orgName"> | ||
</md-editor-records-list> |
89 changes: 89 additions & 0 deletions
89
apps/metadata-editor/src/app/my-org-users/my-org-users.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { MyOrgUsersComponent } from './my-org-users.component' | ||
import { BehaviorSubject, of } from 'rxjs' | ||
import { | ||
ORGANISATIONS_FIXTURE, | ||
USER_FIXTURE, | ||
USERS_FIXTURE, | ||
} from '@geonetwork-ui/common/fixtures' | ||
import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' | ||
import { AuthService } from '@geonetwork-ui/feature/auth' | ||
import { SearchFacade } from '@geonetwork-ui/feature/search' | ||
|
||
describe('MyOrgUsersComponent', () => { | ||
let component: MyOrgUsersComponent | ||
let searchFacade: SearchFacade | ||
let orgService: OrganizationsServiceInterface | ||
let authService: AuthService | ||
|
||
beforeEach(() => { | ||
const user = USER_FIXTURE() | ||
const allUsers = USERS_FIXTURE() | ||
|
||
const authServiceMock = { | ||
user$: new BehaviorSubject(user), | ||
allUsers$: new BehaviorSubject(allUsers), | ||
} | ||
|
||
const organisationsServiceMock = { | ||
organisations$: of(ORGANISATIONS_FIXTURE), | ||
} | ||
|
||
const searchFacadeMock = { | ||
resetSearch: jest.fn(), | ||
} | ||
|
||
authService = authServiceMock as any | ||
orgService = organisationsServiceMock as any | ||
searchFacade = searchFacadeMock as any | ||
|
||
component = new MyOrgUsersComponent(searchFacade, authService, orgService) | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
describe('Get organization users info', () => { | ||
it('should get the org name', () => { | ||
expect(component.orgName).toEqual('Région Hauts-de-France') // Replace with your test data | ||
}) | ||
|
||
it('should get the org logo', () => { | ||
expect(component.logoUrl).toEqual('https://my-geonetwork.org/logo11.png') // Replace with your test data | ||
}) | ||
|
||
it('should get the list of users', () => { | ||
expect(component.userList).toEqual([ | ||
{ | ||
id: '46798', | ||
profile: 'Administrator', | ||
username: 'Gravin', | ||
name: 'Arnaud', | ||
surname: 'De Maison', | ||
email: '[email protected]', | ||
organisation: 'Région Hauts-de-France', | ||
profileIcon: | ||
'https://www.gravatar.com/avatar/dbdffd183622800bcf8587328daf43a6?d=mp', | ||
}, | ||
{ | ||
id: '3', | ||
profile: 'Editor', | ||
username: 'voldy63', | ||
name: 'Lord', | ||
surname: 'Voldemort', | ||
email: '[email protected]', | ||
organisation: 'Région Hauts-de-France', | ||
}, | ||
{ | ||
id: '4', | ||
profile: 'Editor', | ||
username: 'al.dumble98', | ||
name: 'Albus', | ||
surname: 'Dumblerdore', | ||
email: '[email protected]', | ||
organisation: 'Région Hauts-de-France', | ||
}, | ||
]) | ||
}) | ||
}) | ||
}) |
46 changes: 46 additions & 0 deletions
46
apps/metadata-editor/src/app/my-org-users/my-org-users.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component } from '@angular/core' | ||
import { RecordsListComponent } from '../records/records-list.component' | ||
import { SearchFacade } from '@geonetwork-ui/feature/search' | ||
import { AuthService } from '@geonetwork-ui/feature/auth' | ||
import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' | ||
import { UiInputsModule } from '@geonetwork-ui/ui/inputs' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
import { CommonModule } from '@angular/common' | ||
|
||
@Component({ | ||
selector: 'md-editor-my-org-users', | ||
templateUrl: './my-org-users.component.html', | ||
styleUrls: ['./my-org-users.component.css'], | ||
standalone: true, | ||
imports: [ | ||
RecordsListComponent, | ||
UiInputsModule, | ||
TranslateModule, | ||
CommonModule, | ||
], | ||
}) | ||
export class MyOrgUsersComponent { | ||
orgName: string | ||
logoUrl: string | ||
userList: any[] | ||
|
||
constructor( | ||
public searchFacade: SearchFacade, | ||
public authService: AuthService, | ||
private orgService: OrganizationsServiceInterface | ||
) { | ||
this.searchFacade.resetSearch() | ||
this.authService.user$.subscribe((user) => { | ||
this.orgName = user.organisation | ||
}) | ||
this.orgService.organisations$.subscribe((orgs) => { | ||
const org = orgs.filter((org) => org.name === this.orgName)[0] | ||
if (org) { | ||
this.logoUrl = org.logoUrl?.href.toString() | ||
} | ||
}) | ||
this.authService.allUsers$.subscribe((users) => { | ||
this.userList = users.filter((user) => user.organisation === this.orgName) | ||
}) | ||
} | ||
} |
7 changes: 6 additions & 1 deletion
7
apps/metadata-editor/src/app/records/my-org-records/my-org-records.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
<md-editor-records-list [title]="'dashboard.records.myOrg' | translate"> | ||
<md-editor-records-list | ||
[logo]="logoUrl" | ||
[title]="orgName" | ||
[recordCount]="recordCount" | ||
[userCount]="userCount" | ||
> | ||
</md-editor-records-list> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.