forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jobs_v2: add UI to unstuck a strand or singleton
test plan: - queue some jobs in a new strand while explicitly setting next_in_strand to false, e.g. 5.times { delay(strand: 'sad', next_in_strand: false).sleep(1) } - also queue a singleton that way: delay(singleton: 'stuck', next_in_strand: false).sleep(1) - verify the strand and singleton are orphaned in the jobs_v2 user interface (strand / singleton tabs) by the presence of the exclamation mark icon with the tooltip - click that icon and a modal should appear asking you to confirm the operation - if you click "Unblock" it should unblock the strand or singleton and refresh the list flag=jobs_v2 closes DE-1314 Change-Id: Id9463e5c45046d705324cec946e089bd2eeaa5bb Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/300698 Tested-by: Service Cloud Jenkins <[email protected]> Reviewed-by: Aaron Ogata <[email protected]> QA-Review: Jeremy Stanley <[email protected]> Product-Review: Jeremy Stanley <[email protected]>
- Loading branch information
Showing
4 changed files
with
221 additions
and
11 deletions.
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
97 changes: 97 additions & 0 deletions
97
ui/features/jobs_v2/react/components/__tests__/OrphanedStrandIndicator.test.js
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,97 @@ | ||
/* | ||
* Copyright (C) 2022 - present Instructure, Inc. | ||
* | ||
* This file is part of Canvas. | ||
* | ||
* Canvas is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License as published by the Free | ||
* Software Foundation, version 3 of the License. | ||
* | ||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from 'react' | ||
import {render, fireEvent} from '@testing-library/react' | ||
import OrphanedStrandIndicator from '../OrphanedStrandIndicator' | ||
import doFetchApi from '@canvas/do-fetch-api-effect' | ||
|
||
jest.mock('@canvas/do-fetch-api-effect') | ||
|
||
const flushPromises = () => new Promise(setTimeout) | ||
|
||
function mockUnstuckApi({path, params}) { | ||
if (path === '/api/v1/jobs2/unstuck') { | ||
if (params.strand) { | ||
return Promise.resolve({json: {status: 'OK', count: 2}}) | ||
} else if (params.singleton) { | ||
return Promise.resolve({json: {status: 'OK', count: 1}}) | ||
} else { | ||
return Promise.resolve({ | ||
json: { | ||
status: 'pending', | ||
progress: { | ||
id: 101, | ||
url: 'http://example.com/api/v1/progress/101', | ||
workflow_state: 'queued' | ||
} | ||
} | ||
}) | ||
} | ||
} else { | ||
return Promise.reject() | ||
} | ||
} | ||
|
||
describe('OrphanedStrandIndicator', () => { | ||
let oldEnv | ||
beforeAll(() => { | ||
oldEnv = {...window.ENV} | ||
doFetchApi.mockImplementation(mockUnstuckApi) | ||
}) | ||
|
||
beforeEach(() => { | ||
doFetchApi.mockClear() | ||
}) | ||
|
||
afterAll(() => { | ||
window.ENV = oldEnv | ||
}) | ||
|
||
it("doesn't render button if the user lacks :manage_jobs", async () => { | ||
ENV.manage_jobs = false | ||
const {queryByText} = render( | ||
<OrphanedStrandIndicator name="strandy" type="strand" onComplete={jest.fn()} /> | ||
) | ||
expect(queryByText('Unblock strand "strandy"')).not.toBeInTheDocument() | ||
}) | ||
|
||
it('unstucks a strand', async () => { | ||
ENV.manage_jobs = true | ||
const onComplete = jest.fn() | ||
const {getByText} = render( | ||
<OrphanedStrandIndicator name="strandy" type="strand" onComplete={onComplete} /> | ||
) | ||
fireEvent.click(getByText('Unblock strand "strandy"')) | ||
fireEvent.click(getByText('Unblock')) | ||
await flushPromises() | ||
expect(onComplete).toHaveBeenCalledWith({status: 'OK', count: 2}) | ||
}) | ||
|
||
it('unstucks a singleton', async () => { | ||
ENV.manage_jobs = true | ||
const onComplete = jest.fn() | ||
const {getByText} = render( | ||
<OrphanedStrandIndicator name="tony" type="singleton" onComplete={onComplete} /> | ||
) | ||
fireEvent.click(getByText('Unblock singleton "tony"')) | ||
fireEvent.click(getByText('Unblock')) | ||
await flushPromises() | ||
expect(onComplete).toHaveBeenCalledWith({status: 'OK', count: 1}) | ||
}) | ||
}) |
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