Skip to content

Commit

Permalink
Update e2e tests (#81)
Browse files Browse the repository at this point in the history
* base tests added

* inline-field revert

* removed incorrect case

* add sorting

* add base test for filter functionality

* add edit case

* update e2e

* expand test added

* update e2e flow

* simple helpers added

* selectors first step

* locator selectors updated

* Add variables to dashboard

* Fix tests

* Add dependency workflow

* Update e2e tests

* Fix e2e script

* Fix using grafana selectors for dependency version

* Fix e2e for main grafana

* Fix the same artifact name for dependency workflow

---------

Co-authored-by: Mikhail Volkov <[email protected]>
Co-authored-by: asimonok <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent fc5ca4b commit 1a33e34
Show file tree
Hide file tree
Showing 18 changed files with 1,116 additions and 45 deletions.
40 changes: 37 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main

jobs:
tests:
dev:
runs-on: ubuntu-latest

steps:
Expand All @@ -18,8 +18,8 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm install
Expand All @@ -42,3 +42,37 @@ jobs:
name: playwright-report
path: playwright-report/
retention-days: 30

dependency:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Start Grafana
run: docker compose --profile dependency up -d

- name: Run e2e tests
run: npm run test:e2e:docker

- name: Stop Grafana
run: docker compose down

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report-dependency
path: playwright-report/
retention-days: 30
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ e2e-results/
.idea
.DS_Store

# Cypress
cypress/report.json
cypress/videos/
cypress/screenshots/actual
# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

### Features / Enhancements

- Update aggregated cell to support Standard Options (#79)
- Updated aggregated cell to support Standard Options (#79)
- Added nested objects cell type (#80)
- Updated e2e tests (#81)

## 1.3.0 (2024-09-20)

Expand Down
18 changes: 16 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
environment:
- GF_DEFAULT_APP_MODE=development
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards/panels.json
- GF_INSTALL_PLUGINS=marcusolsson-static-datasource
- GF_INSTALL_PLUGINS=marcusolsson-static-datasource,volkovlabs-variable-panel
volumes:
- ./dist:/var/lib/grafana/plugins/volkovlabs-table-panel
- ./provisioning:/etc/grafana/provisioning
Expand All @@ -20,13 +20,26 @@ services:
environment:
- GF_DEFAULT_APP_MODE=development
- GF_USERS_DEFAULT_THEME=light
- GF_INSTALL_PLUGINS=marcusolsson-static-datasource
- GF_INSTALL_PLUGINS=marcusolsson-static-datasource,volkovlabs-variable-panel
volumes:
- ./dist:/var/lib/grafana/plugins/volkovlabs-table-panel
- ./provisioning:/etc/grafana/provisioning
profiles:
- main

grafana-dep:
image: grafana/grafana:10.3.0
ports:
- 3000:3000/tcp
environment:
- GF_DEFAULT_APP_MODE=development
- GF_INSTALL_PLUGINS=marcusolsson-static-datasource,volkovlabs-variable-panel
volumes:
- ./dist:/var/lib/grafana/plugins/volkovlabs-table-panel
- ./provisioning:/etc/grafana/provisioning
profiles:
- dependency

test:
build:
context: .
Expand All @@ -52,3 +65,4 @@ services:
profiles:
- dev
- main
- dependency
23 changes: 5 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"devDependencies": {
"@babel/core": "^7.25.2",
"@grafana/eslint-config": "^7.0.0",
"@grafana/plugin-e2e": "^1.7.1",
"@grafana/plugin-e2e": "^1.8.2",
"@grafana/tsconfig": "^2.0.0",
"@swc/core": "^1.7.23",
"@swc/helpers": "^0.5.13",
Expand Down Expand Up @@ -74,6 +74,7 @@
"lint:fix": "eslint --fix --ignore-path ./.eslintignore --ext .js,.jsx,.ts,.tsx .",
"sign": "npx --yes @grafana/sign-plugin@latest",
"start": "docker compose pull grafana && docker compose --profile dev up",
"start:dep": "docker compose pull grafana-dep && docker compose --profile dependency up",
"start:main": "docker compose pull grafana-main && docker compose --profile main up",
"stop": "docker compose down",
"test": "jest --watch --onlyChanged",
Expand Down
12 changes: 7 additions & 5 deletions provisioning/dashboards/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 2,
"links": [],
"panels": [
{
Expand Down Expand Up @@ -140,7 +141,7 @@
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "select * from comments WHERE id IN (${payload.ids:sqlstring});",
"rawSql": "select * from comments WHERE id IN (${payload.ids:csv});",
"refId": "A",
"sql": {
"columns": [
Expand Down Expand Up @@ -214,7 +215,7 @@
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "select id, title from comments WHERE id IN (${payload.ids:sqlstring});",
"rawSql": "select id, title from comments WHERE id IN (${payload.ids:csv});",
"refId": "A",
"sql": {
"columns": [
Expand Down Expand Up @@ -834,7 +835,7 @@
"export": false
}
},
"pluginVersion": "1.3.0",
"pluginVersion": "1.4.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -996,7 +997,8 @@
"type": "volkovlabs-table-panel"
}
],
"schemaVersion": 39,
"preload": false,
"schemaVersion": 40,
"tags": [],
"templating": {
"list": []
Expand All @@ -1009,6 +1011,6 @@
"timezone": "browser",
"title": "Devices",
"uid": "edxke3hyi04cgc",
"version": 21,
"version": 1,
"weekStart": ""
}
78 changes: 72 additions & 6 deletions provisioning/dashboards/query-based.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,75 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 4,
"links": [],
"panels": [
{
"datasource": {
"type": "marcusolsson-static-datasource",
"uid": "P1D2C73DC01F2359B"
},
"fieldConfig": {
"defaults": {
"custom": {
"thresholdsStyle": {
"mode": "color",
"thresholds": []
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 2,
"w": 15,
"x": 0,
"y": 0
},
"id": 3,
"options": {
"alwaysVisibleFilter": false,
"autoScroll": false,
"collapsedByDefault": false,
"customValue": false,
"displayMode": "button",
"emptyValue": false,
"favorites": {
"enabled": false,
"storage": "browser"
},
"filter": false,
"groupSelection": false,
"header": true,
"padding": 10,
"persistent": false,
"saveSelectedGroup": false,
"saveSelectedGroupKey": "",
"showGroupTotal": false,
"showLabel": false,
"showName": false,
"showResetButton": false,
"showTotal": false,
"statusSort": false,
"sticky": false,
"tabsInOrder": true,
"variable": "status"
},
"pluginVersion": "3.4.0",
"type": "volkovlabs-variable-panel"
},
{
"datasource": {
"type": "marcusolsson-static-datasource",
Expand Down Expand Up @@ -65,7 +131,7 @@
"h": 9,
"w": 15,
"x": 0,
"y": 0
"y": 2
},
"id": 1,
"options": {
Expand Down Expand Up @@ -273,7 +339,7 @@
"export": false
}
},
"pluginVersion": "1.3.0",
"pluginVersion": "1.4.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -352,7 +418,7 @@
"h": 8,
"w": 15,
"x": 0,
"y": 9
"y": 11
},
"id": 2,
"options": {
Expand Down Expand Up @@ -472,7 +538,7 @@
"export": false
}
},
"pluginVersion": "1.3.0",
"pluginVersion": "1.4.0",
"targets": [
{
"datasource": {
Expand Down Expand Up @@ -556,7 +622,7 @@
},
{
"current": {
"selected": true,
"selected": false,
"text": ["All"],
"value": ["$__all"]
},
Expand Down
1 change: 1 addition & 0 deletions src/__mocks__/@grafana/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const SelectMock = ({
isLoading,
onOpenMenu,
onCloseMenu,
inputId,
isSearchable,
...restProps
}: any) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export const Table = <TData,>({
>
<thead className={styles.header} ref={tableHeaderRef} style={{ top: topOffset }}>
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id} className={styles.headerRow}>
<tr key={headerGroup.id} className={styles.headerRow} {...TEST_IDS.table.headerRow.apply(headerGroup.id)}>
{headerGroup.headers.map((header) => (
<th
key={header.id}
Expand Down
1 change: 1 addition & 0 deletions src/components/editors/FieldPicker/FieldPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const FieldPicker: React.FC<Props> = ({

return (
<Select
inputId="config-new-column"
options={availableFieldOptions}
value={selectValue}
onChange={(event) => {
Expand Down
1 change: 1 addition & 0 deletions src/components/editors/TablesEditor/TablesEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const TablesEditor: React.FC<Props> = ({ context: { options, data }, onCh
{...provided.draggableProps}
style={getItemStyle(snapshot.isDragging, provided.draggableProps.style)}
className={styles.item}
{...testIds.item.apply(item.name)}
>
<Collapse
key={item.name}
Expand Down
Loading

0 comments on commit 1a33e34

Please sign in to comment.