diff --git a/frontend/src/__tests__/cypress/cypress/pages/connections.ts b/frontend/src/__tests__/cypress/cypress/pages/connections.ts index 2736ae6b29..a5b3739512 100644 --- a/frontend/src/__tests__/cypress/cypress/pages/connections.ts +++ b/frontend/src/__tests__/cypress/cypress/pages/connections.ts @@ -1,4 +1,5 @@ import { TableRow } from './components/table'; +import { Modal } from './components/Modal'; class ConnectionsPage { findTable() { @@ -31,5 +32,60 @@ class ConnectionsPage { return cy.contains('.pf-v6-c-menu__item-text', 'Delete'); } } +class ConnectionModal extends Modal { + constructor(edit = false) { + super(`${edit ? 'Edit' : 'Add'} connection`); + } + + findConnectionTypeDropdown() { + return this.find().findByTestId('connection-type-dropdown'); + } + + findS3CompatibleStorageOption() { + return cy.findByText('S3 compatible object storage - v1'); + } + + findSubmitButton() { + return this.findFooter().findByTestId('data-connection-submit-button'); + } + + findCreateButton() { + return this.find().findByTestId('modal-submit-button'); + } + + findConnectionNameInput() { + return this.find().findByTestId('connection-name-desc-name'); + } + + findConnectionDescriptionInput() { + return this.find().findByTestId('connection-name-desc-description'); + } + + findNameInput() { + return this.find().findByTestId('field Name'); + } + + findAwsKeyInput() { + return this.find().findByTestId('field AWS_ACCESS_KEY_ID'); + } + + findAwsSecretKeyInput() { + return this.find().findByTestId('field AWS_SECRET_ACCESS_KEY'); + } + + findEndpointInput() { + return this.find().findByTestId('field AWS_S3_ENDPOINT'); + } + + findRegionInput() { + return this.find().findByTestId('field AWS_DEFAULT_REGION'); + } + + findBucketInput() { + return this.find().findByTestId('field AWS_S3_BUCKET'); + } +} export const connectionsPage = new ConnectionsPage(); +export const addConnectionModal = new ConnectionModal(false); +export const editConnectionModal = new ConnectionModal(true); diff --git a/frontend/src/__tests__/cypress/cypress/pages/dataConnection.ts b/frontend/src/__tests__/cypress/cypress/pages/dataConnection.ts index f3e3f15f9e..1dcba70dee 100644 --- a/frontend/src/__tests__/cypress/cypress/pages/dataConnection.ts +++ b/frontend/src/__tests__/cypress/cypress/pages/dataConnection.ts @@ -2,38 +2,13 @@ import { Modal } from './components/Modal'; class DataConnectionModal extends Modal { constructor(edit = false) { - const titles = [ - edit ? 'Edit connection' : 'Add connection', - `${edit ? 'Edit' : 'Add'} data connection`, - ]; - - super(titles[0]); - } - - findConnectionTypeDropdown() { - return this.find().findByTestId('connection-type-dropdown'); - } - - findS3CompatibleStorageOption() { - return cy.findByText('S3 compatible object storage - v1'); + super(`${edit ? 'Edit' : 'Add'} data connection`); } findSubmitButton() { return this.findFooter().findByTestId('data-connection-submit-button'); } - findCreateButton() { - return this.find().findByTestId('modal-submit-button'); - } - - findConnectionNameInput() { - return this.find().findByTestId('connection-name-desc-name'); - } - - findConnectionDescriptionInput() { - return this.find().findByTestId('connection-name-desc-description'); - } - findNameInput() { return this.find().findByTestId('field Name'); } diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/connections/testDataConnectionCreation.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/connections/testDataConnectionCreation.cy.ts index 22d482607e..40eed411f7 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/connections/testDataConnectionCreation.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/connections/testDataConnectionCreation.cy.ts @@ -2,10 +2,9 @@ import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e import { projectListPage, projectDetails } from '~/__tests__/cypress/cypress/pages/projects'; import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project'; import type { DataScienceProjectData, AWSS3BucketDetails } from '~/__tests__/cypress/cypress/types'; -import { connectionsPage } from '~/__tests__/cypress/cypress/pages/connections'; +import { connectionsPage, addConnectionModal } from '~/__tests__/cypress/cypress/pages/connections'; import { loadDSPFixture } from '~/__tests__/cypress/cypress/utils/dataLoader'; import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker'; -import { addDataConnectionModal } from '~/__tests__/cypress/cypress/pages/dataConnection'; import { deleteModal } from '~/__tests__/cypress/cypress/pages/components/DeleteModal'; import { AWS_BUCKETS } from '~/__tests__/cypress/cypress/utils/s3Buckets'; @@ -75,16 +74,16 @@ describe('Verify Data Connections - Creation and Deletion', () => { // Enter validate Data Connection details into the Data Connection Modal cy.step('Enter valid Data Connection details and verify creation'); - addDataConnectionModal.findConnectionTypeDropdown().click(); - addDataConnectionModal.findS3CompatibleStorageOption().click(); - addDataConnectionModal.findConnectionNameInput().type(s3Config.NAME); - addDataConnectionModal.findConnectionDescriptionInput().type('S3 Bucket Connection'); - addDataConnectionModal.findAwsKeyInput().type(s3AccessKey); - addDataConnectionModal.findAwsSecretKeyInput().type(s3SecretKey); - addDataConnectionModal.findEndpointInput().type(s3Config.ENDPOINT); - addDataConnectionModal.findRegionInput().type(s3Config.REGION); - addDataConnectionModal.findBucketInput().type(s3Config.NAME); - addDataConnectionModal.findCreateButton().click(); + addConnectionModal.findConnectionTypeDropdown().click(); + addConnectionModal.findS3CompatibleStorageOption().click(); + addConnectionModal.findConnectionNameInput().type(s3Config.NAME); + addConnectionModal.findConnectionDescriptionInput().type('S3 Bucket Connection'); + addConnectionModal.findAwsKeyInput().type(s3AccessKey); + addConnectionModal.findAwsSecretKeyInput().type(s3SecretKey); + addConnectionModal.findEndpointInput().type(s3Config.ENDPOINT); + addConnectionModal.findRegionInput().type(s3Config.REGION); + addConnectionModal.findBucketInput().type(s3Config.NAME); + addConnectionModal.findCreateButton().click(); connectionsPage.getConnectionRow(s3Config.NAME).find().should('exist'); // Delete the Data Connection and confirm that the deletion was successful