-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review workflow UI improvements. (#319)
- Loading branch information
Showing
7 changed files
with
186 additions
and
26 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
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,113 @@ | ||
import { expect } from "chai"; | ||
import { put } from "redux-saga/effects"; | ||
|
||
import { notifySuccess } from "../../../src/actions/notifications"; | ||
import { routeLoadSuccess } from "../../../src/actions/route"; | ||
import { setClient } from "../../../src/client"; | ||
import * as actions from "../../../src/plugins/signoff/actions"; | ||
import * as saga from "../../../src/plugins/signoff/sagas"; | ||
|
||
|
||
describe("signoff plugin sagas", () => { | ||
let bucket, collection, getState; | ||
|
||
before(() => { | ||
collection = { | ||
getData() {}, | ||
setData() {}, | ||
}; | ||
bucket = {collection() {return collection;}}; | ||
setClient({bucket() {return bucket;}}); | ||
getState = () => ({ | ||
bucket: {data: {id: "buck"}}, | ||
collection: {data: {id: "coll", last_modified: 42}} | ||
}); | ||
}); | ||
|
||
describe("handleRequestReview()", () => { | ||
let handleRequestReview; | ||
|
||
before(() => { | ||
const action = actions.requestReview(); | ||
handleRequestReview = saga.handleRequestReview(getState, action); | ||
}); | ||
|
||
it("should update the collection status as 'to-review'", () => { | ||
expect(handleRequestReview.next({id: "coll"}).value) | ||
.to.have.property("CALL") | ||
.to.have.property("args") | ||
.to.include({status: "to-review"}); | ||
}); | ||
|
||
it("should dispatch the routeLoadSuccess action", () => { | ||
expect(handleRequestReview.next({data: {id: "coll", status: "to-review"}}).value) | ||
.eql(put(routeLoadSuccess({ | ||
bucket: {data: {id: "buck"}}, | ||
collection: {data: {id: "coll", status: "to-review"}}, | ||
}))); | ||
}); | ||
|
||
it("should dispatch a success notification", () => { | ||
expect(handleRequestReview.next().value) | ||
.eql(put(notifySuccess("Review requested."))); | ||
}); | ||
}); | ||
|
||
describe("handleDeclineChanges()", () => { | ||
let handleDeclineChanges; | ||
|
||
before(() => { | ||
const action = actions.declineChanges(); | ||
handleDeclineChanges = saga.handleDeclineChanges(getState, action); | ||
}); | ||
|
||
it("should update the collection status as 'work-in-progress'", () => { | ||
expect(handleDeclineChanges.next({id: "coll"}).value) | ||
.to.have.property("CALL") | ||
.to.have.property("args") | ||
.to.include({status: "work-in-progress"}); | ||
}); | ||
|
||
it("should dispatch the routeLoadSuccess action", () => { | ||
expect(handleDeclineChanges.next({data: {id: "coll", status: "work-in-progress"}}).value) | ||
.eql(put(routeLoadSuccess({ | ||
bucket: {data: {id: "buck"}}, | ||
collection: {data: {id: "coll", status: "work-in-progress"}}, | ||
}))); | ||
}); | ||
|
||
it("should dispatch a success notification", () => { | ||
expect(handleDeclineChanges.next().value) | ||
.eql(put(notifySuccess("Changes declined."))); | ||
}); | ||
}); | ||
|
||
describe("handleApproveChanges()", () => { | ||
let handleApproveChanges; | ||
|
||
before(() => { | ||
const action = actions.approveChanges(); | ||
handleApproveChanges = saga.handleApproveChanges(getState, action); | ||
}); | ||
|
||
it("should update the collection status as 'to-sign'", () => { | ||
expect(handleApproveChanges.next({id: "coll"}).value) | ||
.to.have.property("CALL") | ||
.to.have.property("args") | ||
.to.include({status: "to-sign"}); | ||
}); | ||
|
||
it("should dispatch the routeLoadSuccess action", () => { | ||
expect(handleApproveChanges.next({data: {id: "coll", status: "to-sign"}}).value) | ||
.eql(put(routeLoadSuccess({ | ||
bucket: {data: {id: "buck"}}, | ||
collection: {data: {id: "coll", status: "to-sign"}}, | ||
}))); | ||
}); | ||
|
||
it("should dispatch a success notification", () => { | ||
expect(handleApproveChanges.next().value) | ||
.eql(put(notifySuccess("Signature requested."))); | ||
}); | ||
}); | ||
}); |
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