Skip to content

Commit

Permalink
Made changes to page objects, changed the test to reference correct o…
Browse files Browse the repository at this point in the history
…bjects
  • Loading branch information
antowaddle committed Jan 28, 2025
1 parent 0e00c84 commit c7cedbc
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 38 deletions.
56 changes: 56 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/connections.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TableRow } from './components/table';
import { Modal } from './components/Modal';

class ConnectionsPage {
findTable() {
Expand Down Expand Up @@ -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);
27 changes: 1 addition & 26 deletions frontend/src/__tests__/cypress/cypress/pages/dataConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c7cedbc

Please sign in to comment.