diff --git a/e2e/query.spec.ts b/e2e/query.spec.ts
index b2bac827..d3b9c598 100644
--- a/e2e/query.spec.ts
+++ b/e2e/query.spec.ts
@@ -4,27 +4,27 @@ import { runQuery } from './query';
test('test type:json source:url', async ({ page, panelEditPage }) => {
await panelEditPage.datasource.set('Infinity');
await panelEditPage.setVisualization('Table');
- const queryEditorRow = await panelEditPage.getQueryEditorRow('A');
+ const options = { page, panelEditPage };
- let frames = await runQuery(page, panelEditPage, queryEditorRow, {});
+ let frames = await runQuery({}, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe(''); // Ensure the parser type passed correctly
expect(frames.results['A'].frames[0].schema.meta.custom.data[0].country).toBe('USA'); // Ensure schema meta have actual data to be passed to the frontend
await expect(page.getByText('Patricia Lebsack')).toBeVisible(); // Ensure actual data rendered
- frames = await runQuery(page, panelEditPage, queryEditorRow, { parser: 'backend' });
+ frames = await runQuery({ parser: 'backend' }, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe('backend'); // Ensure the parser type passed correctly
expect(frames.results['A'].frames[0].data.values[1][0]).toBe('USA'); // Ensure actual data frames being returned
await expect(page.getByText('Patricia Lebsack')).toBeVisible(); // Ensure actual data rendered
- frames = await runQuery(page, panelEditPage, queryEditorRow, { parser: 'uql' });
+ frames = await runQuery({ parser: 'uql' }, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe('uql'); // Ensure the parser type passed correctly
expect(frames.results['A'].frames[0].schema.meta.custom.data[0].country).toBe('USA'); // Ensure schema meta have actual data to be passed to the frontend
await expect(page.getByText('Patricia Lebsack')).toBeVisible(); // Ensure actual data rendered
- frames = await runQuery(page, panelEditPage, queryEditorRow, { parser: 'groq' });
+ frames = await runQuery({ parser: 'groq' }, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe('groq'); // Ensure the parser type passed correctly
expect(frames.results['A'].frames[0].schema.meta.custom.data[0].country).toBe('USA'); // Ensure schema meta have actual data to be passed to the frontend
@@ -34,21 +34,21 @@ test('test type:json source:url', async ({ page, panelEditPage }) => {
test('test type:csv source:url', async ({ page, panelEditPage }) => {
await panelEditPage.datasource.set('Infinity');
await panelEditPage.setVisualization('Table');
- const queryEditorRow = await panelEditPage.getQueryEditorRow('A');
+ const options = { page, panelEditPage };
- let frames = await runQuery(page, panelEditPage, queryEditorRow, { type: 'csv', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.csv' });
+ let frames = await runQuery({ type: 'csv', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.csv' }, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe(''); // Ensure the parser type passed correctly
expect((frames.results['A'].frames[0].schema.meta.custom.data || '').startsWith('name,age,country,occupation,salary')).toBeTruthy(); // Ensure schema meta have actual data to be passed to the frontend
await expect(page.getByText('Patricia Lebsack')).toBeVisible(); // Ensure actual data rendered
- frames = await runQuery(page, panelEditPage, queryEditorRow, { type: 'csv', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.csv', parser: 'backend' });
+ frames = await runQuery({ type: 'csv', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.csv', parser: 'backend' }, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe('backend'); // Ensure the parser type passed correctly
expect(frames.results['A'].frames[0].data.values[1][0]).toBe('USA'); // Ensure actual data frames being returned
await expect(page.getByText('Patricia Lebsack')).toBeVisible(); // Ensure actual data rendered
- frames = await runQuery(page, panelEditPage, queryEditorRow, { type: 'csv', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.csv', parser: 'uql' });
+ frames = await runQuery({ type: 'csv', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.csv', parser: 'uql' }, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe('uql'); // Ensure the parser type passed correctly
expect((frames.results['A'].frames[0].schema.meta.custom.data || '').startsWith('name,age,country,occupation,salary')).toBeTruthy(); // Ensure schema meta have actual data to be passed to the frontend
@@ -58,21 +58,21 @@ test('test type:csv source:url', async ({ page, panelEditPage }) => {
test('test type:xml source:url', async ({ page, panelEditPage }) => {
await panelEditPage.datasource.set('Infinity');
await panelEditPage.setVisualization('Table');
- const queryEditorRow = await panelEditPage.getQueryEditorRow('A');
+ const options = { page, panelEditPage };
- let frames = await runQuery(page, panelEditPage, queryEditorRow, { type: 'xml', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.xml' });
+ let frames = await runQuery({ type: 'xml', url: 'https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.xml' }, options);
expect(frames.results['A'].frames[0].schema.name).toBe('A');
expect(frames.results['A'].frames[0].schema.meta.custom.query.parser).toBe(''); // Ensure the parser type passed correctly
expect((frames.results['A'].frames[0].schema.meta.custom.data || '').includes('Leanne GrahamLeanne Graham) => {
+export const runQuery = async (query: Record, options: { page: Page; panelEditPage: PanelEditPage }) => {
+ const { page, panelEditPage } = options;
+ const locator = await panelEditPage.getQueryEditorRow('A');
if (query.type) {
const typeDropdown = await locator.locator(`[data-testid='infinity-query-field-wrapper-type'] input`);
await typeDropdown.clear();