[ACS-8001] fix import

This commit is contained in:
Mykyta Maliarchuk
2024-06-11 23:01:07 +02:00
committed by Mykyta Maliarchuk
parent 654dec8d57
commit b5877e6faa

View File

@@ -22,7 +22,10 @@ import {
Category, Category,
CategoryPaging, CategoryPaging,
ClassesApi, ClassesApi,
Node, Prediction, PredictionPaging, ReviewStatus, Node,
Prediction,
PredictionPaging,
ReviewStatus,
Tag, Tag,
TagBody, TagBody,
TagEntry, TagEntry,
@@ -1679,20 +1682,20 @@ describe('ContentMetadataComponent', () => {
describe('Predictions', () => { describe('Predictions', () => {
const getMockPrediction = (reviewStatus: ReviewStatus): Prediction => ({ const getMockPrediction = (reviewStatus: ReviewStatus): Prediction => ({
confidenceLevel: 0.9, confidenceLevel: 0.9,
predictionDateTime: new Date(2024, 1, 1), predictionDateTime: new Date(2024, 1, 1),
modelId: 'test-model-id', modelId: 'test-model-id',
property: 'test:test', property: 'test:test',
id: 'test-prediction-id', id: 'test-prediction-id',
previousValue: 'previous value', previousValue: 'previous value',
predictionValue: 'new value', predictionValue: 'new value',
updateType: 'AUTOCORRECT', updateType: 'AUTOCORRECT',
reviewStatus: reviewStatus reviewStatus: reviewStatus
}); });
const getMockPredictionPaging = (predictions: Prediction[]): PredictionPaging => ({ const getMockPredictionPaging = (predictions: Prediction[]): PredictionPaging => ({
list: { list: {
entries: predictions.map(prediction => ({entry: prediction})) entries: predictions.map((prediction) => ({ entry: prediction }))
} }
}); });
@@ -1701,7 +1704,9 @@ describe('ContentMetadataComponent', () => {
beforeEach(() => { beforeEach(() => {
component.node = node; component.node = node;
component.displayPredictions = true; component.displayPredictions = true;
getPredictionsSpy = spyOn(predictionService, 'getPredictions').and.returnValue(of(getMockPredictionPaging([getMockPrediction(ReviewStatus.UNREVIEWED)]))); getPredictionsSpy = spyOn(predictionService, 'getPredictions').and.returnValue(
of(getMockPredictionPaging([getMockPrediction(ReviewStatus.UNREVIEWED)]))
);
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -1723,7 +1728,7 @@ describe('ContentMetadataComponent', () => {
); );
component.ngOnInit(); component.ngOnInit();
component.basicProperties$.subscribe(properties => { component.basicProperties$.subscribe((properties) => {
expect(properties[0].prediction).toEqual(getMockPrediction(ReviewStatus.UNREVIEWED)); expect(properties[0].prediction).toEqual(getMockPrediction(ReviewStatus.UNREVIEWED));
done(); done();
}); });
@@ -1735,25 +1740,29 @@ describe('ContentMetadataComponent', () => {
{ {
editable: true, editable: true,
title: 'test', title: 'test',
properties: [{ properties: [
key: 'properties.test:test', {
editable: true, key: 'properties.test:test',
value: 'new value', editable: true,
title: 'test' value: 'new value',
}] title: 'test'
}
]
} }
]) ])
); );
component.ngOnInit(); component.ngOnInit();
component.groupedProperties$.subscribe(properties => { component.groupedProperties$.subscribe((properties) => {
expect(properties[0].properties[0].prediction).toEqual(getMockPrediction(ReviewStatus.UNREVIEWED)); expect(properties[0].properties[0].prediction).toEqual(getMockPrediction(ReviewStatus.UNREVIEWED));
done(); done();
}); });
}); });
it('should not map predictions when reviewStatus other then UNREVIEWED', (done) => { it('should not map predictions when reviewStatus other then UNREVIEWED', (done) => {
getPredictionsSpy.and.returnValue(of(getMockPredictionPaging([getMockPrediction(ReviewStatus.REJECTED), getMockPrediction(ReviewStatus.CONFIRMED)]))); getPredictionsSpy.and.returnValue(
of(getMockPredictionPaging([getMockPrediction(ReviewStatus.REJECTED), getMockPrediction(ReviewStatus.CONFIRMED)]))
);
getBasicPropertiesSpy.and.returnValue( getBasicPropertiesSpy.and.returnValue(
of([ of([
{ {
@@ -1766,7 +1775,7 @@ describe('ContentMetadataComponent', () => {
); );
component.ngOnInit(); component.ngOnInit();
component.basicProperties$.subscribe(properties => { component.basicProperties$.subscribe((properties) => {
expect(properties[0].prediction).toBeNull(); expect(properties[0].prediction).toBeNull();
done(); done();
}); });
@@ -1785,24 +1794,24 @@ describe('ContentMetadataComponent', () => {
); );
component.ngOnInit(); component.ngOnInit();
component.basicProperties$.subscribe(properties => { component.basicProperties$.subscribe((properties) => {
expect(properties[0].prediction).toBeNull(); expect(properties[0].prediction).toBeNull();
done(); done();
}); });
}); });
it('should set updated node when prediction status has changed', () => { it('should set updated node when prediction status has changed', () => {
const updatedNode = {...node, name: 'new test name'}; const updatedNode = { ...node, name: 'new test name' };
const getNodeSpy = spyOn(nodesApiService, 'getNode').and.returnValue(of(updatedNode)); const getNodeSpy = spyOn(nodesApiService, 'getNode').and.returnValue(of(updatedNode));
component.ngOnInit(); component.ngOnInit();
predictionService.predictionStatusUpdated$.next({key: 'test:test', previousValue: 'previous value'}); predictionService.predictionStatusUpdated$.next({ key: 'test:test', previousValue: 'previous value' });
expect(getNodeSpy).toHaveBeenCalledWith(node.id); expect(getNodeSpy).toHaveBeenCalledWith(node.id);
expect(component.node).toEqual(updatedNode); expect(component.node).toEqual(updatedNode);
}); });
it('should call onPredictionStatusChanged when prediction status has changed', () => { it('should call onPredictionStatusChanged when prediction status has changed', () => {
const onPredictionStatusChangedSpy = spyOn(updateService, 'onPredictionStatusChanged'); const onPredictionStatusChangedSpy = spyOn(updateService, 'onPredictionStatusChanged');
const notification = {key: 'test:test', previousValue: 'previous value'}; const notification = { key: 'test:test', previousValue: 'previous value' };
component.ngOnInit(); component.ngOnInit();
predictionService.predictionStatusUpdated$.next(notification); predictionService.predictionStatusUpdated$.next(notification);
expect(onPredictionStatusChangedSpy).toHaveBeenCalledWith([notification]); expect(onPredictionStatusChangedSpy).toHaveBeenCalledWith([notification]);