Skip to content

Commit

Permalink
Fix lints for integrations.spec.js and setup_integrations.ts (opensea…
Browse files Browse the repository at this point in the history
…rch-project#1332)

* Fix lints for integrations.spec.js

Signed-off-by: Simeon Widdis <[email protected]>

* Fix lint errors for setup_integration.tsx

Signed-off-by: Simeon Widdis <[email protected]>

* Fix lints for setup_integration

Signed-off-by: Simeon Widdis <[email protected]>

* Revert .eslintrc changes

Signed-off-by: Simeon Widdis <[email protected]>

---------

Signed-off-by: Simeon Widdis <[email protected]>
  • Loading branch information
Swiddis authored Jan 5, 2024
1 parent 177ae31 commit 3a4a08c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
64 changes: 30 additions & 34 deletions .cypress/integration/integrations_test/integrations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable jest/expect-expect */

/// <reference types="cypress" />

import {
TEST_INTEGRATION_INSTANCE, TEST_SAMPLE_INSTANCE,
} from '../../utils/constants';
import { TEST_INTEGRATION_INSTANCE, TEST_SAMPLE_INSTANCE } from '../../utils/constants';

let testInstanceSuffix = (Math.random() + 1).toString(36).substring(7);
let testInstance = `${TEST_INTEGRATION_INSTANCE}_${testInstanceSuffix}`;
const testInstanceSuffix = (Math.random() + 1).toString(36).substring(7);
const testInstance = `${TEST_INTEGRATION_INSTANCE}_${testInstanceSuffix}`;

const moveToIntegrationsHome = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/integrations#/available`);
Expand All @@ -28,10 +27,9 @@ const createSamples = () => {
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="try-it-button"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
}

};

describe('Basic sanity test for integrations plugin', () => {
describe('Integrations plugin', () => {
it('Navigates to integrations plugin and expects the correct header', () => {
moveToIntegrationsHome();
cy.get('[data-test-subj="integrations-header"]').should('exist');
Expand All @@ -40,66 +38,66 @@ describe('Basic sanity test for integrations plugin', () => {
it('Navigates to integrations plugin and tests that clicking the nginx cards navigates to the nginx page', () => {
moveToIntegrationsHome();
cy.get('[data-test-subj="integration_card_nginx"]').click();
cy.url().should('include', '/available/nginx')
})
cy.url().should('include', '/available/nginx');
});

it('Navigates to nginx page and asserts the page to be as expected', () => {
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="nginx-overview"]').should('exist')
cy.get('[data-test-subj="nginx-details"]').should('exist')
cy.get('[data-test-subj="nginx-screenshots"]').should('exist')
cy.get('[data-test-subj="nginx-assets"]').should('exist')
cy.get('[data-test-subj="nginx-overview"]').should('exist');
cy.get('[data-test-subj="nginx-details"]').should('exist');
cy.get('[data-test-subj="nginx-screenshots"]').should('exist');
cy.get('[data-test-subj="nginx-assets"]').should('exist');
cy.get('[data-test-subj="fields"]').click();
cy.get('[data-test-subj="nginx-fields"]').should('exist')
})
cy.get('[data-test-subj="nginx-fields"]').should('exist');
});

it('Uses the search of assets and fields tables', () => {
moveToAvailableNginxIntegration();
cy.get('input[type="search"]').eq(0).focus().type('ss4o{enter}');
cy.get('.euiTableRow').should('have.length', 1);//Filters correctly to the index pattern
cy.get('.euiTableRow').should('have.length', 1); //Filters correctly to the index pattern
cy.get('[data-test-subj="fields"]').click();
cy.get('input[type="search"]').eq(0).focus().clear().type('severity.observe')
cy.get('.euiTableRow').should('have.length', 2);//Filters correctly to the field name
})
cy.get('input[type="search"]').eq(0).focus().clear().type('severity.observe');
cy.get('.euiTableRow').should('have.length', 2); //Filters correctly to the field name
});

it('Uses the filter of assets table', () => {
moveToAvailableNginxIntegration();
cy.get('.euiFilterGroup').trigger('mouseover').click();
cy.get('.euiFilterSelectItem').contains('visualization').click();
cy.get('.euiTableRow').should('have.length', 6);//Filters correctly to visualization types
})
cy.get('.euiTableRow').should('have.length', 6); //Filters correctly to visualization types
});
});

describe('Tests the add nginx integration instance flow', () => {
describe('Add nginx integration instance flow', () => {
it('Navigates to nginx page and triggers the adds the instance flow', () => {
createSamples();
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="add-integration-button"]').click();
cy.get('[data-test-subj="new-instance-name"]').should('have.value', 'nginx Integration');
cy.get('[data-test-subj="create-instance-button"]').should('be.disabled')
cy.get('[data-test-subj="create-instance-button"]').should('be.disabled');
// Modifies the name of the integration
cy.get('[data-test-subj="new-instance-name"]').clear().type(testInstance);
// Validates the created sample index
cy.get('[data-test-subj="data-source-name"]').type('ss4o_logs-nginx-sample-sample{enter}');
cy.get('[data-test-subj="create-instance-button"]').click();
cy.get('[data-test-subj="eventHomePageTitle"]').should('contain', 'nginx');
})
});

it('Navigates to installed integrations page and verifies that nginx-test exists', () => {
moveToAddedIntegrations();
cy.contains(testInstance).should('exist');
cy.get('input[type="search"]').eq(0).focus().type(`${testInstance}{enter}`);
cy.get('.euiTableRow').should('have.length', 1);//Filters correctly to the test integration instance
cy.get('.euiTableRow').should('have.length', 1); //Filters correctly to the test integration instance
cy.get(`[data-test-subj="${testInstance}IntegrationLink"]`).click();
})
});

it('Navigates to added integrations page and verifies that nginx-test exists and linked asset works as expected', () => {
moveToAddedIntegrations();
cy.contains(TEST_INTEGRATION_INSTANCE).should('exist');
cy.get(`[data-test-subj="${testInstance}IntegrationLink"]`).click();
cy.get(`[data-test-subj="IntegrationAssetLink"]`).click();
cy.url().should('include', '/dashboards#/')
})
cy.url().should('include', '/dashboards#/');
});

it('Navigates to installed nginx-test instance page and deletes it', () => {
moveToAddedIntegrations();
Expand All @@ -115,17 +113,15 @@ describe('Tests the add nginx integration instance flow', () => {
cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('not.be.disabled');
cy.get('button[data-test-subj="popoverModal__deleteButton"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
})
});
});

describe('Tests the add nginx integration instance flow', () => {
describe('Nginx try it flow', () => {
it('Navigates to nginx page and triggers the try it flow', () => {
moveToAvailableNginxIntegration();
cy.get('[data-test-subj="try-it-button"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
moveToAddedIntegrations();
cy.contains(TEST_SAMPLE_INSTANCE).should('exist');
})
});
});


19 changes: 12 additions & 7 deletions public/components/integrations/components/setup_integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ import {
EuiTitle,
} from '@elastic/eui';
import React, { useState, useEffect } from 'react';
import { Color } from 'common/constants/integrations';
import { Color } from '../../../../common/constants/integrations';
import { coreRefs } from '../../../framework/core_refs';
import { IntegrationTemplate, addIntegrationRequest } from './create_integration_helpers';
import { CONSOLE_PROXY, INTEGRATIONS_BASE } from '../../../../common/constants/shared';
import { DATACONNECTIONS_BASE } from '../../../../common/constants/shared';
import {
CONSOLE_PROXY,
INTEGRATIONS_BASE,
DATACONNECTIONS_BASE,
} from '../../../../common/constants/shared';

export interface IntegrationSetupInputs {
displayName: string;
Expand Down Expand Up @@ -119,7 +122,7 @@ const suggestDataSources = async (type: string): Promise<Array<{ label: string }
console.error(`Unknown connection type: ${type}`);
return [];
}
} catch (err: any) {
} catch (err) {
console.error(err.message);
return [];
}
Expand All @@ -144,9 +147,10 @@ const runQuery = async (
method: 'POST',
},
});
let poll: { status: string; error?: string } = { status: 'undefined' };
const [queryId, newSessionId] = [queryResponse.queryId, queryResponse.sessionId];
while (true) {
const poll: { status: string; error?: string } = await http.post(CONSOLE_PROXY, {
while (!poll.error) {
poll = await http.post(CONSOLE_PROXY, {
body: '{}',
query: {
path: '_plugins/_async_query/' + queryId,
Expand All @@ -170,7 +174,8 @@ const runQuery = async (
}
await sleep(3000);
}
} catch (err: any) {
return { ok: false, error: new Error(poll.error) };
} catch (err) {
console.error(err);
return { ok: false, error: err };
}
Expand Down

0 comments on commit 3a4a08c

Please sign in to comment.