@@ -322,4 +322,40 @@ describe('visualisation', () => {
322322 // Switch back to the default user
323323 cy . request ( '/x/test/switchdefault' )
324324 } )
325+
326+ // Ensure the save and delete buttons are only shown to the database owner
327+ it ( 'Ensure save/delete buttons are only shown to database owner' , ( ) => {
328+ // Switch to a different user
329+ cy . request ( '/x/test/switchfirst' )
330+
331+ // Load a public page
332+ cy . visit ( '/vis/default/Assembly Election 2017 with view.sqlite' )
333+
334+ // Test if the Save and Delete fields are visible. They shouldn't be
335+ cy . get ( '[data-cy="savebtn"' ) . should ( 'not.exist' )
336+ cy . get ( '[data-cy="nameinput"' ) . should ( 'not.exist' )
337+ cy . get ( '[data-cy="delvisbtn"' ) . should ( 'not.exist' )
338+
339+ // Log out
340+ cy . request ( '/x/test/logout' )
341+
342+ // Reload the page
343+ cy . visit ( '/vis/default/Assembly Election 2017 with view.sqlite' )
344+
345+ // Test if the Save and Delete fields are visible. They shouldn't be
346+ cy . get ( '[data-cy="savebtn"' ) . should ( 'not.exist' )
347+ cy . get ( '[data-cy="nameinput"' ) . should ( 'not.exist' )
348+ cy . get ( '[data-cy="delvisbtn"' ) . should ( 'not.exist' )
349+
350+ // Switch back to the default user
351+ cy . request ( '/x/test/switchdefault' )
352+
353+ // Reload the page again
354+ cy . visit ( '/vis/default/Assembly Election 2017 with view.sqlite' )
355+
356+ // Ensure the Save and Delete fields are visible. They should be this time
357+ cy . get ( '[data-cy="savebtn"' ) . should ( 'exist' )
358+ cy . get ( '[data-cy="nameinput"' ) . should ( 'exist' )
359+ cy . get ( '[data-cy="delvisbtn"' ) . should ( 'exist' )
360+ } )
325361} )
0 commit comments