Skip to content

Commit fcfd762

Browse files
authored
SS-1190 e2e tests for gradio and streamlit app deployment (#262)
Co-authored-by: akochari <[email protected]> Source: https://scilifelab.atlassian.net/browse/SS-1190 The task is to add appropriate tests for these app types where needed in e2e tests.
1 parent 148aa2e commit fcfd762

File tree

1 file changed

+131
-5
lines changed

1 file changed

+131
-5
lines changed

cypress/e2e/ui-tests/test-deploy-app.cy.js

Lines changed: 131 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ describe("Test deploying app", () => {
6565
it("can deploy a project and public app using the custom app chart", { defaultCommandTimeout: defaultCmdTimeoutMs }, () => {
6666
// Names of objects to create
6767
const project_name = "e2e-deploy-app-test"
68-
const app_name_project = "e2e-streamlit-example-project"
69-
const app_name_public = "e2e-streamlit-example-public"
70-
const app_name_public_2 = "e2e-streamlit-example-2-public"
71-
const app_description = "e2e-streamlit-description"
72-
const app_description_2 = "e2e-streamlit-2-description"
68+
const app_name_project = "e2e-custom-example-project"
69+
const app_name_public = "e2e-custom-example-public"
70+
const app_name_public_2 = "e2e-custom-example-2-public"
71+
const app_description = "e2e-custom-description"
72+
const app_description_2 = "e2e-custom-2-description"
7373
const image_name = "ghcr.io/scilifelabdatacentre/example-streamlit:latest"
7474
const image_name_2 = "ghcr.io/scilifelabdatacentre/example-streamlit:230921-1443"
7575
const image_port = "8501"
@@ -470,6 +470,132 @@ describe("Test deploying app", () => {
470470
}
471471
})
472472

473+
it("can deploy a gradio app", { defaultCommandTimeout: defaultCmdTimeoutMs }, () => {
474+
// Simple test to create and delete a Gradio app
475+
// Names of objects to create
476+
const project_name = "e2e-deploy-app-test"
477+
const app_name = "e2e-gradio-example"
478+
const app_description = "e2e-gradio-description"
479+
const source_code_url = "https://doi.org/example"
480+
const image_name = "ghcr.io/scilifelabdatacentre/gradio-flower-classification:20241118-174426"
481+
const image_port = "7860"
482+
const createResources = Cypress.env('create_resources');
483+
const app_type = "Gradio App"
484+
485+
if (createResources === true) {
486+
// Create Gradio app
487+
cy.logf("Creating a gradio app", Cypress.currentTest)
488+
cy.visit("/projects/")
489+
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
490+
cy.get('div.card-body:contains("' + app_type + '")').find('a:contains("Create")').click()
491+
cy.get('#id_name').type(app_name)
492+
cy.get('#id_description').type(app_description)
493+
cy.get('#id_access').select('Public')
494+
cy.get('#id_source_code_url').type(source_code_url)
495+
cy.get('#id_image').clear().type(image_name)
496+
cy.get('#id_port').clear().type(image_port)
497+
cy.get('#submit-id-submit').contains('Submit').click()
498+
// Back on project page
499+
cy.url().should("not.include", "/apps/settings")
500+
cy.get('h3').should('have.text', project_name);
501+
// check that the app was created
502+
verifyAppStatus(app_name, "Running", "public")
503+
504+
// Verify Gradio app values
505+
cy.logf("Checking that all dash app settings were saved", Cypress.currentTest)
506+
cy.visit("/projects/")
507+
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
508+
cy.get('tr:contains("' + app_name + '")').find('i.bi-three-dots-vertical').click()
509+
cy.get('tr:contains("' + app_name + '")').find('a').contains('Settings').click()
510+
cy.get('#id_name').should('have.value', app_name)
511+
cy.get('#id_description').should('have.value', app_description)
512+
cy.get('#id_access').find(':selected').should('contain', 'Public')
513+
cy.get('#id_image').should('have.value', image_name)
514+
cy.get('#id_port').should('have.value', image_port)
515+
516+
// Delete the Gradio app
517+
cy.logf("Deleting the gradio app", Cypress.currentTest)
518+
cy.visit("/projects/")
519+
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
520+
cy.get('tr:contains("' + app_name + '")').find('i.bi-three-dots-vertical').click()
521+
cy.get('tr:contains("' + app_name + '")').find('a.confirm-delete').click()
522+
cy.get('button').contains('Delete').click()
523+
verifyAppStatus(app_name, "Deleted", "")
524+
525+
// check that the app is not visible under public apps
526+
cy.visit('/apps/')
527+
cy.get("title").should("have.text", "Apps and models | SciLifeLab Serve (beta)")
528+
cy.get('h3').should('contain', 'Public applications and models')
529+
cy.contains('h5.card-title', app_name).should('not.exist')
530+
531+
} else {
532+
cy.logf('Skipped because create_resources is not true', Cypress.currentTest);
533+
}
534+
})
535+
536+
it("can deploy a streamlit app", { defaultCommandTimeout: defaultCmdTimeoutMs }, () => {
537+
// Simple test to create and delete a Streamlit app
538+
// Names of objects to create
539+
const project_name = "e2e-deploy-app-test"
540+
const app_name = "e2e-streamlit-example"
541+
const app_description = "e2e-streamlit-description"
542+
const source_code_url = "https://doi.org/example"
543+
const image_name = "ghcr.io/scilifelabdatacentre/streamlit-image-to-smiles:20241112-183549"
544+
const image_port = "8501"
545+
const createResources = Cypress.env('create_resources');
546+
const app_type = "Streamlit App"
547+
548+
if (createResources === true) {
549+
// Create Streamlit app
550+
cy.logf("Creating a streamlit app", Cypress.currentTest)
551+
cy.visit("/projects/")
552+
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
553+
cy.get('div.card-body:contains("' + app_type + '")').find('a:contains("Create")').click()
554+
cy.get('#id_name').type(app_name)
555+
cy.get('#id_description').type(app_description)
556+
cy.get('#id_access').select('Public')
557+
cy.get('#id_source_code_url').type(source_code_url)
558+
cy.get('#id_image').clear().type(image_name)
559+
cy.get('#id_port').clear().type(image_port)
560+
cy.get('#submit-id-submit').contains('Submit').click()
561+
// Back on project page
562+
cy.url().should("not.include", "/apps/settings")
563+
cy.get('h3').should('have.text', project_name);
564+
// check that the app was created
565+
verifyAppStatus(app_name, "Running", "public")
566+
567+
// Verify Streamlit app values
568+
cy.logf("Checking that all dash app settings were saved", Cypress.currentTest)
569+
cy.visit("/projects/")
570+
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
571+
cy.get('tr:contains("' + app_name + '")').find('i.bi-three-dots-vertical').click()
572+
cy.get('tr:contains("' + app_name + '")').find('a').contains('Settings').click()
573+
cy.get('#id_name').should('have.value', app_name)
574+
cy.get('#id_description').should('have.value', app_description)
575+
cy.get('#id_access').find(':selected').should('contain', 'Public')
576+
cy.get('#id_image').should('have.value', image_name)
577+
cy.get('#id_port').should('have.value', image_port)
578+
579+
// Delete the Streamlit app
580+
cy.logf("Deleting the dash app", Cypress.currentTest)
581+
cy.visit("/projects/")
582+
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
583+
cy.get('tr:contains("' + app_name + '")').find('i.bi-three-dots-vertical').click()
584+
cy.get('tr:contains("' + app_name + '")').find('a.confirm-delete').click()
585+
cy.get('button').contains('Delete').click()
586+
verifyAppStatus(app_name, "Deleted", "")
587+
588+
// check that the app is not visible under public apps
589+
cy.visit('/apps/')
590+
cy.get("title").should("have.text", "Apps and models | SciLifeLab Serve (beta)")
591+
cy.get('h3').should('contain', 'Public applications and models')
592+
cy.contains('h5.card-title', app_name).should('not.exist')
593+
594+
} else {
595+
cy.logf('Skipped because create_resources is not true', Cypress.currentTest);
596+
}
597+
})
598+
473599
it("can modify app settings resulting in NO k8s redeployment shows correct app status", { defaultCommandTimeout: defaultCmdTimeoutMs }, () => {
474600
// An advanced test to verify user can modify app settings such as the name and description
475601
// Names of objects to create

0 commit comments

Comments
 (0)