@@ -102,6 +102,24 @@ describe("Test project contributor user functionality", () => {
102102 cy . contains ( '.card-title' , project_name ) . parents ( '.card-body' ) . siblings ( '.card-footer' ) . find ( 'a:contains("Open")' ) . first ( ) . click ( )
103103 cy . get ( '.card-text' ) . should ( 'contain' , project_description_2 )
104104
105+ cy . logf ( "Check that creating another project with same existing project name will create an error" , Cypress . currentTest )
106+ cy . visit ( "/projects/" )
107+ cy . get ( "a" ) . contains ( 'New project' ) . click ( )
108+ cy . get ( "a" ) . contains ( 'Create' ) . first ( ) . click ( )
109+ cy . get ( 'input[name=name]' ) . type ( project_name ) // same name used before
110+ cy . get ( 'textarea[name=description]' ) . type ( project_description )
111+ cy . get ( "input[name=save]" ) . contains ( 'Create project' ) . click ( ) // should generate an error
112+ // Check that the error message is displayed
113+ cy . get ( '#flash-msg' )
114+ . should ( 'be.visible' )
115+ . and ( 'have.class' , 'alert-danger' )
116+ . and ( 'contain.text' , `Project cannot be created because a project with name '${ project_name } ' already exists.` ) ;
117+ cy . logf ( "Error is successfully generated when trying to create a new project with the same existing project name" , Cypress . currentTest )
118+
119+ // go back to the previously created project
120+ cy . visit ( "/projects/" )
121+ cy . contains ( '.card-title' , project_name ) . parents ( '.card-body' ) . siblings ( '.card-footer' ) . find ( 'a.btn' ) . contains ( 'Open' ) . click ( )
122+
105123 cy . logf ( "Delete the project from the settings menu" , Cypress . currentTest )
106124 cy . get ( '[data-cy="settings"]' ) . click ( )
107125 cy . get ( 'a' ) . contains ( "Delete" ) . click ( )
@@ -117,85 +135,6 @@ describe("Test project contributor user functionality", () => {
117135 } )
118136 } )
119137
120- // This test cannot run properly in GitHub workflows because there is an issue with minio creation there. Therefore, it should be run locally to make sure things work. For GitHub, skipping it.
121-
122- // TODO: When models are launched, make sure that this test is activated
123- it . skip ( "can create a new project with ML serving template, open settings, delete from settings" , { defaultCommandTimeout : defaultCmdTimeoutMs } , ( ) => {
124-
125- // Names of objects to create
126- const project_name = "e2e-create-ml-proj-test"
127- const project_title_name = project_name + " | SciLifeLab Serve (beta)"
128-
129- cy . visit ( "/projects/" )
130- cy . get ( "title" ) . should ( "have.text" , "My projects | SciLifeLab Serve (beta)" )
131-
132- // Click button for UI to create a new project
133- cy . get ( "a" ) . contains ( 'New project' ) . click ( )
134- cy . url ( ) . should ( "include" , "projects/templates" )
135- cy . get ( 'h3' ) . should ( 'contain' , 'New project' )
136-
137- // Next click button to create a new blank project
138- cy . get ( ".card-footer" ) . last ( ) . contains ( "Create" ) . click ( )
139- cy . url ( ) . should ( "include" , "projects/create/?template=" )
140- cy . get ( 'h3' ) . should ( 'contain' , 'New project' )
141-
142- // Fill in the options for creating a new blank project
143- cy . get ( 'input[name=name]' ) . type ( project_name )
144- cy . get ( 'textarea[name=description]' ) . type ( "A test project created by an e2e test." )
145- cy . get ( "input[name=save]" ) . contains ( 'Create project' ) . click ( )
146- cy . wait ( 5000 ) // sometimes it takes a while to create a project
147- . then ( ( href ) => {
148- cy . logf ( href , Cypress . currentTest )
149- cy . reload ( )
150- cy . get ( "title" ) . should ( "have.text" , project_title_name )
151- cy . get ( 'h3' ) . should ( 'contain' , project_name )
152-
153- // Check that the correct deployment options are available
154- cy . get ( '.card-header' ) . find ( 'h5' ) . should ( 'contain' , 'Develop' )
155- cy . get ( '.card-header' ) . find ( 'h5' ) . should ( 'contain' , 'Serve' )
156- cy . get ( '.card-header' ) . find ( 'h5' ) . should ( 'contain' , 'Models' )
157- cy . get ( '.card-header' ) . find ( 'h5' ) . should ( 'not.contain' , 'Additional options [admins only]' )
158-
159- // Section Models - Machine Learning Models
160- // Navigate to the create models view and cancel back again
161- cy . get ( "div#models" ) . first ( "h5" ) . should ( "contain" , "Machine Learning Models" )
162- cy . get ( "div#models" ) . find ( "a.btn" ) . click ( )
163- . then ( ( href ) => {
164- cy . url ( ) . should ( "include" , "models/create" )
165- cy . get ( 'h3' ) . should ( "contain" , "Create Model Object" )
166- cy . get ( "button" ) . contains ( "Cancel" ) . click ( )
167- . then ( ( href ) => {
168- cy . get ( 'h3' ) . should ( "contain" , project_name )
169- } )
170- } )
171-
172- // Check that project settings are available
173- cy . get ( '[data-cy="settings"]' ) . click ( )
174- cy . url ( ) . should ( "include" , "settings" )
175- cy . get ( 'h3' ) . should ( 'contain' , 'Project settings' )
176-
177- // Check that the correct project settings are visible (i.e. no extra settings)
178- cy . get ( '.list-group' ) . find ( 'a' ) . should ( 'contain' , 'Access' )
179- cy . get ( '.list-group' ) . find ( 'a' ) . should ( 'not.contain' , 'S3 storage' )
180- cy . get ( '.list-group' ) . find ( 'a' ) . should ( 'not.contain' , 'MLFlow' )
181- cy . get ( '.list-group' ) . find ( 'a' ) . should ( 'not.contain' , 'Flavors' )
182- cy . get ( '.list-group' ) . find ( 'a' ) . should ( 'not.contain' , 'Environments' )
183-
184- // Delete the project from the settings menu
185- cy . get ( 'a' ) . contains ( "Delete" ) . click ( )
186- . then ( ( href ) => {
187- cy . get ( 'div#delete' ) . should ( 'have.css' , 'display' , 'block' )
188- cy . get ( '#id_delete_button' ) . parent ( ) . parent ( ) . find ( 'button' ) . contains ( 'Delete' ) . click ( )
189- . then ( ( href ) => {
190- cy . get ( 'div#deleteModal' ) . should ( 'have.css' , 'display' , 'block' )
191- cy . get ( 'div#deleteModal' ) . find ( 'button' ) . contains ( 'Confirm' ) . click ( )
192- } )
193- cy . contains ( project_name ) . should ( 'not.exist' )
194-
195- } )
196- } )
197- } )
198-
199138 it ( "can delete a project from projects overview" , { defaultCommandTimeout : defaultCmdTimeoutMs } , ( ) => {
200139
201140 // Names of objects to create
0 commit comments