Skip to content

Commit 2d07cf0

Browse files
Jan Waśnineinchnick
authored andcommitted
Add an E2E test
1 parent 1bd839d commit 2d07cf0

File tree

8 files changed

+103
-18
lines changed

8 files changed

+103
-18
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,42 @@ jobs:
2525
- name: Build and test frontend
2626
run: yarn build
2727

28-
- name: Check for backend
29-
id: check-for-backend
30-
run: |
31-
if [ -f "Magefile.go" ]
32-
then
33-
echo "::set-output name=has-backend::true"
34-
fi
35-
3628
- name: Setup Go environment
37-
if: steps.check-for-backend.outputs.has-backend == 'true'
3829
uses: actions/setup-go@v5
3930
with:
4031
go-version: "1.22"
4132

4233
- name: Test backend
43-
if: steps.check-for-backend.outputs.has-backend == 'true'
4434
uses: magefile/mage-action@v3
4535
with:
4636
version: latest
4737
args: coverage
4838

4939
- name: Build backend
50-
if: steps.check-for-backend.outputs.has-backend == 'true'
5140
uses: magefile/mage-action@v3
5241
with:
5342
version: latest
5443
args: buildAll
44+
45+
- name: End to end test
46+
run: |
47+
docker network create trino
48+
49+
docker run \
50+
--rm --detach \
51+
--name trino \
52+
--net trino \
53+
trinodb/trino:468
54+
55+
docker run \
56+
--rm --detach \
57+
--name grafana \
58+
--net trino \
59+
--publish 3000:3000 \
60+
--volume "$(pwd):/var/lib/grafana/plugins/trino" \
61+
--env "GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=trino-datasource" \
62+
grafana/grafana:11.4.0
63+
64+
npx tsc -p tsconfig.json --noEmit
65+
npx playwright install
66+
npx playwright test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ e2e-results/
2929
# Editor
3030
.idea
3131
.vscode
32+
33+
# Playwright
34+
playwright-report/
35+
test-results

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44

55
const standard = require('@grafana/toolkit/src/config/jest.plugin.config');
66

7+
8+
var jestConfig = standard.jestConfig();
9+
jestConfig.testPathIgnorePatterns = ["/node_modules/", "e2e.test.ts"]
10+
711
// This process will use the same config that `yarn test` is using
8-
module.exports = standard.jestConfig();
12+
module.exports = jestConfig;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@grafana/runtime": "9.5.2",
2121
"@grafana/toolkit": "9.5.2",
2222
"@grafana/ui": "9.5.2",
23+
"@playwright/test": "1.33.0",
2324
"@types/lodash": "4.14.195",
2425
"react": "^18.2.0",
2526
"react-dom": "^18.2.0"

playwright.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: 'src',
5+
testMatch: 'e2e*.test.ts',
6+
fullyParallel: true,
7+
forbidOnly: !!process.env.CI,
8+
retries: process.env.CI ? 2 : 0,
9+
workers: process.env.CI ? 1 : undefined,
10+
reporter: 'html',
11+
use: {
12+
baseURL: 'http://127.0.0.1:3000',
13+
trace: 'on-first-retry',
14+
},
15+
projects: [
16+
{
17+
name: 'chromium',
18+
use: { ...devices['Desktop Chrome'] },
19+
},
20+
]
21+
});

src/e2e.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('test', async ({ page }) => {
4+
await page.goto('http://localhost:3000/login');
5+
await page.getByTestId('data-testid Username input field').fill('admin');
6+
await page.getByTestId('data-testid Password input field').fill('admin');
7+
await page.getByTestId('data-testid Login button').click();
8+
await page.getByTestId('data-testid Skip change password button').click();
9+
await page.getByTestId('data-testid Toggle menu').click();
10+
await page.getByRole('link', { name: 'Connections' }).click();
11+
await page.getByRole('link', { name: 'Trino' }).click();
12+
await page.locator('.css-1yhi3xa').click();
13+
await page.getByRole('button', { name: 'Add new data source' }).click();
14+
await page.getByTestId('data-testid Datasource HTTP settings url').fill('http://trino:8080');
15+
await page.locator('div').filter({ hasText: /^Impersonate logged in userAccess token$/ }).getByLabel('Toggle switch').click();
16+
await page.locator('input[type="password"]').fill('aaa');
17+
await page.getByTestId('data-testid Data source settings page Save and Test button').click();
18+
await page.getByLabel('Explore data').click();
19+
await page.getByTestId('data-testid TimePicker Open Button').click();
20+
await page.getByTestId('data-testid Time Range from field').fill('1995-01-01');
21+
await page.getByTestId('data-testid Time Range to field').fill('1995-12-31');
22+
await page.getByTestId('data-testid TimePicker submit button').click();
23+
await page.locator('div').filter({ hasText: /^Format asChoose$/ }).locator('svg').click();
24+
await page.getByRole('option', { name: 'Table' }).click();
25+
await page.getByTestId('data-testid Code editor container').click();
26+
await page.getByTestId('data-testid RefreshPicker run button').click();
27+
await expect(page.getByTestId('data-testid table body')).toContainText(/.*1995-01-19 0.:00:005703857F.*/);
28+
});

src/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ export const SelectableFormatOptions: Array<SelectableValue<FormatOptions>> = [
2727

2828
export const defaultQuery: Partial<TrinoQuery> = {
2929
rawSQL: `SELECT
30-
$__timeGroup(time_column, '1h'),
31-
value_column as value,
32-
series_column as metric
30+
$__timeGroup(orderdate, '1w'),
31+
sum(totalprice) as value,
32+
orderstatus as metric
3333
FROM
34-
catalog_name.schema_name.table_name
34+
tpch.tiny.orders
3535
WHERE
36-
$__timeFilter(time_column)
36+
$__timeFilter(orderdate)
3737
GROUP BY
3838
1, 3
3939
ORDER BY

yarn.lock

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,16 @@
21192119
resolved "https://registry.yarnpkg.com/@petamoriken/float16/-/float16-3.7.1.tgz#4a0cc0854a3a101cc2d697272f120e1a05975ce5"
21202120
integrity sha512-oXZOc+aePd0FnhTWk15pyqK+Do87n0TyLV1nxdEougE95X/WXWDqmQobfhgnSY7QsWn5euZUWuDVeTQvoQ5VNw==
21212121

2122+
"@playwright/[email protected]":
2123+
version "1.33.0"
2124+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.33.0.tgz#669ef859efb81b143dfc624eef99d1dd92a81b67"
2125+
integrity sha512-YunBa2mE7Hq4CfPkGzQRK916a4tuZoVx/EpLjeWlTVOnD4S2+fdaQZE0LJkbfhN5FTSKNLdcl7MoT5XB37bTkg==
2126+
dependencies:
2127+
"@types/node" "*"
2128+
playwright-core "1.33.0"
2129+
optionalDependencies:
2130+
fsevents "2.3.2"
2131+
21222132
"@popperjs/[email protected]", "@popperjs/core@^2.11.5":
21232133
version "2.11.6"
21242134
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.6.tgz#cee20bd55e68a1720bdab363ecf0c821ded4cd45"
@@ -5482,7 +5492,7 @@ fs.realpath@^1.0.0:
54825492
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
54835493
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
54845494

5485-
fsevents@^2.3.2, fsevents@~2.3.2:
5495+
fsevents@2.3.2, fsevents@^2.3.2, fsevents@~2.3.2:
54865496
version "2.3.2"
54875497
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
54885498
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
@@ -7694,6 +7704,11 @@ pkg-up@^3.1.0:
76947704
dependencies:
76957705
find-up "^3.0.0"
76967706

7707+
7708+
version "1.33.0"
7709+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.33.0.tgz#269efe29a927cd6d144d05f3c2d2f72bd72447a1"
7710+
integrity sha512-aizyPE1Cj62vAECdph1iaMILpT0WUDCq3E6rW6I+dleSbBoGbktvJtzS6VHkZ4DKNEOG9qJpiom/ZxO+S15LAw==
7711+
76977712
pngjs@^6.0.0:
76987713
version "6.0.0"
76997714
resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-6.0.0.tgz#ca9e5d2aa48db0228a52c419c3308e87720da821"

0 commit comments

Comments
 (0)