Enhancement: workflow overview toggle enable button (#7818)

This commit is contained in:
shamoon
2024-09-30 19:44:02 -07:00
committed by GitHub
parent 991c9b0ca4
commit 0b829cab32
4 changed files with 82 additions and 14 deletions

View File

@@ -211,4 +211,27 @@ describe('WorkflowsComponent', () => {
editDialog.confirmClicked.emit()
expect(reloadSpy).toHaveBeenCalled()
})
it('should update workflow when enable is toggled', () => {
const patchSpy = jest.spyOn(workflowService, 'patch')
const toggleInput = fixture.debugElement.query(
By.css('input[type="checkbox"]')
)
const toastErrorSpy = jest.spyOn(toastService, 'showError')
const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
// fail first
patchSpy.mockReturnValueOnce(
throwError(() => new Error('Error getting config'))
)
toggleInput.nativeElement.click()
expect(patchSpy).toHaveBeenCalled()
expect(toastErrorSpy).toHaveBeenCalled()
// succeed second
patchSpy.mockReturnValueOnce(of(workflows[0]))
toggleInput.nativeElement.click()
patchSpy.mockReturnValueOnce(of({ ...workflows[0], enabled: false }))
toggleInput.nativeElement.click()
expect(patchSpy).toHaveBeenCalled()
expect(toastInfoSpy).toHaveBeenCalled()
})
})