mirror of https://github.com/grafana/grafana
Search e2e (#102827)
* search e2e * add github action * run test for every ini file in test folderfolder-tracing
parent
cd53070a00
commit
2489e423d0
@ -0,0 +1,121 @@ |
||||
name: Run dashboard search e2e |
||||
|
||||
on: |
||||
push: |
||||
branches: |
||||
- main |
||||
pull_request: |
||||
branches: |
||||
- main |
||||
|
||||
env: |
||||
ARCH: linux-amd64 |
||||
|
||||
jobs: |
||||
setup: |
||||
runs-on: ubuntu-latest |
||||
if: github.event.pull_request.draft == false |
||||
outputs: |
||||
ini_files: ${{ steps.get_files.outputs.ini_files }} |
||||
|
||||
steps: |
||||
- name: Checkout |
||||
uses: actions/checkout@v4 |
||||
- name: Pin Go version to mod file |
||||
uses: actions/setup-go@v5 |
||||
with: |
||||
go-version-file: 'go.mod' |
||||
cache: true |
||||
- run: go version |
||||
- uses: actions/setup-node@v4 |
||||
with: |
||||
node-version: 20 |
||||
cache: 'yarn' |
||||
- name: Cache Node Modules |
||||
id: cache-node-modules |
||||
uses: actions/cache@v3 |
||||
with: |
||||
path: | |
||||
node_modules |
||||
/home/runner/.cache/Cypress |
||||
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} |
||||
- name: Install dependencies |
||||
if: steps.cache-node-modules.outputs.cache-hit != 'true' |
||||
run: yarn install --immutable |
||||
- name: Install Cypress dependencies |
||||
if: steps.cache-node-modules.outputs.cache-hit != 'true' |
||||
uses: cypress-io/github-action@v6 |
||||
with: |
||||
runTests: false |
||||
- name: Cache Grafana Build and Dependencies |
||||
id: cache-grafana |
||||
uses: actions/cache@v3 |
||||
with: |
||||
path: | |
||||
bin/ |
||||
scripts/grafana-server/ |
||||
tools/ |
||||
public/ |
||||
conf/ |
||||
e2e/test-plugins/ |
||||
devenv/ |
||||
key: ${{ runner.os }}-grafana-${{ hashFiles('go.mod', 'package-lock.json', 'Makefile', 'pkg/storage/**/*.go', 'public/app/features/search/**/*.ts', 'public/app/features/search/**/*.tsx') }} |
||||
# only rebuild grafana if search files have changed ( or dependencies ) |
||||
- name: Build Grafana (Runs Only If Not Cached) |
||||
if: steps.cache-grafana.outputs.cache-hit != 'true' |
||||
run: make build |
||||
|
||||
- name: Get list of .ini files |
||||
id: get_files |
||||
run: | |
||||
INI_FILES=$(ls ${{ github.workspace }}/e2e/dashboards-search-suite/*.ini | jq -R -s -c 'split("\n")[:-1]') |
||||
echo "ini_files=$INI_FILES" >> $GITHUB_OUTPUT |
||||
shell: bash |
||||
|
||||
run_tests: |
||||
needs: setup |
||||
runs-on: ubuntu-latest |
||||
continue-on-error: true |
||||
if: github.event.pull_request.draft == false |
||||
strategy: |
||||
matrix: |
||||
ini_file: ${{ fromJson(needs.setup.outputs.ini_files) }} |
||||
|
||||
steps: |
||||
- name: Checkout repository |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Restore Cached Node Modules |
||||
uses: actions/cache@v3 |
||||
with: |
||||
path: | |
||||
node_modules |
||||
/home/runner/.cache/Cypress |
||||
key: foo |
||||
|
||||
- name: Restore Cached Grafana Build and Dependencies |
||||
uses: actions/cache@v3 |
||||
with: |
||||
path: | |
||||
bin/ |
||||
scripts/grafana-server/ |
||||
tools/ |
||||
public/ |
||||
conf/ |
||||
e2e/test-plugins/ |
||||
devenv/ |
||||
key: ${{ runner.os }}-grafana-${{ hashFiles('go.mod', 'package-lock.json', 'Makefile', 'pkg/storage/**/*.go', 'public/app/features/search/**/*.ts', 'public/app/features/search/**/*.tsx') }} |
||||
- name: Prettify the name |
||||
run: echo "Running tests for $(basename "${{ matrix.ini_file }}")" |
||||
- name: Set the step name |
||||
id: set_file_name |
||||
run: | |
||||
FILE_NAME=$(basename "${{ matrix.ini_file }}" .ini) |
||||
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV |
||||
- name: Run tests for ${{ env.FILE_NAME }} |
||||
run: | |
||||
cp -rf ${{ matrix.ini_file }} ${{ github.workspace }}/scripts/grafana-server/custom.ini |
||||
yarn e2e:dashboards-search || echo "Test failed but marking as success since unified search is behind a feature flag and should not block PRs" |
||||
- name: Always succeed # This is a workaround to make the job pass even if the previous step fails |
||||
if: failure() |
||||
run: exit 0 |
@ -0,0 +1,61 @@ |
||||
import { e2e } from '../utils'; |
||||
|
||||
const rowGroup = '[role="rowgroup"]'; |
||||
const row = '[role="row"]'; |
||||
const searchInput = '[data-testid="input-wrapper"]'; |
||||
|
||||
describe('Dashboard search', () => { |
||||
beforeEach(() => { |
||||
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD')); |
||||
}); |
||||
|
||||
it('Search - Dashboards list', () => { |
||||
e2e.pages.Dashboards.visit(); |
||||
|
||||
toggleSearchView(); |
||||
|
||||
assertResultsCount(24); |
||||
}); |
||||
|
||||
it('Search - Filter by search input', () => { |
||||
e2e.pages.Dashboards.visit(); |
||||
|
||||
toggleSearchView(); |
||||
|
||||
assertResultsCount(24); |
||||
|
||||
// prefix match
|
||||
cy.get(searchInput).type('Datasource tests - MySQL'); |
||||
assertResultsCount(2); |
||||
|
||||
cy.get(searchInput).type('{selectall}{backspace}'); // clear input
|
||||
|
||||
// exact match
|
||||
cy.get(searchInput).type('Datasource tests - MySQL (unittest)'); |
||||
assertResultsCount(1); |
||||
|
||||
cy.get(searchInput).type('{selectall}{backspace}'); // clear input
|
||||
|
||||
// suffix match
|
||||
cy.get(searchInput).type('- MySQL'); |
||||
assertResultsCount(1); |
||||
}); |
||||
}); |
||||
|
||||
const assertResultsCount = (length: number) => { |
||||
e2e.pages.SearchDashboards.table().should('exist'); |
||||
|
||||
const table = e2e.pages.SearchDashboards.table(); |
||||
const group = table.find(rowGroup); |
||||
group.should('have.length', 1); |
||||
const rows = group.find(row); |
||||
rows.should('have.length', length); |
||||
}; |
||||
|
||||
const toggleSearchView = () => { |
||||
e2e.pages.Dashboards.toggleView().each((e, i) => { |
||||
if (i === 1) { |
||||
cy.wrap(e).click(); |
||||
} |
||||
}); |
||||
}; |
@ -0,0 +1,19 @@ |
||||
[server] |
||||
|
||||
[feature_toggles] |
||||
kubernetesFolders = true |
||||
unifiedStorageSearch = true |
||||
unifiedStorageSearchUI = true |
||||
grafanaAPIServerWithExperimentalAPIs = true |
||||
kubernetesDashboardsAPI = true |
||||
kubernetesCliDashboards = true |
||||
unifiedStorageSearchSprinkles = true |
||||
kubernetesFoldersServiceV2 = true |
||||
unifiedStorageSearchPermissionFiltering = true |
||||
kubernetesClientDashboardsFolders = true |
||||
|
||||
[unified_storage.folders.folder.grafana.app] |
||||
dualWriterMode = 0 |
||||
|
||||
[unified_storage.dashboards.dashboard.grafana.app] |
||||
dualWriterMode = 0 |
@ -0,0 +1,19 @@ |
||||
[server] |
||||
|
||||
[feature_toggles] |
||||
kubernetesFolders = true |
||||
unifiedStorageSearch = true |
||||
unifiedStorageSearchUI = true |
||||
grafanaAPIServerWithExperimentalAPIs = true |
||||
kubernetesDashboardsAPI = true |
||||
kubernetesCliDashboards = true |
||||
unifiedStorageSearchSprinkles = true |
||||
kubernetesFoldersServiceV2 = true |
||||
unifiedStorageSearchPermissionFiltering = true |
||||
kubernetesClientDashboardsFolders = true |
||||
|
||||
[unified_storage.folders.folder.grafana.app] |
||||
dualWriterMode = 1 |
||||
|
||||
[unified_storage.dashboards.dashboard.grafana.app] |
||||
dualWriterMode = 1 |
@ -0,0 +1,19 @@ |
||||
[server] |
||||
|
||||
[feature_toggles] |
||||
kubernetesFolders = true |
||||
unifiedStorageSearch = true |
||||
unifiedStorageSearchUI = false |
||||
grafanaAPIServerWithExperimentalAPIs = true |
||||
kubernetesDashboardsAPI = true |
||||
kubernetesCliDashboards = true |
||||
unifiedStorageSearchSprinkles = true |
||||
kubernetesFoldersServiceV2 = true |
||||
unifiedStorageSearchPermissionFiltering = true |
||||
kubernetesClientDashboardsFolders = true |
||||
|
||||
[unified_storage.folders.folder.grafana.app] |
||||
dualWriterMode = 2 |
||||
|
||||
[unified_storage.dashboards.dashboard.grafana.app] |
||||
dualWriterMode = 2 |
@ -0,0 +1,19 @@ |
||||
[server] |
||||
|
||||
[feature_toggles] |
||||
kubernetesFolders = true |
||||
unifiedStorageSearch = true |
||||
unifiedStorageSearchUI = true |
||||
grafanaAPIServerWithExperimentalAPIs = true |
||||
kubernetesDashboardsAPI = true |
||||
kubernetesCliDashboards = true |
||||
unifiedStorageSearchSprinkles = true |
||||
kubernetesFoldersServiceV2 = true |
||||
unifiedStorageSearchPermissionFiltering = true |
||||
kubernetesClientDashboardsFolders = true |
||||
|
||||
[unified_storage.folders.folder.grafana.app] |
||||
dualWriterMode = 2 |
||||
|
||||
[unified_storage.dashboards.dashboard.grafana.app] |
||||
dualWriterMode = 2 |
@ -0,0 +1,19 @@ |
||||
[server] |
||||
|
||||
[feature_toggles] |
||||
kubernetesFolders = true |
||||
unifiedStorageSearch = true |
||||
unifiedStorageSearchUI = true |
||||
grafanaAPIServerWithExperimentalAPIs = true |
||||
kubernetesDashboardsAPI = true |
||||
kubernetesCliDashboards = true |
||||
unifiedStorageSearchSprinkles = true |
||||
kubernetesFoldersServiceV2 = true |
||||
unifiedStorageSearchPermissionFiltering = true |
||||
kubernetesClientDashboardsFolders = true |
||||
|
||||
[unified_storage.folders.folder.grafana.app] |
||||
dualWriterMode = 3 |
||||
|
||||
[unified_storage.dashboards.dashboard.grafana.app] |
||||
dualWriterMode = 3 |
@ -0,0 +1,19 @@ |
||||
[server] |
||||
|
||||
[feature_toggles] |
||||
kubernetesFolders = true |
||||
unifiedStorageSearch = true |
||||
unifiedStorageSearchUI = true |
||||
grafanaAPIServerWithExperimentalAPIs = true |
||||
kubernetesDashboardsAPI = true |
||||
kubernetesCliDashboards = true |
||||
unifiedStorageSearchSprinkles = true |
||||
kubernetesFoldersServiceV2 = true |
||||
unifiedStorageSearchPermissionFiltering = true |
||||
kubernetesClientDashboardsFolders = true |
||||
|
||||
[unified_storage.folders.folder.grafana.app] |
||||
dualWriterMode = 4 |
||||
|
||||
[unified_storage.dashboards.dashboard.grafana.app] |
||||
dualWriterMode = 4 |
@ -0,0 +1,19 @@ |
||||
[server] |
||||
|
||||
[feature_toggles] |
||||
kubernetesFolders = true |
||||
unifiedStorageSearch = true |
||||
unifiedStorageSearchUI = true |
||||
grafanaAPIServerWithExperimentalAPIs = true |
||||
kubernetesDashboardsAPI = true |
||||
kubernetesCliDashboards = true |
||||
unifiedStorageSearchSprinkles = true |
||||
kubernetesFoldersServiceV2 = true |
||||
unifiedStorageSearchPermissionFiltering = true |
||||
kubernetesClientDashboardsFolders = true |
||||
|
||||
[unified_storage.folders.folder.grafana.app] |
||||
dualWriterMode = 5 |
||||
|
||||
[unified_storage.dashboards.dashboard.grafana.app] |
||||
dualWriterMode = 5 |
Loading…
Reference in new issue