mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fixup tests
This commit is contained in:
parent
b855b9481f
commit
e940e2cc8a
@ -64,6 +64,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
hotkeyService = TestBed.inject(HotKeyService)
|
hotkeyService = TestBed.inject(HotKeyService)
|
||||||
fixture = TestBed.createComponent(FilterableDropdownComponent)
|
fixture = TestBed.createComponent(FilterableDropdownComponent)
|
||||||
component = fixture.componentInstance
|
component = fixture.componentInstance
|
||||||
|
component.selectionModel = new FilterableDropdownSelectionModel()
|
||||||
selectionModel = new FilterableDropdownSelectionModel()
|
selectionModel = new FilterableDropdownSelectionModel()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should support reset', () => {
|
it('should support reset', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
||||||
expect(selectionModel.getSelectedItems()).toHaveLength(1)
|
expect(selectionModel.getSelectedItems()).toHaveLength(1)
|
||||||
@ -96,7 +97,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should emit change when items selected', () => {
|
it('should emit change when items selected', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
let newModel: FilterableDropdownSelectionModel
|
let newModel: FilterableDropdownSelectionModel
|
||||||
component.selectionModelChange.subscribe((model) => (newModel = model))
|
component.selectionModelChange.subscribe((model) => (newModel = model))
|
||||||
@ -110,11 +111,11 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
selectionModel.set(items[0].id, ToggleableItemState.NotSelected)
|
selectionModel.set(items[0].id, ToggleableItemState.NotSelected)
|
||||||
expect(newModel.getSelectedItems()).toEqual([])
|
expect(newModel.getSelectedItems()).toEqual([])
|
||||||
|
|
||||||
expect(component.items).toEqual([nullItem, ...items])
|
expect(component.selectionModel.items).toEqual([nullItem, ...items])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit change when items excluded', () => {
|
it('should emit change when items excluded', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
let newModel: FilterableDropdownSelectionModel
|
let newModel: FilterableDropdownSelectionModel
|
||||||
component.selectionModelChange.subscribe((model) => (newModel = model))
|
component.selectionModelChange.subscribe((model) => (newModel = model))
|
||||||
@ -124,7 +125,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should emit change when items excluded', () => {
|
it('should emit change when items excluded', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
let newModel: FilterableDropdownSelectionModel
|
let newModel: FilterableDropdownSelectionModel
|
||||||
component.selectionModelChange.subscribe((model) => (newModel = model))
|
component.selectionModelChange.subscribe((model) => (newModel = model))
|
||||||
@ -139,8 +140,8 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should exclude items when excluded and not editing', () => {
|
it('should exclude items when excluded and not editing', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.manyToOne = true
|
component.selectionModel.manyToOne = true
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
||||||
component.excludeClicked(items[0].id)
|
component.excludeClicked(items[0].id)
|
||||||
@ -149,8 +150,8 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should toggle when items excluded and editing', () => {
|
it('should toggle when items excluded and editing', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.manyToOne = true
|
component.selectionModel.manyToOne = true
|
||||||
component.editing = true
|
component.editing = true
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
selectionModel.set(items[0].id, ToggleableItemState.NotSelected)
|
selectionModel.set(items[0].id, ToggleableItemState.NotSelected)
|
||||||
@ -160,8 +161,8 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should hide count for item if adding will increase size of set', () => {
|
it('should hide count for item if adding will increase size of set', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.manyToOne = true
|
component.selectionModel.manyToOne = true
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
expect(component.hideCount(items[0])).toBeFalsy()
|
expect(component.hideCount(items[0])).toBeFalsy()
|
||||||
selectionModel.logicalOperator = LogicalOperator.Or
|
selectionModel.logicalOperator = LogicalOperator.Or
|
||||||
@ -170,7 +171,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
|
|
||||||
it('should enforce single select when editing', () => {
|
it('should enforce single select when editing', () => {
|
||||||
component.editing = true
|
component.editing = true
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
let newModel: FilterableDropdownSelectionModel
|
let newModel: FilterableDropdownSelectionModel
|
||||||
component.selectionModelChange.subscribe((model) => (newModel = model))
|
component.selectionModelChange.subscribe((model) => (newModel = model))
|
||||||
@ -182,11 +183,11 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should support manyToOne selecting', () => {
|
it('should support manyToOne selecting', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
selectionModel.manyToOne = false
|
selectionModel.manyToOne = false
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
component.manyToOne = true
|
component.selectionModel.manyToOne = true
|
||||||
expect(component.manyToOne).toBeTruthy()
|
expect(component.selectionModel.manyToOne).toBeTruthy()
|
||||||
let newModel: FilterableDropdownSelectionModel
|
let newModel: FilterableDropdownSelectionModel
|
||||||
component.selectionModelChange.subscribe((model) => (newModel = model))
|
component.selectionModelChange.subscribe((model) => (newModel = model))
|
||||||
|
|
||||||
@ -197,12 +198,10 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should dynamically enable / disable modifier toggle', () => {
|
it('should dynamically enable / disable modifier toggle', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
expect(component.modifierToggleEnabled).toBeTruthy()
|
expect(component.modifierToggleEnabled).toBeTruthy()
|
||||||
selectionModel.toggle(null)
|
component.selectionModel.manyToOne = true
|
||||||
expect(component.modifierToggleEnabled).toBeFalsy()
|
|
||||||
component.manyToOne = true
|
|
||||||
expect(component.modifierToggleEnabled).toBeFalsy()
|
expect(component.modifierToggleEnabled).toBeFalsy()
|
||||||
selectionModel.toggle(items[0].id)
|
selectionModel.toggle(items[0].id)
|
||||||
selectionModel.toggle(items[1].id)
|
selectionModel.toggle(items[1].id)
|
||||||
@ -210,7 +209,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should apply changes and close when apply button clicked', () => {
|
it('should apply changes and close when apply button clicked', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.editing = true
|
component.editing = true
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
@ -232,7 +231,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should apply on close if enabled', () => {
|
it('should apply on close if enabled', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.editing = true
|
component.editing = true
|
||||||
component.applyOnClose = true
|
component.applyOnClose = true
|
||||||
@ -250,7 +249,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should focus text filter on open, support filtering, clear on close', fakeAsync(() => {
|
it('should focus text filter on open, support filtering, clear on close', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
fixture.nativeElement
|
fixture.nativeElement
|
||||||
.querySelector('button')
|
.querySelector('button')
|
||||||
@ -277,7 +276,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should toggle & close on enter inside filter field if 1 item remains', fakeAsync(() => {
|
it('should toggle & close on enter inside filter field if 1 item remains', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
expect(component.selectionModel.getSelectedItems()).toEqual([])
|
expect(component.selectionModel.getSelectedItems()).toEqual([])
|
||||||
fixture.nativeElement
|
fixture.nativeElement
|
||||||
@ -297,7 +296,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should apply & close on enter inside filter field if 1 item remains if editing', fakeAsync(() => {
|
it('should apply & close on enter inside filter field if 1 item remains if editing', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.editing = true
|
component.editing = true
|
||||||
let applyResult: ChangedItems
|
let applyResult: ChangedItems
|
||||||
@ -319,7 +318,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should support arrow keyboard navigation', fakeAsync(() => {
|
it('should support arrow keyboard navigation', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
fixture.nativeElement
|
fixture.nativeElement
|
||||||
.querySelector('button')
|
.querySelector('button')
|
||||||
@ -364,7 +363,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should support arrow keyboard navigation after tab keyboard navigation', fakeAsync(() => {
|
it('should support arrow keyboard navigation after tab keyboard navigation', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
fixture.nativeElement
|
fixture.nativeElement
|
||||||
.querySelector('button')
|
.querySelector('button')
|
||||||
@ -400,7 +399,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should support arrow keyboard navigation after click', fakeAsync(() => {
|
it('should support arrow keyboard navigation after click', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
fixture.nativeElement
|
fixture.nativeElement
|
||||||
.querySelector('button')
|
.querySelector('button')
|
||||||
@ -425,9 +424,9 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should toggle logical operator', fakeAsync(() => {
|
it('should toggle logical operator', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.manyToOne = true
|
component.selectionModel.manyToOne = true
|
||||||
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
||||||
selectionModel.set(items[1].id, ToggleableItemState.Selected)
|
selectionModel.set(items[1].id, ToggleableItemState.Selected)
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
@ -454,7 +453,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should toggle intersection include / exclude', fakeAsync(() => {
|
it('should toggle intersection include / exclude', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
selectionModel.set(items[0].id, ToggleableItemState.Selected)
|
||||||
selectionModel.set(items[1].id, ToggleableItemState.Selected)
|
selectionModel.set(items[1].id, ToggleableItemState.Selected)
|
||||||
@ -484,21 +483,22 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('selection model should sort items by state', () => {
|
it('selection model should sort items by state', () => {
|
||||||
component.items = items.concat([{ id: null, name: 'Null B' }])
|
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
|
component.selectionModel.items = items.concat([{ id: 3, name: 'Item3' }])
|
||||||
selectionModel.toggle(items[1].id)
|
selectionModel.toggle(items[1].id)
|
||||||
selectionModel.apply()
|
selectionModel.apply()
|
||||||
|
expect(selectionModel.items.length).toEqual(4)
|
||||||
expect(selectionModel.items).toEqual([
|
expect(selectionModel.items).toEqual([
|
||||||
nullItem,
|
nullItem,
|
||||||
{ id: null, name: 'Null B' },
|
|
||||||
items[1],
|
items[1],
|
||||||
|
{ id: 3, name: 'Item3' },
|
||||||
items[0],
|
items[0],
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('selection model should sort items by state and document counts = 0, if set', () => {
|
it('selection model should sort items by state and document counts = 0, if set', () => {
|
||||||
const tagA = { id: 4, name: 'Tag A' }
|
const tagA = { id: 4, name: 'Tag A' }
|
||||||
component.items = items.concat([tagA])
|
component.selectionModel.items = items.concat([tagA])
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
component.documentCounts = [
|
component.documentCounts = [
|
||||||
{ id: 1, document_count: 0 }, // Tag1
|
{ id: 1, document_count: 0 }, // Tag1
|
||||||
@ -529,7 +529,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should set support create, keep open model and call createRef method', fakeAsync(() => {
|
it('should set support create, keep open model and call createRef method', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
fixture.nativeElement
|
fixture.nativeElement
|
||||||
@ -549,7 +549,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
it('should call create on enter inside filter field if 0 items remain while editing', fakeAsync(() => {
|
it('should call create on enter inside filter field if 0 items remain while editing', fakeAsync(() => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.editing = true
|
component.editing = true
|
||||||
component.createRef = jest.fn()
|
component.createRef = jest.fn()
|
||||||
@ -569,7 +569,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
const id = 1
|
const id = 1
|
||||||
const state = ToggleableItemState.Selected
|
const state = ToggleableItemState.Selected
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
component.manyToOne = true
|
component.selectionModel.manyToOne = true
|
||||||
component.selectionModel.singleSelect = true
|
component.selectionModel.singleSelect = true
|
||||||
component.selectionModel.intersection = Intersection.Include
|
component.selectionModel.intersection = Intersection.Include
|
||||||
component.selectionModel['temporarySelectionStates'].set(id, state)
|
component.selectionModel['temporarySelectionStates'].set(id, state)
|
||||||
@ -596,7 +596,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should support shortcut keys', () => {
|
it('should support shortcut keys', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.shortcutKey = 't'
|
component.shortcutKey = 't'
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
@ -606,7 +606,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should support an extra button and not apply changes when clicked', () => {
|
it('should support an extra button and not apply changes when clicked', () => {
|
||||||
component.items = items
|
component.selectionModel.items = items
|
||||||
component.icon = 'tag-fill'
|
component.icon = 'tag-fill'
|
||||||
component.extraButtonTitle = 'Extra'
|
component.extraButtonTitle = 'Extra'
|
||||||
component.selectionModel = selectionModel
|
component.selectionModel = selectionModel
|
||||||
|
@ -1150,10 +1150,10 @@ describe('BulkEditorComponent', () => {
|
|||||||
|
|
||||||
it('should not attempt to retrieve objects if user does not have permissions', () => {
|
it('should not attempt to retrieve objects if user does not have permissions', () => {
|
||||||
jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
|
jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
|
||||||
expect(component.tags).toBeUndefined()
|
expect(component.tagSelectionModel.items.length).toEqual(0)
|
||||||
expect(component.correspondents).toBeUndefined()
|
expect(component.correspondentSelectionModel.items.length).toEqual(0)
|
||||||
expect(component.documentTypes).toBeUndefined()
|
expect(component.documentTypeSelectionModel.items.length).toEqual(0)
|
||||||
expect(component.storagePaths).toBeUndefined()
|
expect(component.storagePathsSelectionModel.items.length).toEqual(0)
|
||||||
httpTestingController.expectNone(`${environment.apiBaseUrl}documents/tags/`)
|
httpTestingController.expectNone(`${environment.apiBaseUrl}documents/tags/`)
|
||||||
httpTestingController.expectNone(
|
httpTestingController.expectNone(
|
||||||
`${environment.apiBaseUrl}documents/correspondents/`
|
`${environment.apiBaseUrl}documents/correspondents/`
|
||||||
@ -1204,7 +1204,9 @@ describe('BulkEditorComponent', () => {
|
|||||||
expect(tagListAllSpy).toHaveBeenCalled()
|
expect(tagListAllSpy).toHaveBeenCalled()
|
||||||
|
|
||||||
expect(tagSelectionModelToggleSpy).toHaveBeenCalledWith(newTag.id)
|
expect(tagSelectionModelToggleSpy).toHaveBeenCalledWith(newTag.id)
|
||||||
expect(component.tags).toEqual(tags.results)
|
expect(component.tagSelectionModel.items).toEqual(
|
||||||
|
[{ id: null, name: 'Not assigned' }].concat(tags.results as any)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support create new correspondent', () => {
|
it('should support create new correspondent', () => {
|
||||||
@ -1251,7 +1253,9 @@ describe('BulkEditorComponent', () => {
|
|||||||
expect(correspondentSelectionModelToggleSpy).toHaveBeenCalledWith(
|
expect(correspondentSelectionModelToggleSpy).toHaveBeenCalledWith(
|
||||||
newCorrespondent.id
|
newCorrespondent.id
|
||||||
)
|
)
|
||||||
expect(component.correspondents).toEqual(correspondents.results)
|
expect(component.correspondentSelectionModel.items).toEqual(
|
||||||
|
[{ id: null, name: 'Not assigned' }].concat(correspondents.results as any)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support create new document type', () => {
|
it('should support create new document type', () => {
|
||||||
@ -1295,7 +1299,9 @@ describe('BulkEditorComponent', () => {
|
|||||||
expect(documentTypeSelectionModelToggleSpy).toHaveBeenCalledWith(
|
expect(documentTypeSelectionModelToggleSpy).toHaveBeenCalledWith(
|
||||||
newDocumentType.id
|
newDocumentType.id
|
||||||
)
|
)
|
||||||
expect(component.documentTypes).toEqual(documentTypes.results)
|
expect(component.documentTypeSelectionModel.items).toEqual(
|
||||||
|
[{ id: null, name: 'Not assigned' }].concat(documentTypes.results as any)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support create new storage path', () => {
|
it('should support create new storage path', () => {
|
||||||
@ -1339,7 +1345,9 @@ describe('BulkEditorComponent', () => {
|
|||||||
expect(storagePathsSelectionModelToggleSpy).toHaveBeenCalledWith(
|
expect(storagePathsSelectionModelToggleSpy).toHaveBeenCalledWith(
|
||||||
newStoragePath.id
|
newStoragePath.id
|
||||||
)
|
)
|
||||||
expect(component.storagePaths).toEqual(storagePaths.results)
|
expect(component.storagePathsSelectionModel.items).toEqual(
|
||||||
|
[{ id: null, name: 'Not assigned' }].concat(storagePaths.results as any)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support create new custom field', () => {
|
it('should support create new custom field', () => {
|
||||||
@ -1391,7 +1399,9 @@ describe('BulkEditorComponent', () => {
|
|||||||
expect(customFieldsSelectionModelToggleSpy).toHaveBeenCalledWith(
|
expect(customFieldsSelectionModelToggleSpy).toHaveBeenCalledWith(
|
||||||
newCustomField.id
|
newCustomField.id
|
||||||
)
|
)
|
||||||
expect(component.customFields).toEqual(customFields.results)
|
expect(component.customFieldsSelectionModel.items).toEqual(
|
||||||
|
[{ id: null, name: 'Not assigned' }].concat(customFields.results as any)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should open the bulk edit custom field values dialog with correct parameters', () => {
|
it('should open the bulk edit custom field values dialog with correct parameters', () => {
|
||||||
@ -1416,17 +1426,17 @@ describe('BulkEditorComponent', () => {
|
|||||||
const toastServiceShowErrorSpy = jest.spyOn(toastService, 'showError')
|
const toastServiceShowErrorSpy = jest.spyOn(toastService, 'showError')
|
||||||
const listReloadSpy = jest.spyOn(documentListViewService, 'reload')
|
const listReloadSpy = jest.spyOn(documentListViewService, 'reload')
|
||||||
|
|
||||||
component.customFields = [
|
component.customFieldsSelectionModel.items = [
|
||||||
{ id: 1, name: 'Custom Field 1', data_type: CustomFieldDataType.String },
|
{ id: 1, name: 'Custom Field 1', data_type: CustomFieldDataType.String },
|
||||||
{ id: 2, name: 'Custom Field 2', data_type: CustomFieldDataType.String },
|
{ id: 2, name: 'Custom Field 2', data_type: CustomFieldDataType.String },
|
||||||
]
|
] as any
|
||||||
|
|
||||||
component.setCustomFieldValues({
|
component.setCustomFieldValues({
|
||||||
itemsToAdd: [{ id: 1 }, { id: 2 }],
|
itemsToAdd: [{ id: 1 }, { id: 2 }],
|
||||||
itemsToRemove: [1],
|
itemsToRemove: [1],
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
expect(modal.componentInstance.customFields).toEqual(component.customFields)
|
expect(modal.componentInstance.customFields.length).toEqual(2)
|
||||||
expect(modal.componentInstance.fieldsToAddIds).toEqual([1, 2])
|
expect(modal.componentInstance.fieldsToAddIds).toEqual([1, 2])
|
||||||
expect(modal.componentInstance.documents).toEqual([3, 4])
|
expect(modal.componentInstance.documents).toEqual([3, 4])
|
||||||
|
|
||||||
|
@ -671,9 +671,6 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '12',
|
value: '12',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.correspondentSelectionModel.logicalOperator).toEqual(
|
|
||||||
LogicalOperator.Or
|
|
||||||
)
|
|
||||||
expect(component.correspondentSelectionModel.intersection).toEqual(
|
expect(component.correspondentSelectionModel.intersection).toEqual(
|
||||||
Intersection.Include
|
Intersection.Include
|
||||||
)
|
)
|
||||||
@ -754,9 +751,6 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '22',
|
value: '22',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.documentTypeSelectionModel.logicalOperator).toEqual(
|
|
||||||
LogicalOperator.Or
|
|
||||||
)
|
|
||||||
expect(component.documentTypeSelectionModel.intersection).toEqual(
|
expect(component.documentTypeSelectionModel.intersection).toEqual(
|
||||||
Intersection.Include
|
Intersection.Include
|
||||||
)
|
)
|
||||||
@ -780,9 +774,6 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '23',
|
value: '23',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.documentTypeSelectionModel.logicalOperator).toEqual(
|
|
||||||
LogicalOperator.Or
|
|
||||||
)
|
|
||||||
expect(component.documentTypeSelectionModel.intersection).toEqual(
|
expect(component.documentTypeSelectionModel.intersection).toEqual(
|
||||||
Intersection.Include
|
Intersection.Include
|
||||||
)
|
)
|
||||||
@ -837,9 +828,6 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '32',
|
value: '32',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.storagePathSelectionModel.logicalOperator).toEqual(
|
|
||||||
LogicalOperator.Or
|
|
||||||
)
|
|
||||||
expect(component.storagePathSelectionModel.intersection).toEqual(
|
expect(component.storagePathSelectionModel.intersection).toEqual(
|
||||||
Intersection.Include
|
Intersection.Include
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user