File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
test/e2e/integration/frontend-test Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ export const CustomButtonComponent = ({ baseComponentId }: PropsFromGenericCompo
202
202
const acquireLock = FD . useLocking ( id ) ;
203
203
const isAuthorized = useIsAuthorized ( ) ;
204
204
const { handleClientActions } = useHandleClientActions ( ) ;
205
- const { mutate : handleServerAction , error } = useMutation ( {
205
+ const { mutateAsync : handleServerAction , error } = useMutation ( {
206
206
mutationFn : useHandleServerActionMutationFn ( acquireLock ) ,
207
207
} ) ;
208
208
@@ -263,7 +263,11 @@ export const CustomButtonComponent = ({ baseComponentId }: PropsFromGenericCompo
263
263
if ( isClientAction ( action ) ) {
264
264
await handleClientActions ( [ action ] ) ;
265
265
} else if ( isServerAction ( action ) ) {
266
- handleServerAction ( { action, buttonId : id } ) ;
266
+ try {
267
+ await handleServerAction ( { action, buttonId : id } ) ;
268
+ } catch {
269
+ // Error is handled elsewhere
270
+ }
267
271
}
268
272
}
269
273
} ) ;
Original file line number Diff line number Diff line change @@ -4,9 +4,18 @@ const appFrontend = new AppFrontend();
4
4
5
5
describe ( 'Custom Button' , ( ) => {
6
6
it ( 'Should perform action and update the frontend with the updated datamodel' , ( ) => {
7
+ cy . intercept ( { url : '**/instances/**/actions*' } , ( req ) => {
8
+ req . reply ( ( res ) => {
9
+ res . setDelay ( 500 ) ;
10
+ } ) ;
11
+ } ) . as ( 'actionWithDelay' ) ;
12
+
7
13
cy . goto ( 'changename' ) ;
8
14
9
15
cy . findByRole ( 'button' , { name : 'Fyll ut skjema' } ) . click ( ) ;
16
+ cy . findByRole ( 'button' , { name : 'Fyll ut skjema' } ) . should ( 'be.disabled' ) ; // Disabled while loading
17
+ cy . wait ( '@actionWithDelay' ) ;
18
+ cy . findByRole ( 'button' , { name : 'Fyll ut skjema' } ) . should ( 'not.be.disabled' ) ; // Enabled when finished
10
19
cy . findByRole ( 'textbox' , { name : 'Denne oppdateres av custom button' } ) . should (
11
20
'have.value' ,
12
21
'Her kommer det data fra backend' ,
You can’t perform that action at this time.
0 commit comments