-
Notifications
You must be signed in to change notification settings - Fork 423
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
Create new Item Version (basic Items only) #1318
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
5b036e8
[CST-4499] Version history module (WIP)
alemarte a1e3124
[CST-4499] Version history (WIP) - Buttons added to history, form rep…
6f24b31
[CST-4499] Version history (WIP) - Removed summary page (with routing…
95ffc7a
[CST-4499] Version history (WIP) - Added in-row editing in version hi…
72bfab1
[CST-4499] Version history (WIP) - Changes to in-row editing, code cl…
d402ab7
[CST-4499] Version history (WIP) - New version modal and other changes
05385f3
[CST-4499] Version history (WIP) - Fixes to API calls
dd2df91
[CST-4499] Version history (WIP) - Fixes to API calls
ad5ace7
Changes by alex
44d3558
[CST-4499] Version history (WIP) - 'Create version' button in item pa…
ce399cb
[CST-4499] Version history (WIP) - Missing tests and auth features
alemarte b4111fe
[CST-4499] Version history (WIP) - Version page added (redirecting to…
f10f25d
Merge remote-tracking branch 'bb/CST-4499' into CST-4499
5d8f625
[CST-4499] Version history (WIP) - Refactoring
60bbb9a
[CST-4499] Version history (WIP) - Redirect after deleting a version
77ff774
[CST-4499] Version history (WIP) - Minor fixes and code cleanup
f858eee
[CST-4499] Version history (WIP) - Authorization features - Deleting …
cf1c73b
[CST-4499] Version history (WIP) - Authorization features - Deleting
b1b2bd4
[CST-4499] Version history (WIP) - Authorization features - Cache iss…
025e7f5
[CST-4499] Version history (WIP) - Cache issue fixed
55a1a1c
[CST-4499] Version history (WIP) - Refactoring
97ed08e
[CST-4499] Version history - Test TBD
a547030
[CST-4499] Version history - LGTM fixes - Test TBD
fbc6983
[CST-4499] Version history - Tests WIP
3255a29
[CST-4499] Version history - Tests WIP
62fea1f
[CST-4499] Version history - Tests WIP
aee612e
[CST-4499] Version history - Old tests fixed
468ad70
[CST-4499] Version history - Old tests fixed
c816b97
[CST-4499] Version history - Old tests fixed
f60755b
[CST-4499] Version history - New version refactored - Test TBD
4f2697b
[CST-4499] Version history - New version refactored (with tests)
ca9ca01
[CST-4499] Version history - Redirect to Edit Item
8a38d06
[CST-4499] Version history - Fixes and tests
e111f7c
[CST-4499] Version history - Minor fixes
b7d6c8e
[CST-4499] Version history - SSR bug fixed
850970e
[CST-4499] Version history - Code refactoring (WIP) and "Edit workspa…
e4d468b
[CST-4499] Version history - Changes to version history table
dfeee78
Merge branch 'main' into CST-4499
7c40c3b
[CST-4499] Version history - Pagination fixed
bee6289
[CST-4499] Version history - Test
8f541c3
[CST-4499] Add tests to workspaceitem-data.service and workflowitem-d…
atarix83 e142a49
[CST-4499] Add tests to version-data.service
atarix83 376d803
[CST-4499] Version history - Test item-data.service and item-versions…
6dac829
Merge branch 'main' of github.com:4science/dspace-angular into CST-4499
3cc302b
[CST-4499] Version history - Test version-history-data.service
82f6a78
Merge branch 'main' into CST-4499
75fffe2
[CST-4499] Version history - Test version-history-data.service
d12f932
[CST-4499] Version history - Test version-history-data.service
52baa81
[CST-4499] Version history - Test versioned-item.component
3b0e1db
[CST-4499] Version history - Test item-versions.component
fd61ac0
[CST-4499] Version history - Test item-versions.component
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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,181 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { of as observableOf } from 'rxjs'; | ||
import { TestScheduler } from 'rxjs/testing'; | ||
|
||
import { NotificationsService } from '../../shared/notifications/notifications.service'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | ||
import { RequestService } from './request.service'; | ||
import { PageInfo } from '../shared/page-info.model'; | ||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; | ||
import { RequestEntry } from './request.reducer'; | ||
import { HrefOnlyDataService } from './href-only-data.service'; | ||
import { getMockHrefOnlyDataService } from '../../shared/mocks/href-only-data.service.mock'; | ||
|
||
import { Store } from '@ngrx/store'; | ||
import { CoreState } from '../core.reducers'; | ||
import { RestResponse } from '../cache/response.models'; | ||
import { cold, getTestScheduler, hot } from 'jasmine-marbles'; | ||
import { Item } from '../shared/item.model'; | ||
import { VersionDataService } from './version-data.service'; | ||
import { Version } from '../shared/version.model'; | ||
import { VersionHistory } from '../shared/version-history.model'; | ||
import { followLink } from '../../shared/utils/follow-link-config.model'; | ||
|
||
|
||
describe('VersionDataService test', () => { | ||
let scheduler: TestScheduler; | ||
let service: VersionDataService; | ||
let requestService: RequestService; | ||
let rdbService: RemoteDataBuildService; | ||
let objectCache: ObjectCacheService; | ||
let halService: HALEndpointService; | ||
let hrefOnlyDataService: HrefOnlyDataService; | ||
let responseCacheEntry: RequestEntry; | ||
|
||
const item = Object.assign(new Item(), { | ||
id: '1234-1234', | ||
uuid: '1234-1234', | ||
bundles: observableOf({}), | ||
metadata: { | ||
'dc.title': [ | ||
{ | ||
language: 'en_US', | ||
value: 'This is just another title' | ||
} | ||
], | ||
'dc.type': [ | ||
{ | ||
language: null, | ||
value: 'Article' | ||
} | ||
], | ||
'dc.contributor.author': [ | ||
{ | ||
language: 'en_US', | ||
value: 'Smith, Donald' | ||
} | ||
], | ||
'dc.date.issued': [ | ||
{ | ||
language: null, | ||
value: '2015-06-26' | ||
} | ||
] | ||
} | ||
}); | ||
const itemRD = createSuccessfulRemoteDataObject(item); | ||
|
||
const versionHistory = Object.assign(new VersionHistory(), { | ||
id: '1', | ||
draftVersion: true, | ||
}); | ||
|
||
const mockVersion: Version = Object.assign(new Version(), { | ||
item: createSuccessfulRemoteDataObject$(item), | ||
versionhistory: createSuccessfulRemoteDataObject$(versionHistory), | ||
version: 1, | ||
}); | ||
const mockVersionRD = createSuccessfulRemoteDataObject(mockVersion); | ||
|
||
const endpointURL = `https://rest.api/rest/api/versioning/versions`; | ||
const findByIdRequestURL = `https://rest.api/rest/api/versioning/versions/${mockVersion.id}`; | ||
const findByIdRequestURL$ = observableOf(findByIdRequestURL); | ||
|
||
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a'; | ||
|
||
objectCache = {} as ObjectCacheService; | ||
const notificationsService = {} as NotificationsService; | ||
const http = {} as HttpClient; | ||
const comparator = {} as any; | ||
const comparatorEntry = {} as any; | ||
const store = {} as Store<CoreState>; | ||
const pageInfo = new PageInfo(); | ||
|
||
function initTestService() { | ||
hrefOnlyDataService = getMockHrefOnlyDataService(); | ||
return new VersionDataService( | ||
requestService, | ||
rdbService, | ||
store, | ||
objectCache, | ||
halService, | ||
notificationsService, | ||
http, | ||
comparatorEntry | ||
); | ||
} | ||
|
||
describe('', () => { | ||
beforeEach(() => { | ||
|
||
scheduler = getTestScheduler(); | ||
|
||
halService = jasmine.createSpyObj('halService', { | ||
getEndpoint: cold('a', { a: endpointURL }) | ||
}); | ||
responseCacheEntry = new RequestEntry(); | ||
responseCacheEntry.request = { href: 'https://rest.api/' } as any; | ||
responseCacheEntry.response = new RestResponse(true, 200, 'Success'); | ||
|
||
requestService = jasmine.createSpyObj('requestService', { | ||
generateRequestId: requestUUID, | ||
send: true, | ||
removeByHrefSubstring: {}, | ||
getByHref: observableOf(responseCacheEntry), | ||
getByUUID: observableOf(responseCacheEntry), | ||
}); | ||
rdbService = jasmine.createSpyObj('rdbService', { | ||
buildSingle: hot('(a|)', { | ||
a: mockVersionRD | ||
}) | ||
}); | ||
|
||
service = initTestService(); | ||
|
||
spyOn((service as any), 'findByHref').and.callThrough(); | ||
spyOn((service as any), 'getIDHrefObs').and.returnValue(findByIdRequestURL$); | ||
}); | ||
|
||
afterEach(() => { | ||
service = null; | ||
}); | ||
|
||
describe('getHistoryFromVersion', () => { | ||
it('should proxy the call to DataService.findByHref', () => { | ||
scheduler.schedule(() => service.getHistoryFromVersion(mockVersion, true, true)); | ||
scheduler.flush(); | ||
|
||
expect((service as any).findByHref).toHaveBeenCalledWith(findByIdRequestURL$, true, true, followLink('versionhistory')); | ||
}); | ||
|
||
it('should return a VersionHistory', () => { | ||
const result = service.getHistoryFromVersion(mockVersion, true, true); | ||
const expected = cold('(a|)', { | ||
a: versionHistory | ||
}); | ||
expect(result).toBeObservable(expected); | ||
}); | ||
|
||
it('should return an EMPTY observable when version is not given', () => { | ||
const result = service.getHistoryFromVersion(null); | ||
const expected = cold('|'); | ||
expect(result).toBeObservable(expected); | ||
}); | ||
}); | ||
|
||
describe('getHistoryIdFromVersion', () => { | ||
it('should return the version history id', () => { | ||
spyOn((service as any), 'getHistoryFromVersion').and.returnValue(observableOf(versionHistory)); | ||
|
||
const result = service.getHistoryIdFromVersion(mockVersion); | ||
const expected = cold('(a|)', { | ||
a: versionHistory.id | ||
}); | ||
expect(result).toBeObservable(expected); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New method missing specs