Skip to content

Commit

Permalink
…URLs-for-their-apps (#257)

Source: https://scilifelab.atlassian.net/browse/SS-1203

Creating E2E tests to ensure,

a) when users create apps and set custom URLs, this URL is respected

b) changing this URL works

c) adding a custom URL to an already running app works

d) giving invalid input in this field results in an error
  • Loading branch information
anondo1969 authored Nov 27, 2024
1 parent 36eb700 commit 148aa2e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cypress/e2e/ui-tests/test-deploy-app.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ describe("Test deploying app", () => {
const createResources = Cypress.env('create_resources');
const app_type = "Custom App"
const app_source_code_public = "https://doi.org/example"
const default_url_subpath = "default/url/subpath/"
const changed_default_url_subpath = "changed/subpath/"
const invalid_default_url_subpath = "€% / ()"

let volume_display_text = "project-vol (" + project_name + ")"

Expand All @@ -97,9 +100,15 @@ describe("Test deploying app", () => {
cy.get('#id_port').clear().type(image_port)
cy.get('#id_image').clear().type(image_name)
cy.get('#id_path').clear().type(app_path)
cy.get('button.accordion-button.collapsed[data-bs-target="#advanced-settings"]').click(); // Go to Advanced settings
cy.get('#id_default_url_subpath').clear().type(default_url_subpath) // provide default_url_subpath
cy.get('#submit-id-submit').contains('Submit').click()
// check that the app was created
verifyAppStatus(app_name_project, "Running", "project")
// check that the default URL subpath was created
cy.contains('a', app_name_project)
.should('have.attr', 'href')
.and('include', default_url_subpath);
// check that the app is not visible under public apps
cy.visit('/apps/')
cy.get('h3').should('contain', 'Public applications and models')
Expand Down Expand Up @@ -138,6 +147,8 @@ describe("Test deploying app", () => {
cy.get('#id_image').clear().type(image_name)
cy.get('#id_path').clear().type(app_path)
cy.get('#id_volume').select(volume_display_text)
cy.get('button.accordion-button.collapsed[data-bs-target="#advanced-settings"]').click(); // Go to Advanced settings
cy.get('#id_default_url_subpath').clear().type(default_url_subpath) // provide default_url_subpath
cy.get('#submit-id-submit').contains('Submit').click()

verifyAppStatus(app_name_public, "Running", "public")
Expand All @@ -147,6 +158,11 @@ describe("Test deploying app", () => {
verifyAppStatus(app_name_public, "Running", "public")
})

// check that the default URL subpath was created
cy.contains('a', app_name_public)
.should('have.attr', 'href')
.and('include', default_url_subpath);

cy.visit("/apps")
cy.get('h5.card-title').should('contain', app_name_public)
cy.get('.card-text').find('p').should('contain', app_description)
Expand Down Expand Up @@ -199,6 +215,9 @@ describe("Test deploying app", () => {
cy.get('#id_image').clear().type(image_name_2)
cy.get('#id_path').should('have.value', app_path)
cy.get('#id_path').clear().type(app_path_2)
cy.get('button.accordion-button.collapsed[data-bs-target="#advanced-settings"]').click(); // Go to Advanced settings
cy.get('#id_default_url_subpath').should('have.value', default_url_subpath) // default_url_subpath should be same as before
cy.get('#id_default_url_subpath').clear().type(changed_default_url_subpath) // provide changed_default_url_subpath
cy.get('#submit-id-submit').contains('Submit').click()

// NB: it will get status "Running" but it won't work because the new port is incorrect
Expand All @@ -209,6 +228,11 @@ describe("Test deploying app", () => {
verifyAppStatus(app_name_public_2, "Running", "link")
})

// check that the default URL subpath was changed
cy.contains('a', app_name_public_2)
.should('have.attr', 'href')
.and('include', changed_default_url_subpath);

// Check that the changes were saved
cy.visit("/projects/")
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
Expand All @@ -221,6 +245,17 @@ describe("Test deploying app", () => {
cy.get('#id_port').should('have.value', image_port_2)
cy.get('#id_image').should('have.value', image_name_2)
cy.get('#id_path').should('have.value', app_path_2)
cy.get('button.accordion-button.collapsed[data-bs-target="#advanced-settings"]').click(); // Go to Advanced settings
cy.get('#id_default_url_subpath').should('have.value', changed_default_url_subpath) // changed_url_subpath should be same as before

// Make sure that giving invalid input in default_url_subpath field results in an error
cy.get('#id_default_url_subpath').clear().type(invalid_default_url_subpath) // provide invalid_default_url_subpath
cy.get('#submit-id-submit').contains('Submit').click() // this should trigger the error

// check this invalid_default_url_subpath error was matched
cy.get('.client-validation-feedback.client-validation-invalid')
.should('exist')
.and('include.text', 'Your custom URL subpath is not valid, please correct it');

// Remove the created public app and verify that it is deleted from public apps page
cy.logf("Now deleting the public app", Cypress.currentTest)
Expand Down

0 comments on commit 148aa2e

Please sign in to comment.