-
Notifications
You must be signed in to change notification settings - Fork 57
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
[Enhancement/Fix] Refactor datasources cypress tests #1323
Changes from all commits
d8e5d55
9e5653d
1cef138
ec90078
1a1957d
7536060
5aba972
f47c5c4
0574e8e
f8d5f59
2c1e2a0
9a553bc
1963efb
4e48438
b2ccbe6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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'); | ||
}); | ||
}); |
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 }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,12 @@ module.exports = defineConfig({ | |
env: { | ||
opensearch: 'localhost:9200', | ||
opensearchDashboards: 'localhost:5601', | ||
security_enabled: true, | ||
security_enabled: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This security config should be disabled by default because:
|
||
}, | ||
'cypress-watch-and-reload': { | ||
watch: ['common/**', 'public/**', 'server/**'], | ||
}, | ||
e2e: { | ||
// We've imported your old cypress plugins here. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a cypress update comment, and we should remove this. |
||
// You may want to clean this up later by importing these. | ||
setupNodeEvents(on, config) { | ||
return require('./.cypress/plugins/index.js')(on, config); | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this dashboards configuration because the current cypress framework is having trouble determine among
localhost
,127.0.0.1
, and::
.This is a known issue for cypress + node version 18+: cypress-io/cypress#25397 (comment)