Skip to content

Commit

Permalink
[Multiple Datasource] Update tests for 2.7 (opensearch-project#610) (o…
Browse files Browse the repository at this point in the history
…pensearch-project#614)

* [Multiple Datasource] Update tests for 2.7 (opensearch-project#610)

Signed-off-by: Su <szhongna@amazon.com>
(cherry picked from commit 9f890f7)
Signed-off-by: Yibo Wang <yibow@amazon.com>

* lint check fix

Signed-off-by: Yibo Wang <yibow@amazon.com>

---------

Signed-off-by: Su <szhongna@amazon.com>
Signed-off-by: Yibo Wang <yibow@amazon.com>
Co-authored-by: Zhongnan Su <szhongna@amazon.com>
Signed-off-by: leanne.laceybyrne@eliatra.com <leanne.laceybyrne@eliatra.com>
  • Loading branch information
2 people authored and leanneeliatra committed Sep 15, 2023
1 parent 76b1522 commit 91d50c3
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const miscUtils = new MiscUtils(cy);
// Get environment variables
const username = Cypress.env('username');
const password = Cypress.env('password');
const REGION = 'us-east-1';
const ACCESS_KEY = 'accessKey';
const SECRET_KEY = 'secretKey';

if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
describe('Create datasources', () => {
Expand All @@ -35,16 +38,14 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
);
});

it('should successfully show the experimental feature callout', () => {
cy.getElementByTestId('data-source-experimental-call').should('exist');
});

describe('Datasource can be created successfully', () => {
it('with no auth and all required inputs', () => {
cy.get('[name="dataSourceTitle"]').type('test_noauth');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[for="no_auth"]').click();
cy.get('[type="submit"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.getElementByTestId('createDataSourceButton').click();

cy.location('pathname', { timeout: 6000 }).should(
'include',
Expand All @@ -55,14 +56,40 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
it('with basic auth and all required inputs', () => {
cy.get('[name="dataSourceTitle"]').type('test_auth');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[for="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormUsernameField"]').type(
username
);
cy.get('[data-test-subj="createDataSourceFormPasswordField"]').type(
password
);
cy.get('[type="submit"]').click();
cy.getElementByTestId('createDataSourceButton').click();

cy.location('pathname', { timeout: 6000 }).should(
'include',
'app/management/opensearch-dashboards/dataSources'
);
});

it('with sigV4 and all required inputs', () => {
cy.get('[name="dataSourceTitle"]').type('test_sigv4');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'sigv4'
);
cy.get('[data-test-subj="createDataSourceFormRegionField"]').type(
REGION
);
cy.get('[data-test-subj="createDataSourceFormAccessKeyField"]').type(
ACCESS_KEY
);
cy.get('[data-test-subj="createDataSourceFormSecretKeyField"]').type(
SECRET_KEY
);

cy.getElementByTestId('createDataSourceButton').click();

cy.location('pathname', { timeout: 6000 }).should(
'include',
Expand All @@ -76,8 +103,10 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
'test if can create datasource with no auth successfully'
);
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[for="no_auth"]').click();
cy.get('[type="submit"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.getElementByTestId('createDataSourceButton').click();

cy.location('pathname', { timeout: 6000 }).should(
'include',
Expand All @@ -91,14 +120,16 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
'test if can create datasource with basic auth successfully'
);
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[for="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormUsernameField"]').type(
username
);
cy.get('[data-test-subj="createDataSourceFormPasswordField"]').type(
password
);
cy.get('[type="submit"]').click();
cy.getElementByTestId('createDataSourceButton').click();

cy.location('pathname', { timeout: 6000 }).should(
'include',
Expand Down Expand Up @@ -170,14 +201,18 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {

describe('Username validation', () => {
it('validate that username field does not show when auth type is no auth', () => {
cy.get('[for="no_auth"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.get('[data-test-subj="createDataSourceFormUsernameField"]').should(
'not.exist'
);
});

it('validate that username is a required field when auth type is username & password', () => {
cy.get('[for="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormUsernameField"]')
.focus()
.blur();
Expand All @@ -187,7 +222,9 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
});

it('validate that username field does not show any error when auth type is username & password and field is not empty', () => {
cy.get('[for="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormUsernameField"]')
.type(username)
.blur();
Expand All @@ -199,14 +236,18 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {

describe('Password validation', () => {
it('validate that password field does not show when auth type is no auth', () => {
cy.get('[for="no_auth"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.get('[data-test-subj="createDataSourceFormPasswordField"]').should(
'not.exist'
);
});

it('validate that password is a required field when auth type is username & password', () => {
cy.get('[for="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormPasswordField"]')
.focus()
.blur();
Expand All @@ -216,7 +257,9 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
});

it('validate that password field does not show any error when auth type is username & password and field is not empty', () => {
cy.get('[for="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormPasswordField"]')
.type(password)
.blur();
Expand All @@ -231,7 +274,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
miscUtils.visitPage(
'app/management/opensearch-dashboards/dataSources/create'
);
cy.get('[type="submit"]').should('be.disabled');
cy.getElementByTestId('createDataSourceButton').should('be.disabled');
});

it('validate if create data source connection button is disabled when there is any field error', () => {
Expand All @@ -240,14 +283,18 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
'have.length',
1
);
cy.get('[type="submit"]').should('be.disabled');
cy.getElementByTestId('createDataSourceButton').should('be.disabled');
});

it('validate if create data source connection button is not disabled only if there is no any field error', () => {
cy.get('[name="dataSourceTitle"]').type('test_create_button');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[for="no_auth"]').click();
cy.get('[type="submit"]').should('not.be.disabled');
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.getElementByTestId('createDataSourceButton').should(
'not.be.disabled'
);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
);
});

/* Experimental Callout */
it('should display experimental call out', () => {
cy.getElementByTestId('data-source-experimental-call').should('exist');
});

describe('Empty State', () => {
before(() => {
// Clean up table before other tests run
Expand Down
Loading

0 comments on commit 91d50c3

Please sign in to comment.