Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Su <[email protected]>
  • Loading branch information
zhongnansu committed Apr 2, 2024
1 parent 4faa0c9 commit 5620ff4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 50 deletions.
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ENDPOINT_WITH_PROXY": false,
"MANAGED_SERVICE_ENDPOINT": false,
"VISBUILDER_ENABLED": true,
"DATASOURCE_MANAGEMENT_ENABLED": false,
"DATASOURCE_MANAGEMENT_ENABLED": true,
"ML_COMMONS_DASHBOARDS_ENABLED": true,
"WAIT_FOR_LOADER_BUFFER_MS": 0,
"DASHBOARDS_ASSISTANT_ENABLED": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
);
cy.get('[name="dataSourceTitle"]').type('test_noauth');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="no_auth"]').click();

cy.get('[data-test-subj="createDataSourceButton"]').should(
'be.enabled'
);
Expand All @@ -79,9 +79,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
);
cy.get('[name="dataSourceTitle"]').type('test_auth');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormUsernameField"]').type(
username
);
Expand All @@ -91,6 +90,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
cy.get('[data-test-subj="createDataSourceButton"]').should(
'be.enabled'
);

cy.get('[name="dataSourceDescription"]').type(
'cypress test basic auth data source'
);
Expand All @@ -110,15 +110,15 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
);
cy.get('[name="dataSourceTitle"]').type('test_sigv4_es');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'sigv4'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="sigv4"]').click();
cy.get('[data-test-subj="createDataSourceFormRegionField"]').type(
REGION
);
cy.get(
'[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]'
).select('es');
).click();
cy.get('button[id="es"]').click();
cy.get('[data-test-subj="createDataSourceFormAccessKeyField"]').type(
ACCESS_KEY
);
Expand Down Expand Up @@ -149,15 +149,16 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
);
cy.get('[name="dataSourceTitle"]').type('test_sigv4_aoss');
cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'sigv4'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="sigv4"]').click();
cy.get('[data-test-subj="createDataSourceFormRegionField"]').type(
REGION
);
cy.get(
'[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]'
).select('aoss');
cy.get('[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]')
.click()
.get('button[id="aoss"]')
.click();

cy.get('[data-test-subj="createDataSourceFormAccessKeyField"]').type(
ACCESS_KEY
);
Expand Down Expand Up @@ -246,18 +247,16 @@ 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('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="no_auth"]').click();
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('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="username_password"]').click().blur();
cy.get('[data-test-subj="createDataSourceFormUsernameField"]')
.focus()
.blur();
Expand All @@ -267,9 +266,8 @@ 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('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormUsernameField"]')
.type(username)
.blur();
Expand All @@ -281,18 +279,16 @@ 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('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="no_auth"]').click();
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('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormPasswordField"]')
.focus()
.blur();
Expand All @@ -302,9 +298,8 @@ 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('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'username_password'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="username_password"]').click();
cy.get('[data-test-subj="createDataSourceFormPasswordField"]')
.type(password)
.blur();
Expand All @@ -316,9 +311,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {

describe('SigV4 AuthType: fields validation', () => {
it('validate that region is a required field', () => {
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'sigv4'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="sigv4"]').click();
cy.get('[data-test-subj="createDataSourceFormRegionField"]')
.focus()
.blur();
Expand All @@ -328,9 +322,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
});

it('validate that accessKey is a required field', () => {
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'sigv4'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="sigv4"]').click();
cy.get('[data-test-subj="createDataSourceFormAccessKeyField"]')
.focus()
.blur();
Expand All @@ -340,9 +333,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
});

it('validate that secretKey is a required field', () => {
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'sigv4'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="sigv4"]').click();
cy.get('[data-test-subj="createDataSourceFormSecretKeyField"]')
.focus()
.blur();
Expand All @@ -352,9 +344,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
});

it('validate that serviceName is a required field, and with default option rendered', () => {
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'sigv4'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="sigv4"]').click();
cy.get(
'[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]'
).should('have.value', 'es');
Expand Down Expand Up @@ -385,9 +376,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
it('validate if create data source 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('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select(
'no_auth'
);
cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click();
cy.get('button[id="no_auth"]').click();
cy.get('[data-test-subj="createDataSourceButton"]').should(
'not.be.disabled'
);
Expand Down

0 comments on commit 5620ff4

Please sign in to comment.