Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SS-1211 add e2e test to check that user cannot create a new project with the same name #261

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e29c6ef
SS-1203 e2e test for custom url subpath
anondo1969 Nov 22, 2024
3cb58aa
SS-1203 e2e test for custom url subpath
anondo1969 Nov 26, 2024
f4dd7bb
Merge branch 'develop' of https://github.com/ScilifelabDataCentre/ser…
anondo1969 Nov 26, 2024
6397dbd
Merge branch 'develop' into SS-1203-Add-e2e-test-for-making-sure-that…
anondo1969 Nov 26, 2024
9e95031
Merge branch 'develop' of https://github.com/ScilifelabDataCentre/ser…
anondo1969 Nov 27, 2024
c986c9f
SS-1203 restructured e2e test segment
anondo1969 Nov 27, 2024
3a475a3
SS-1203 fixed pre-commit issues
anondo1969 Nov 27, 2024
5af52f5
Merge branch 'SS-1203-Add-e2e-test-for-making-sure-that-users-can-set…
anondo1969 Nov 27, 2024
db91b80
SS-1211 e2e test for detecting project name duplication
anondo1969 Nov 27, 2024
33c6da3
Merge branch 'develop' of https://github.com/ScilifelabDataCentre/ser…
anondo1969 Nov 27, 2024
bbc58c5
SS-1211 remove commented code
anondo1969 Nov 27, 2024
ed9440a
SS-1211 remove accidental skips
anondo1969 Nov 27, 2024
69cdb59
SS-1211 remove accidental skips
anondo1969 Nov 27, 2024
706037c
SS-1211 remove accidental skips from superuser test
anondo1969 Nov 27, 2024
2bb67ee
SS-1211 e2e test for project name duplication in superuser mode
anondo1969 Nov 28, 2024
d711c4e
remove legacy uncommented test, not needed anymore
akochari Nov 28, 2024
3c7ec11
simplify test for dplicate project name
akochari Nov 28, 2024
c675e01
simplify test for dplicate project name
akochari Nov 28, 2024
2435abb
Merge branch 'develop' into SS-1211-Add-e2e-test-to-check-that-user-c…
anondo1969 Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 18 additions & 79 deletions cypress/e2e/ui-tests/test-project-as-contributor.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ describe("Test project contributor user functionality", () => {
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
cy.get('.card-text').should('contain', project_description_2)

cy.logf("Check that creating another project with same existing project name will create an error", Cypress.currentTest)
cy.visit("/projects/")
cy.get("a").contains('New project').click()
cy.get("a").contains('Create').first().click()
cy.get('input[name=name]').type(project_name) // same name used before
cy.get('textarea[name=description]').type(project_description)
cy.get("input[name=save]").contains('Create project').click() // should generate an error
// Check that the error message is displayed
cy.get('#flash-msg')
.should('be.visible')
.and('have.class', 'alert-danger')
.and('contain.text', `Project cannot be created because a project with name '${project_name}' already exists.`);
cy.logf("Error is successfully generated when trying to create a new project with the same existing project name", Cypress.currentTest)

// go back to the previously created project
cy.visit("/projects/")
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a.btn').contains('Open').click()

cy.logf("Delete the project from the settings menu", Cypress.currentTest)
cy.get('[data-cy="settings"]').click()
cy.get('a').contains("Delete").click()
Expand All @@ -117,85 +135,6 @@ describe("Test project contributor user functionality", () => {
})
})

// 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.

// TODO: When models are launched, make sure that this test is activated
it.skip("can create a new project with ML serving template, open settings, delete from settings", { defaultCommandTimeout: defaultCmdTimeoutMs }, () => {

// Names of objects to create
const project_name = "e2e-create-ml-proj-test"
const project_title_name = project_name + " | SciLifeLab Serve (beta)"

cy.visit("/projects/")
cy.get("title").should("have.text", "My projects | SciLifeLab Serve (beta)")

// Click button for UI to create a new project
cy.get("a").contains('New project').click()
cy.url().should("include", "projects/templates")
cy.get('h3').should('contain', 'New project')

// Next click button to create a new blank project
cy.get(".card-footer").last().contains("Create").click()
cy.url().should("include", "projects/create/?template=")
cy.get('h3').should('contain', 'New project')

// Fill in the options for creating a new blank project
cy.get('input[name=name]').type(project_name)
cy.get('textarea[name=description]').type("A test project created by an e2e test.")
cy.get("input[name=save]").contains('Create project').click()
cy.wait(5000) // sometimes it takes a while to create a project
.then((href) => {
cy.logf(href, Cypress.currentTest)
cy.reload()
cy.get("title").should("have.text", project_title_name)
cy.get('h3').should('contain', project_name)

// Check that the correct deployment options are available
cy.get('.card-header').find('h5').should('contain', 'Develop')
cy.get('.card-header').find('h5').should('contain', 'Serve')
cy.get('.card-header').find('h5').should('contain', 'Models')
cy.get('.card-header').find('h5').should('not.contain', 'Additional options [admins only]')

// Section Models - Machine Learning Models
// Navigate to the create models view and cancel back again
cy.get("div#models").first("h5").should("contain", "Machine Learning Models")
cy.get("div#models").find("a.btn").click()
.then((href) => {
cy.url().should("include", "models/create")
cy.get('h3').should("contain", "Create Model Object")
cy.get("button").contains("Cancel").click()
.then((href) => {
cy.get('h3').should("contain", project_name)
})
})

// Check that project settings are available
cy.get('[data-cy="settings"]').click()
cy.url().should("include", "settings")
cy.get('h3').should('contain', 'Project settings')

// Check that the correct project settings are visible (i.e. no extra settings)
cy.get('.list-group').find('a').should('contain', 'Access')
cy.get('.list-group').find('a').should('not.contain', 'S3 storage')
cy.get('.list-group').find('a').should('not.contain', 'MLFlow')
cy.get('.list-group').find('a').should('not.contain', 'Flavors')
cy.get('.list-group').find('a').should('not.contain', 'Environments')

// Delete the project from the settings menu
cy.get('a').contains("Delete").click()
.then((href) => {
cy.get('div#delete').should('have.css', 'display', 'block')
cy.get('#id_delete_button').parent().parent().find('button').contains('Delete').click()
.then((href) => {
cy.get('div#deleteModal').should('have.css', 'display', 'block')
cy.get('div#deleteModal').find('button').contains('Confirm').click()
})
cy.contains(project_name).should('not.exist')

})
})
})

it("can delete a project from projects overview", { defaultCommandTimeout: defaultCmdTimeoutMs }, () => {

// Names of objects to create
Expand Down
29 changes: 27 additions & 2 deletions cypress/e2e/ui-tests/test-superuser-functionality.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe("Test superuser access", () => {
// Names of objects to create
const project_name = "e2e-create-default-proj-test"
const project_description = "A test project created by an e2e test."
const project_description_duplicate = "A test project with an existing project name"
const project_description_2 = "An alternative project description created by an e2e test."

cy.visit("/projects/")
Expand All @@ -65,12 +66,10 @@ describe("Test superuser access", () => {
cy.get('input[name=name]').type(project_name)
cy.get('textarea[name=description]').type(project_description)
cy.get("input[name=save]").contains('Create project').click()
//cy.wait(5000) // sometimes it takes a while to create a project. Not needed because of cypress retryability.

cy.get('h3', {timeout: longCmdTimeoutMs}).should('contain', project_name)
cy.get('.card-text').should('contain', project_description)


cy.logf("Checking that project settings are available", Cypress.currentTest)
cy.get('[data-cy="settings"]').click()
cy.url().should("include", "settings")
Expand All @@ -88,6 +87,32 @@ describe("Test superuser access", () => {
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a:contains("Open")').first().click()
cy.get('.card-text').should('contain', project_description_2)

cy.logf("Check that creating another project with same existing project name will work for a superuser", Cypress.currentTest)
cy.visit("/projects/")
cy.get("a").contains('New project').click()
cy.get("a").contains('Create').first().click()
cy.get('input[name=name]').type(project_name) // this name already exists
cy.get('textarea[name=description]').type(project_description_duplicate) // this will be used to ensure to delete it
cy.get("input[name=save]").contains('Create project').click()
cy.get('h3', {timeout: longCmdTimeoutMs}).should('contain', project_name)
cy.get('.card-text').should('contain', project_description_duplicate) // checking that project creation succeeded
// deleting the project with the duplicate name
cy.get('[data-cy="settings"]').click()
cy.get('a').contains("Delete").click()
.then((href) => {
cy.get('div#delete').should('have.css', 'display', 'block')
cy.get('#id_delete_button').parent().parent().find('button').contains('Delete').click()
.then((href) => {
cy.get('div#deleteModal').should('have.css', 'display', 'block')
cy.get('div#deleteModal').find('button').contains('Confirm').click()
})
// checking that the project with the duplicate name has been deleted
cy.visit("/projects/")
cy.contains(project_description_duplicate).should('not.exist')
})
// going to the previously created project's page
cy.contains('.card-title', project_name).parents('.card-body').siblings('.card-footer').find('a.btn').contains('Open').click()

cy.logf("Deleting the project from the settings menu", Cypress.currentTest)
cy.get('[data-cy="settings"]').click()
cy.get('a').contains("Delete").click()
Expand Down