-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: LEAP-1173: Disable the postpone option if the skip interface is…
…n't set (#6048) ### PR fulfills these requirements - [x] Commit message(s) and PR title follows the format `[fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made` ex. `fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors` - [x] Tests for the changes have been added/updated (for bug fixes/features) - [ ] Docs have been added/updated (for bug fixes/features) - [x] Best efforts were made to ensure docs/code are concise and coherent (checked for spelling/grammatical errors, commented out code, debug logs etc.) - [x] Self-reviewed and ran all changes on a local instance (for bug fixes/features) #### Change has impacts in these area(s) _(check all that apply)_ - [ ] Product design - [ ] Backend (Database) - [ ] Backend (API) - [x] Frontend **_Reason for the Change_** This change is necessary to enforce task flow integrity by preventing users from bypassing the task sequence. It ensures that tasks intended to be completed in order cannot be skipped, thus maintaining the workflow's intended progression. **_What Does This Fix?_** When skip interface is not set, postpone option will be disabled ### What level of testing was included in the change? _(check all that apply)_ - [ ] e2e - [ ] integration - [x] unit
- Loading branch information
1 parent
a5fc063
commit 470b83b
Showing
6 changed files
with
286 additions
and
3 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
136 changes: 136 additions & 0 deletions
136
web/libs/editor/src/components/BottomBar/__tests__/CurrentTask.test.tsx
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,136 @@ | ||
import { render } from "@testing-library/react"; | ||
import { CurrentTask } from "../CurrentTask"; | ||
import { BlockContext, cn } from "../../../utils/bem.ts"; | ||
import { FF_LEAP_1173 } from "../../../utils/feature-flags"; | ||
import { mockFF } from "../../../../__mocks__/global"; | ||
|
||
const ff = mockFF(); | ||
|
||
describe("CurrentTask", () => { | ||
let store: any; | ||
|
||
beforeAll(() => { | ||
ff.setup(); | ||
ff.set({ | ||
[FF_LEAP_1173]: true, | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
// Initialize your store with default values | ||
store = { | ||
annotationStore: { selected: { pk: null } }, | ||
canGoNextTask: false, | ||
canGoPrevTask: false, | ||
hasInterface: jest.fn(), | ||
taskHistory: [ | ||
{ | ||
taskId: 6627, | ||
annotationId: null, | ||
}, | ||
{ | ||
taskId: 6616, | ||
annotationId: null, | ||
}, | ||
], | ||
task: { id: 6616 }, | ||
commentStore: { | ||
loading: "list", | ||
comments: [], | ||
setAddedCommentThisSession: jest.fn(), | ||
}, | ||
queuePosition: 1, | ||
prevTask: jest.fn(), | ||
nextTask: jest.fn(), | ||
postponeTask: jest.fn(), | ||
queueTotal: 22, | ||
}; | ||
}); | ||
|
||
it("sets canPostpone correctly", () => { | ||
// check if next-task is enabled | ||
store.hasInterface.mockImplementation((interfaceName: string) => | ||
["skip", "postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
); | ||
|
||
const { rerender, getByTestId } = render( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(false); | ||
|
||
// check if next-task is disabled removing the postpone interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["skip", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
|
||
// check if next-task is disabled removing the skip interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
|
||
// check if next-task is disabled removing both skip and postpone interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
|
||
// check if next-task is disabled setting review interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["review", "skip", "postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
}); | ||
}); |
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
136 changes: 136 additions & 0 deletions
136
web/libs/editor/src/components/TopBar/__tests__/CurrentTask.test.tsx
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,136 @@ | ||
import { render } from "@testing-library/react"; | ||
import { CurrentTask } from "../CurrentTask"; | ||
import { BlockContext, cn } from "../../../utils/bem.ts"; | ||
import { FF_LEAP_1173 } from "../../../utils/feature-flags"; | ||
import { mockFF } from "../../../../__mocks__/global"; | ||
|
||
const ff = mockFF(); | ||
|
||
describe("CurrentTask", () => { | ||
let store: any; | ||
|
||
beforeAll(() => { | ||
ff.setup(); | ||
ff.set({ | ||
[FF_LEAP_1173]: true, | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
// Initialize your store with default values | ||
store = { | ||
annotationStore: { selected: { pk: null } }, | ||
canGoNextTask: false, | ||
canGoPrevTask: false, | ||
hasInterface: jest.fn(), | ||
taskHistory: [ | ||
{ | ||
taskId: 6627, | ||
annotationId: null, | ||
}, | ||
{ | ||
taskId: 6616, | ||
annotationId: null, | ||
}, | ||
], | ||
task: { id: 6616 }, | ||
commentStore: { | ||
loading: "list", | ||
comments: [], | ||
setAddedCommentThisSession: jest.fn(), | ||
}, | ||
queuePosition: 1, | ||
prevTask: jest.fn(), | ||
nextTask: jest.fn(), | ||
postponeTask: jest.fn(), | ||
queueTotal: 22, | ||
}; | ||
}); | ||
|
||
it("sets canPostpone correctly", () => { | ||
// check if next-task is enabled | ||
store.hasInterface.mockImplementation((interfaceName: string) => | ||
["skip", "postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
); | ||
|
||
const { rerender, getByTestId } = render( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(false); | ||
|
||
// check if next-task is disabled removing the postpone interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["skip", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
|
||
// check if next-task is disabled removing the skip interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
|
||
// check if next-task is disabled removing both skip and postpone interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
|
||
// check if next-task is disabled setting review interface | ||
store = { | ||
...store, | ||
hasInterface: jest | ||
.fn() | ||
.mockImplementation((interfaceName: string) => | ||
["review", "skip", "postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName), | ||
), | ||
}; | ||
|
||
rerender( | ||
<BlockContext.Provider value={cn("block-name")}> | ||
<CurrentTask store={store} /> | ||
</BlockContext.Provider>, | ||
); | ||
|
||
expect(getByTestId("next-task").disabled).toBe(true); | ||
}); | ||
}); |
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