@@ -41,6 +41,49 @@ describe('The node slice reducers', () => {
4141 expect ( nodeSlice . reducer ( undefined , action ) ) . toEqual ( nodeNext0 ) ;
4242 } ) ;
4343
44+ it ( 'should clear error when we successfully process a node with a next' , ( ) => {
45+ const actionError = {
46+ type : 'node/error' ,
47+ payload : {
48+ data : error0a ,
49+ requestId : '1234' ,
50+ httpStatus : 400 ,
51+ } ,
52+ } ;
53+ const errorState = {
54+ cache : {
55+ key : '1234' ,
56+ } ,
57+ client : {
58+ status : 'error' as const ,
59+ } ,
60+ error : {
61+ code : ' Invalid username and/or password' ,
62+ collectors : [ ] ,
63+ message : ' Invalid username and/or password' ,
64+ internalHttpStatus : 400 ,
65+ status : 'error' ,
66+ type : 'davinci_error' ,
67+ } ,
68+ httpStatus : 400 ,
69+ server : {
70+ status : 'error' ,
71+ } ,
72+ status : 'error' ,
73+ } ;
74+ const errorStateReducer = nodeSlice . reducer ( undefined , actionError ) ;
75+ expect ( errorStateReducer ) . toEqual ( errorState ) ;
76+
77+ const action = {
78+ type : 'node/next' ,
79+ payload : {
80+ data : next0 ,
81+ requestId : '1234' ,
82+ httpStatus : 200 ,
83+ } ,
84+ } ;
85+ expect ( nodeSlice . reducer ( errorStateReducer , action ) ) . toEqual ( nodeNext0 ) ;
86+ } ) ;
4487 it ( 'should handle success node after DaVinci flow' , ( ) => {
4588 const action = {
4689 type : 'node/success' ,
@@ -67,6 +110,50 @@ describe('The node slice reducers', () => {
67110 expect ( nodeSlice . reducer ( undefined , action ) ) . toEqual ( nodeSuccess1 ) ;
68111 } ) ;
69112
113+ it ( 'should clear error when we successfully process a node' , ( ) => {
114+ const action = {
115+ type : 'node/error' ,
116+ payload : {
117+ data : error0a ,
118+ requestId : '1234' ,
119+ httpStatus : 400 ,
120+ } ,
121+ } ;
122+ const errorState = {
123+ cache : {
124+ key : '1234' ,
125+ } ,
126+ client : {
127+ status : 'error' as const ,
128+ } ,
129+ error : {
130+ code : ' Invalid username and/or password' ,
131+ collectors : [ ] ,
132+ message : ' Invalid username and/or password' ,
133+ internalHttpStatus : 400 ,
134+ status : 'error' ,
135+ type : 'davinci_error' ,
136+ } ,
137+ httpStatus : 400 ,
138+ server : {
139+ status : 'error' ,
140+ } ,
141+ status : 'error' ,
142+ } ;
143+ const errorStateReducer = nodeSlice . reducer ( undefined , action ) ;
144+ expect ( errorStateReducer ) . toEqual ( errorState ) ;
145+
146+ const actionSuccess = {
147+ type : 'node/success' ,
148+ payload : {
149+ data : success1 ,
150+ requestId : '1234' ,
151+ httpStatus : 200 ,
152+ } ,
153+ } ;
154+ expect ( nodeSlice . reducer ( errorStateReducer , actionSuccess ) ) . toEqual ( nodeSuccess1 ) ;
155+ } ) ;
156+
70157 it ( 'should handle error node' , ( ) => {
71158 const action = {
72159 type : 'node/error' ,
0 commit comments