mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
[CST-12109] tests & translations
This commit is contained in:
@@ -17,13 +17,14 @@ describe('ItemAlertsComponent', () => {
|
|||||||
let dsoWithdrawnReinstateModalService;
|
let dsoWithdrawnReinstateModalService;
|
||||||
let correctionTypeDataService;
|
let correctionTypeDataService;
|
||||||
|
|
||||||
|
const itemMock = Object.assign(new Item(), {
|
||||||
|
uuid: 'item-uuid',
|
||||||
|
id: 'item-uuid',
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
authorizationService = jasmine.createSpyObj('authorizationService', {
|
authorizationService = jasmine.createSpyObj('authorizationService', ['isAuthorized']);
|
||||||
isAuthorized: of(true)
|
dsoWithdrawnReinstateModalService = jasmine.createSpyObj('dsoWithdrawnReinstateModalService',['openCreateWithdrawnReinstateModal']);
|
||||||
});
|
|
||||||
dsoWithdrawnReinstateModalService = jasmine.createSpyObj('dsoWithdrawnReinstateModalService', {
|
|
||||||
openCreateWithdrawnReinstateModal: {}
|
|
||||||
});
|
|
||||||
correctionTypeDataService = jasmine.createSpyObj('correctionTypeDataService', {
|
correctionTypeDataService = jasmine.createSpyObj('correctionTypeDataService', {
|
||||||
findByItem: of({})
|
findByItem: of({})
|
||||||
});
|
});
|
||||||
@@ -43,6 +44,7 @@ describe('ItemAlertsComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ItemAlertsComponent);
|
fixture = TestBed.createComponent(ItemAlertsComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
component.item = itemMock;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,4 +107,47 @@ describe('ItemAlertsComponent', () => {
|
|||||||
expect(privateWarning).toBeNull();
|
expect(privateWarning).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('show reinstate button', () => {
|
||||||
|
it('should return false if user is an admin', () => {
|
||||||
|
const isAdmin$ = of(true);
|
||||||
|
authorizationService.isAuthorized.and.returnValue(isAdmin$);
|
||||||
|
const result$ = component.showReinstateButton$();
|
||||||
|
result$.subscribe((result) => {
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if no correction types are found', () => {
|
||||||
|
const isAdmin$ = of(false);
|
||||||
|
authorizationService.isAuthorized.and.returnValue(isAdmin$);
|
||||||
|
correctionTypeDataService.findByItem.and.returnValue(of([]));
|
||||||
|
const result$ = component.showReinstateButton$();
|
||||||
|
result$.subscribe((result) => {
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if no correction type with topic "REQUEST_REINSTATE" is found', () => {
|
||||||
|
const isAdmin$ = of(false);
|
||||||
|
authorizationService.isAuthorized.and.returnValue(isAdmin$);
|
||||||
|
correctionTypeDataService.findByItem.and.returnValue(of([{ topic: 'OTHER_TOPIC' }]));
|
||||||
|
const result$ = component.showReinstateButton$();
|
||||||
|
result$.subscribe((result) => {
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true if user is not an admin and correction type with topic "REQUEST_REINSTATE" is found', () => {
|
||||||
|
const isAdmin$ = of(false);
|
||||||
|
authorizationService.isAuthorized.and.returnValue(isAdmin$);
|
||||||
|
correctionTypeDataService.findByItem.and.returnValue(of([{ topic: 'REQUEST_REINSTATE' }]));
|
||||||
|
|
||||||
|
const result$ = component.showReinstateButton$();
|
||||||
|
|
||||||
|
result$.subscribe((result) => {
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let sourceElement of (sources$ | async); let i = index">
|
<tr *ngFor="let sourceElement of (sources$ | async); let i = index">
|
||||||
<td>{{sourceElement.id}}</td>
|
<td>{{sourceElement.id}}</td>
|
||||||
<td>{{sourceElement.lastEvent}}</td>
|
<td>{{formatDate(sourceElement.lastEvent)}}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group edit-field">
|
<div class="btn-group edit-field">
|
||||||
<button
|
<button
|
||||||
|
@@ -8,7 +8,7 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
|
|||||||
import { NotificationsStateService } from '../../notifications-state.service';
|
import { NotificationsStateService } from '../../notifications-state.service';
|
||||||
import { AdminQualityAssuranceSourcePageParams } from '../../../admin/admin-notifications/admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
|
import { AdminQualityAssuranceSourcePageParams } from '../../../admin/admin-notifications/admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
|
||||||
import { hasValue } from '../../../shared/empty.util';
|
import { hasValue } from '../../../shared/empty.util';
|
||||||
|
import { format } from 'date-fns';
|
||||||
/**
|
/**
|
||||||
* Component to display the Quality Assurance source list.
|
* Component to display the Quality Assurance source list.
|
||||||
*/
|
*/
|
||||||
@@ -65,6 +65,20 @@ export class QualityAssuranceSourceComponent implements OnInit {
|
|||||||
this.totalElements$ = this.notificationsStateService.getQualityAssuranceSourceTotals();
|
this.totalElements$ = this.notificationsStateService.getQualityAssuranceSourceTotals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the given date string into the format 'yyyy-MM-dd HH:mm:ss'.
|
||||||
|
* If the date is falsy, an empty string is returned.
|
||||||
|
*
|
||||||
|
* @param date - The date string to be formatted.
|
||||||
|
* @returns The formatted date string.
|
||||||
|
*/
|
||||||
|
formatDate(date: string): string {
|
||||||
|
if (!date) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return format(new Date(date), 'yyyy-MM-dd HH:mm:ss');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First Quality Assurance source loading after view initialization.
|
* First Quality Assurance source loading after view initialization.
|
||||||
*/
|
*/
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let topicElement of (topics$ | async); let i = index">
|
<tr *ngFor="let topicElement of (topics$ | async); let i = index">
|
||||||
<td>{{topicElement.name}}</td>
|
<td>{{topicElement.name}}</td>
|
||||||
<td>{{topicElement.lastEvent}}</td>
|
<td>{{formatDate(topicElement.lastEvent)}}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group edit-field">
|
<div class="btn-group edit-field">
|
||||||
<button
|
<button
|
||||||
|
@@ -20,6 +20,7 @@ import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../../../core
|
|||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { getItemPageRoute } from '../../../item-page/item-page-routing-paths';
|
import { getItemPageRoute } from '../../../item-page/item-page-routing-paths';
|
||||||
import { getNotificatioQualityAssuranceRoute } from '../../../admin/admin-routing-paths';
|
import { getNotificatioQualityAssuranceRoute } from '../../../admin/admin-routing-paths';
|
||||||
|
import { format } from 'date-fns';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to display the Quality Assurance topic list.
|
* Component to display the Quality Assurance topic list.
|
||||||
@@ -201,6 +202,20 @@ export class QualityAssuranceTopicsComponent implements OnInit {
|
|||||||
return getNotificatioQualityAssuranceRoute();
|
return getNotificatioQualityAssuranceRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the given date string into the format 'yyyy-MM-dd HH:mm:ss'.
|
||||||
|
* If the date is falsy, an empty string is returned.
|
||||||
|
*
|
||||||
|
* @param date - The date string to format.
|
||||||
|
* @returns The formatted date string.
|
||||||
|
*/
|
||||||
|
formatDate(date: string): string {
|
||||||
|
if (!date) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return format(new Date(date), 'yyyy-MM-dd HH:mm:ss');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe from all subscriptions.
|
* Unsubscribe from all subscriptions.
|
||||||
*/
|
*/
|
||||||
|
@@ -38,7 +38,7 @@ export class DsoWithdrawnReinstateModalService {
|
|||||||
/**
|
/**
|
||||||
* Open the create withdrawn modal for the provided dso
|
* Open the create withdrawn modal for the provided dso
|
||||||
*/
|
*/
|
||||||
openCreateWithdrawnReinstateModal(dso: Item, correctionType: string, state: boolean): void {
|
openCreateWithdrawnReinstateModal(dso: Item, correctionType: 'request-reinstate' | 'request-withdrawn', state: boolean): void {
|
||||||
const target = dso.id;
|
const target = dso.id;
|
||||||
// Open modal
|
// Open modal
|
||||||
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
||||||
@@ -63,16 +63,17 @@ export class DsoWithdrawnReinstateModalService {
|
|||||||
* Reloads the current page in order to update the withdrawn/reinstate button.
|
* Reloads the current page in order to update the withdrawn/reinstate button.
|
||||||
* and desplay a notification box.
|
* and desplay a notification box.
|
||||||
*/
|
*/
|
||||||
sendQARequest(target: string, correctionType: string, reason: string): void {
|
sendQARequest(target: string, correctionType: 'request-reinstate' | 'request-withdrawn', reason: string): void {
|
||||||
this.qaEventDataService.postData(target, correctionType, '', reason)
|
this.qaEventDataService.postData(target, correctionType, '', reason)
|
||||||
.pipe (
|
.pipe (
|
||||||
getFirstCompletedRemoteData()
|
getFirstCompletedRemoteData()
|
||||||
)
|
)
|
||||||
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
||||||
if (res.hasSucceeded) {
|
if (res.hasSucceeded) {
|
||||||
const withdrawnMessage = 'Withdrawn request sent.';
|
const message = (correctionType === 'request-withdrawn')
|
||||||
const reinstateMessage = 'Reinstate request sent.';
|
? 'correction-type.manage-relation.action.notification.withdrawn'
|
||||||
const message = (correctionType === 'request-withdrawn') ? withdrawnMessage : reinstateMessage;
|
: 'correction-type.manage-relation.action.notification.reinstate';
|
||||||
|
|
||||||
this.notificationsService.success(this.translateService.get(message));
|
this.notificationsService.success(this.translateService.get(message));
|
||||||
this.authorizationService.invalidateAuthorizationsRequestCache();
|
this.authorizationService.invalidateAuthorizationsRequestCache();
|
||||||
this.reloadPage(true);
|
this.reloadPage(true);
|
||||||
|
@@ -2648,6 +2648,10 @@
|
|||||||
|
|
||||||
"item.qa.withdrawn.modal.submitted.header": "Sending withdrawn request...",
|
"item.qa.withdrawn.modal.submitted.header": "Sending withdrawn request...",
|
||||||
|
|
||||||
|
"correction-type.manage-relation.action.notification.reinstate": "Reinstate request sent.",
|
||||||
|
|
||||||
|
"correction-type.manage-relation.action.notification.withdrawn": "Withdraw request sent.",
|
||||||
|
|
||||||
"qa-event-notification.check.notification-withdrawn": "You have requested to withdraw this item.",
|
"qa-event-notification.check.notification-withdrawn": "You have requested to withdraw this item.",
|
||||||
|
|
||||||
"qa-event-notification.check.notification-reinstate": "You have requested to reinstate this item.",
|
"qa-event-notification.check.notification-reinstate": "You have requested to reinstate this item.",
|
||||||
|
Reference in New Issue
Block a user