-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix the datasources cypress tests * Clean up test setup and setup constants * Refactor datasources test and disable security config * Fix some lint * Switch to capitalized naming * Fix lint * debugging * List out all the changed files * Add output for file changes * Switch to use env var * Add echo * Remove github env setup * Add msg to check which file is being linted * Use jq for parsing * Lint both modified and added --------- (cherry picked from commit d17ec69) Signed-off-by: Ryan Liang <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7a8b73e
commit 3abd951
Showing
6 changed files
with
108 additions
and
58 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
.cypress/integration/datasources_test/datasources_basic_ui.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { FONTEND_BASE_PATH, DATASOURCES_API_PREFIX, DATASOURCES_PATH } from '../../utils/constants'; | ||
|
||
const MANAGE_DATASOURCES_TAG = 'button[data-test-subj="manage"]'; | ||
const NEW_DATASOURCES_TAG = 'button[data-test-subj="new"]'; | ||
const CREATE_S3_BUTTON = '[data-test-subj="datasource_card_s3glue"]'; | ||
const CREATE_PROMETHEUS_BUTTON = '[data-test-subj="datasource_card_prometheus"]'; | ||
|
||
const visitDatasourcesHomePage = () => { | ||
cy.visit(FONTEND_BASE_PATH + DATASOURCES_API_PREFIX); | ||
}; | ||
|
||
const visitDatasourcesCreationPage = () => { | ||
cy.visit(FONTEND_BASE_PATH + DATASOURCES_PATH.DATASOURCES_CREATION_BASE); | ||
}; | ||
|
||
describe('Integration tests for datasources plugin', () => { | ||
it('Navigates to datasources plugin and expects the correct header', () => { | ||
visitDatasourcesHomePage(); | ||
cy.get('[data-test-subj="dataconnections-header"]').should('exist'); | ||
}); | ||
|
||
it('Tests navigation between tabs', () => { | ||
visitDatasourcesHomePage(); | ||
|
||
cy.get(MANAGE_DATASOURCES_TAG) | ||
.should('have.class', 'euiTab-isSelected') | ||
.and('have.attr', 'aria-selected', 'true'); | ||
cy.get(MANAGE_DATASOURCES_TAG).click(); | ||
cy.url().should('include', '/manage'); | ||
|
||
cy.get(NEW_DATASOURCES_TAG).click(); | ||
cy.get(NEW_DATASOURCES_TAG) | ||
.should('have.class', 'euiTab-isSelected') | ||
.and('have.attr', 'aria-selected', 'true'); | ||
cy.url().should('include', '/new'); | ||
|
||
cy.get(CREATE_S3_BUTTON).should('be.visible'); | ||
cy.get(CREATE_PROMETHEUS_BUTTON).should('be.visible'); | ||
}); | ||
|
||
it('Tests navigation of S3 datasources creation page with hash', () => { | ||
visitDatasourcesCreationPage(); | ||
|
||
cy.get(CREATE_S3_BUTTON).should('be.visible').click(); | ||
cy.url().should('include', DATASOURCES_PATH.DATASOURCES_CONFIG_BASE + '/AmazonS3AWSGlue'); | ||
|
||
cy.get('h1.euiTitle.euiTitle--medium') | ||
.should('be.visible') | ||
.and('contain', 'Configure Amazon S3 data source'); | ||
}); | ||
|
||
it('Tests navigation of Prometheus datasources creation page with hash', () => { | ||
visitDatasourcesCreationPage(); | ||
|
||
cy.get(CREATE_PROMETHEUS_BUTTON).should('be.visible').click(); | ||
cy.url().should('include', DATASOURCES_PATH.DATASOURCES_CONFIG_BASE + '/Prometheus'); | ||
|
||
cy.get('h4.euiTitle.euiTitle--medium') | ||
.should('be.visible') | ||
.and('contain', 'Configure Prometheus data source'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,25 +48,32 @@ jobs: | |
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }} | ||
run: yarn osd bootstrap | ||
|
||
- name: Get list of changed files | ||
id: files | ||
- name: Get list of changed files using GitHub Action | ||
uses: lots0logs/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check Changes of Files | ||
run: | | ||
BASE_SHA="${{ github.event.pull_request.base.sha }}" | ||
HEAD_SHA="${{ github.event.pull_request.head.sha }}" | ||
git fetch origin $BASE_SHA | ||
git diff --name-only $BASE_SHA...$HEAD_SHA > changed_files.txt | ||
CHANGED_FILES=$(cat changed_files.txt | grep -E '\.(js|ts|tsx)$' || true) | ||
echo "::set-output name=changed::${CHANGED_FILES}" | ||
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }} | ||
echo "FILES_MODIFIED=$(cat ${HOME}/files_modified.json)" | ||
echo "FILES_ADDED=$(cat ${HOME}/files_added.json)" | ||
echo "FILES_RENAMED=$(cat ${HOME}/files_renamed.json)" | ||
echo "FILES_DELETED=$(cat ${HOME}/files_deleted.json)" | ||
- name: Lint Changed Files | ||
run: | | ||
CHANGED_FILES="${{ steps.files.outputs.changed }}" | ||
jq -r '.[]' ${HOME}/files_modified.json ${HOME}/files_added.json | sort | uniq > /tmp/changed_files.txt | ||
CHANGED_FILES=$(cat /tmp/changed_files.txt) | ||
echo "These are the changed files: $CHANGED_FILES" | ||
if [[ -n "$CHANGED_FILES" ]]; then | ||
echo "Linting changed files..." | ||
IFS=$'\n' read -r -a FILES_TO_LINT <<< "$CHANGED_FILES" | ||
yarn lint "${FILES_TO_LINT[@]}" | ||
while IFS= read -r file; do | ||
if [[ $file == *.js || $file == *.ts || $file == *.tsx ]]; then | ||
echo "linting file $file" | ||
yarn lint "$file" | ||
fi | ||
done < /tmp/changed_files.txt | ||
else | ||
echo "No matched files to lint." | ||
fi | ||
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }} | ||
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters