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

[Multiple Datasource] Update tests for 2.7 (#610) #614

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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