Prettier: Upgrade to 2 (#30387)

* Updated package json but not updated source files

* Update eslint plugin

* updated files
This commit is contained in:
Torkel Ödegaard 2021-01-20 07:59:48 +01:00 committed by GitHub
parent f27450ed94
commit 1d689888b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1069 changed files with 4370 additions and 5260 deletions

View File

@ -20,7 +20,7 @@ export const setup = () => {
};
};
export default data => {
export default (data) => {
client.withOrgId(data.orgId);
group('annotation by tag test', () => {
@ -29,8 +29,8 @@ export default data => {
let res = client.ui.login('admin', 'admin');
check(res, {
'response status is 200': r => r.status === 200,
"response has cookie 'grafana_session' with 32 characters": r =>
'response status is 200': (r) => r.status === 200,
"response has cookie 'grafana_session' with 32 characters": (r) =>
r.cookies.grafana_session[0].value.length === 32,
});
});
@ -63,7 +63,7 @@ export default data => {
let responses = client.batch(requests);
for (let n = 0; n < batchCount; n++) {
check(responses[n], {
'response status is 200': r => r.status === 200,
'response status is 200': (r) => r.status === 200,
});
}
});
@ -73,4 +73,4 @@ export default data => {
sleep(5);
};
export const teardown = data => {};
export const teardown = (data) => {};

View File

@ -2,7 +2,6 @@ import { sleep, check, group } from 'k6';
import { createClient, createBasicAuthClient, createBearerAuthClient } from './modules/client.js';
import { createTestOrgIfNotExists, createTestdataDatasourceIfNotExists } from './modules/util.js';
export let options = {
noCookiesReset: true,
};
@ -28,7 +27,7 @@ export const setup = () => {
};
};
export default data => {
export default (data) => {
client.withOrgId(data.orgId);
group('API key test', () => {
@ -37,7 +36,7 @@ export default data => {
let res = client.datasources.getAll();
check(res, {
'response status is 200': r => r.status === 200,
'response status is 200': (r) => r.status === 200,
});
});
}
@ -69,7 +68,7 @@ export default data => {
let responses = client.batch(requests);
for (let n = 0; n < batchCount; n++) {
check(responses[n], {
'response status is 200': r => r.status === 200,
'response status is 200': (r) => r.status === 200,
});
}
});
@ -79,4 +78,4 @@ export default data => {
sleep(5);
};
export const teardown = data => {};
export const teardown = (data) => {};

View File

@ -21,7 +21,7 @@ export const setup = () => {
};
};
export default data => {
export default (data) => {
group('auth proxy test', () => {
group('batch proxy requests', () => {
const d = new Date();
@ -44,7 +44,7 @@ export default data => {
let responses = client.batch(requests);
for (let n = 0; n < batchCount; n++) {
check(responses[n], {
'response status is 200': r => r.status === 200,
'response status is 200': (r) => r.status === 200,
});
}
});
@ -53,4 +53,4 @@ export default data => {
sleep(5);
};
export const teardown = data => {};
export const teardown = (data) => {};

View File

@ -21,7 +21,7 @@ export const setup = () => {
};
};
export default data => {
export default (data) => {
client.withOrgId(data.orgId);
group(`user auth token slow test (queries between 1 and ${slowQuery} seconds)`, () => {
@ -30,8 +30,8 @@ export default data => {
let res = client.ui.login('admin', 'admin');
check(res, {
'response status is 200': r => r.status === 200,
"response has cookie 'grafana_session' with 32 characters": r =>
'response status is 200': (r) => r.status === 200,
"response has cookie 'grafana_session' with 32 characters": (r) =>
r.cookies.grafana_session[0].value.length === 32,
});
});
@ -65,7 +65,7 @@ export default data => {
let responses = client.batch(requests);
for (let n = 0; n < batchCount; n++) {
check(responses[n], {
'response status is 200': r => r.status === 200,
'response status is 200': (r) => r.status === 200,
});
}
});
@ -75,4 +75,4 @@ export default data => {
sleep(5);
};
export const teardown = data => {};
export const teardown = (data) => {};

View File

@ -21,7 +21,7 @@ export const setup = () => {
};
};
export default data => {
export default (data) => {
client.withOrgId(data.orgId);
group('user auth token test', () => {
@ -30,8 +30,8 @@ export default data => {
let res = client.ui.login('admin', 'admin');
check(res, {
'response status is 200': r => r.status === 200,
"response has cookie 'grafana_session' with 32 characters": r =>
'response status is 200': (r) => r.status === 200,
"response has cookie 'grafana_session' with 32 characters": (r) =>
r.cookies.grafana_session[0].value.length === 32,
});
});
@ -64,7 +64,7 @@ export default data => {
let responses = client.batch(requests);
for (let n = 0; n < batchCount; n++) {
check(responses[n], {
'response status is 200': r => r.status === 200,
'response status is 200': (r) => r.status === 200,
});
}
});
@ -74,4 +74,4 @@ export default data => {
sleep(5);
};
export const teardown = data => {};
export const teardown = (data) => {};

View File

@ -196,11 +196,11 @@ export class BearerAuthClient extends BaseClient {
beforeRequest(params) {
params = params || {};
params.headers = params.headers || {};
params.headers['Authorization'] = `Bearer ${this.token}`;
params.headers['Authorization'] = `Bearer ${this.token}`;
}
}
export const createClient = url => {
export const createClient = (url) => {
return new GrafanaClient(new BaseClient(url, ''));
};
@ -210,4 +210,4 @@ export const createBasicAuthClient = (url, username, password) => {
export const createBearerAuthClient = (url, token) => {
return new GrafanaClient(new BearerAuthClient(url, '', token));
}
};

View File

@ -1,4 +1,4 @@
export const createTestOrgIfNotExists = client => {
export const createTestOrgIfNotExists = (client) => {
let orgId = 0;
let res = client.orgs.getByName('k6');
@ -20,8 +20,7 @@ export const createTestOrgIfNotExists = client => {
return res.json().id;
};
export const createTestdataDatasourceIfNotExists = client => {
export const createTestdataDatasourceIfNotExists = (client) => {
const payload = {
access: 'proxy',
isDefault: false,

View File

@ -20,7 +20,7 @@ export function getAdminClient() {
let client = getAdminClient();
client.callAs = function(user) {
client.callAs = function (user) {
return getClient({
username: user.login,
password: 'password',

View File

@ -14,14 +14,9 @@ export const smokeTestScenario = {
e2e.components.DataSource.TestData.QueryTab.scenarioSelectContainer()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.should('be.visible')
.click();
e2e.components.Select.input().should('be.visible').click();
cy.contains('CSV Metric Values')
.scrollIntoView()
.should('be.visible')
.click();
cy.contains('CSV Metric Values').scrollIntoView().should('be.visible').click();
});
// Make sure the graph renders via checking legend

View File

@ -40,7 +40,7 @@ e2e.scenario({
e2e()
.get('.markdown-html li')
.should('have.length', 23)
.each(element => {
.each((element) => {
items.push(element.text());
})
.then(() => {

View File

@ -32,7 +32,7 @@ e2e.scenario({
.labels()
.should('be.visible')
.last()
.should(element => {
.should((element) => {
timesInUtc[title] = element.text();
})
);
@ -43,18 +43,11 @@ e2e.scenario({
e2e.components.TimeZonePicker.container()
.should('be.visible')
.within(() => {
e2e.components.Select.singleValue()
.should('be.visible')
.should('have.text', fromTimeZone);
e2e.components.Select.singleValue().should('be.visible').should('have.text', fromTimeZone);
e2e.components.Select.input()
.should('be.visible')
.click();
e2e.components.Select.input().should('be.visible').click();
e2e.components.Select.option()
.should('be.visible')
.contains(toTimeZone)
.click();
e2e.components.Select.option().should('be.visible').contains(toTimeZone).click();
});
e2e.components.BackButton.backArrow().click();
@ -67,7 +60,7 @@ e2e.scenario({
.labels()
.should('be.visible')
.last()
.should(element => {
.should((element) => {
const utc = timesInUtc[title];
const tz = element.text();
const isCorrect = isTimeCorrect(utc, tz, offset);
@ -81,14 +74,9 @@ e2e.scenario({
const isTimeCorrect = (utc: string, tz: string, offset: number): boolean => {
const minutes = 1000 * 60;
const a = Cypress.moment(utc, 'HH:mm')
.set('seconds', 0)
.set('milliseconds', 0);
const a = Cypress.moment(utc, 'HH:mm').set('seconds', 0).set('milliseconds', 0);
const b = Cypress.moment(tz, 'HH:mm')
.set('seconds', 0)
.set('milliseconds', 0)
.add('hours', offset);
const b = Cypress.moment(tz, 'HH:mm').set('seconds', 0).set('milliseconds', 0).add('hours', offset);
return a.diff(b, 'minutes') <= 6 * minutes;
};

View File

@ -14,14 +14,9 @@ e2e.scenario({
e2e.components.DataSource.TestData.QueryTab.scenarioSelectContainer()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.should('be.visible')
.click();
e2e.components.Select.input().should('be.visible').click();
cy.contains('CSV Metric Values')
.scrollIntoView()
.should('be.visible')
.click();
cy.contains('CSV Metric Values').scrollIntoView().should('be.visible').click();
});
const canvases = e2e().get('canvas');

View File

@ -13,10 +13,7 @@ e2e.scenario({
cy.wait(1000);
// check that gauges are rendered
e2e()
.get('body')
.find(`.flot-base`)
.should('have.length', 16);
e2e().get('body').find(`.flot-base`).should('have.length', 16);
// check that no panel errors exist
e2e.components.Panels.Panel.headerCornerInfo('error').should('not.exist');

View File

@ -10,7 +10,7 @@ e2e.scenario({
skipScenario: false,
scenario: () => {
// @ts-ignore some typing issue
e2e().on('uncaught:exception', err => {
e2e().on('uncaught:exception', (err) => {
if (err.stack?.indexOf("TypeError: Cannot read property 'getText' of null") !== -1) {
// On occasion monaco editor will not have the time to be properly unloaded when we change the tab
// and then the e2e test fails with the uncaught:exception:
@ -51,9 +51,7 @@ e2e.scenario({
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Edit, PANEL_UNDER_TEST);
e2e.components.QueryTab.queryInspectorButton()
.should('be.visible')
.click();
e2e.components.QueryTab.queryInspectorButton().should('be.visible').click();
e2e.components.Drawer.General.title(`Inspect: ${PANEL_UNDER_TEST}`)
.should('be.visible')
@ -82,25 +80,19 @@ const expectDrawerTabsAndContent = () => {
e2e.components.PanelInspector.Query.content().should('not.be.visible');
// other tabs should also be visible, click on each to see if we get any console errors
e2e.components.Tab.title('Stats')
.should('be.visible')
.click();
e2e.components.Tab.title('Stats').should('be.visible').click();
e2e.components.PanelInspector.Stats.content().should('be.visible');
e2e.components.PanelInspector.Data.content().should('not.be.visible');
e2e.components.PanelInspector.Json.content().should('not.be.visible');
e2e.components.PanelInspector.Query.content().should('not.be.visible');
e2e.components.Tab.title('JSON')
.should('be.visible')
.click();
e2e.components.Tab.title('JSON').should('be.visible').click();
e2e.components.PanelInspector.Json.content().should('be.visible');
e2e.components.PanelInspector.Data.content().should('not.be.visible');
e2e.components.PanelInspector.Stats.content().should('not.be.visible');
e2e.components.PanelInspector.Query.content().should('not.be.visible');
e2e.components.Tab.title('Query')
.should('be.visible')
.click();
e2e.components.Tab.title('Query').should('be.visible').click();
e2e.components.PanelInspector.Query.content().should('be.visible');
e2e.components.PanelInspector.Data.content().should('not.be.visible');
@ -142,10 +134,7 @@ const expectDrawerExpandAndContract = (viewPortWidth: number) => {
const expectSubMenuScenario = (subMenu: string, tabTitle?: string) => {
tabTitle = tabTitle ?? subMenu;
// testing opening inspect drawer from sub menus under Inspect in header menu
e2e.components.Panels.Panel.title(PANEL_UNDER_TEST)
.scrollIntoView()
.should('be.visible')
.click();
e2e.components.Panels.Panel.title(PANEL_UNDER_TEST).scrollIntoView().should('be.visible').click();
// sub menus are in the DOM but not visible and because there is no hover support in Cypress force click
// https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/testing-dom__hover-hidden-elements/cypress/integration/hover-hidden-elements-spec.js

View File

@ -31,22 +31,16 @@ e2e.scenario({
// Bottom pane tabs
// Can change to Transform tab
e2e.components.Tab.title('Transform')
.should('be.visible')
.click();
e2e.components.Tab.title('Transform').should('be.visible').click();
e2e.components.Tab.active().within((li: JQuery<HTMLLIElement>) => {
expect(li.text()).equals('Transform0'); // there's no transform so therefore Transform + 0
});
e2e.components.Transforms.card('Merge')
.scrollIntoView()
.should('be.visible');
e2e.components.Transforms.card('Merge').scrollIntoView().should('be.visible');
e2e.components.QueryTab.content().should('not.be.visible');
e2e.components.AlertTab.content().should('not.be.visible');
// Can change to Alerts tab (graph panel is the default vis so the alerts tab should be rendered)
e2e.components.Tab.title('Alert')
.should('be.visible')
.click();
e2e.components.Tab.title('Alert').should('be.visible').click();
e2e.components.Tab.active().within((li: JQuery<HTMLLIElement>) => {
expect(li.text()).equals('Alert0'); // there's no alert so therefore Alert + 0
});
@ -54,9 +48,7 @@ e2e.scenario({
e2e.components.QueryTab.content().should('not.be.visible');
e2e.components.TransformTab.content().should('not.exist');
e2e.components.Tab.title('Query')
.should('be.visible')
.click();
e2e.components.Tab.title('Query').should('be.visible').click();
});
// Panel sidebar is rendered open by default
@ -79,9 +71,7 @@ e2e.scenario({
e2e.components.PanelEditor.OptionsPane.content().should('be.visible');
// Can change visualisation type
e2e.components.OptionsGroup.toggle('Panel type')
.should('be.visible')
.click();
e2e.components.OptionsGroup.toggle('Panel type').should('be.visible').click();
// Check that Graph is chosen
e2e.components.PluginVisualization.item('Graph').should('be.visible');
@ -90,10 +80,7 @@ e2e.scenario({
});
// Change to Text panel
e2e.components.PluginVisualization.item('Text')
.scrollIntoView()
.should('be.visible')
.click();
e2e.components.PluginVisualization.item('Text').scrollIntoView().should('be.visible').click();
e2e.components.PluginVisualization.current().within((div: JQuery<HTMLDivElement>) => {
expect(div.text()).equals('Text');
});
@ -102,10 +89,7 @@ e2e.scenario({
e2e.components.PanelEditor.DataPane.content().should('not.be.visible');
// Change to Table panel
e2e.components.PluginVisualization.item('Table')
.scrollIntoView()
.should('be.visible')
.click();
e2e.components.PluginVisualization.item('Table').scrollIntoView().should('be.visible').click();
e2e.components.PluginVisualization.current().within((div: JQuery<HTMLDivElement>) => {
expect(div.text()).equals('Table');
});
@ -122,9 +106,7 @@ e2e.scenario({
e2e.components.OverridesConfigEditor.content().should('not.be.visible');
e2e.components.PanelEditor.OptionsPane.tab('Field').should('be.visible');
e2e.components.PanelEditor.OptionsPane.tab('Overrides')
.should('be.visible')
.click();
e2e.components.PanelEditor.OptionsPane.tab('Overrides').should('be.visible').click();
e2e.components.OverridesConfigEditor.content().should('be.visible');
e2e.components.FieldConfigEditor.content().should('not.be.visible');

View File

@ -21,7 +21,7 @@ e2e.scenario({
e2e.components.PanelEditor.DataPane.content().should('be.visible');
// We expect row with refId A to exist and be visible
e2e.components.QueryEditorRows.rows().within(rows => {
e2e.components.QueryEditorRows.rows().within((rows) => {
expect(rows.length).equals(1);
});
@ -34,37 +34,28 @@ e2e.scenario({
.as('apiPostQuery');
// Add query button should be visible and clicking on it should create a new row
e2e.components.QueryTab.addQuery()
.scrollIntoView()
.should('be.visible')
.click();
e2e.components.QueryTab.addQuery().scrollIntoView().should('be.visible').click();
// We expect row with refId A and B to exist and be visible
e2e.components.QueryEditorRows.rows().within(rows => {
e2e.components.QueryEditorRows.rows().within((rows) => {
expect(rows.length).equals(2);
});
// Remove refId A
e2e.components.QueryEditorRow.actionButton('Remove query')
.eq(0)
.should('be.visible')
.click();
e2e.components.QueryEditorRow.actionButton('Remove query').eq(0).should('be.visible').click();
e2e().wait('@apiPostQuery');
// We expect row with refId B to exist and be visible
e2e.components.QueryEditorRows.rows().within(rows => {
e2e.components.QueryEditorRows.rows().within((rows) => {
expect(rows.length).equals(1);
});
// Duplicate refId B
e2e.components.QueryEditorRow.actionButton('Duplicate query')
.eq(0)
.should('be.visible')
.click();
e2e.components.QueryEditorRow.actionButton('Duplicate query').eq(0).should('be.visible').click();
// We expect row with refId Band and A to exist and be visible
e2e.components.QueryEditorRows.rows().within(rows => {
e2e.components.QueryEditorRows.rows().within((rows) => {
expect(rows.length).equals(2);
});
@ -72,49 +63,36 @@ e2e.scenario({
e2e.components.DataSource.TestData.QueryTab.scenarioSelectContainer()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.eq(0)
.should('be.visible')
.click();
e2e.components.Select.input().eq(0).should('be.visible').click();
cy.contains('CSV Metric Values')
.scrollIntoView()
.should('be.visible')
.eq(0)
.click();
cy.contains('CSV Metric Values').scrollIntoView().should('be.visible').eq(0).click();
});
e2e().wait('@apiPostQuery');
// Disable / enable row
expectInspectorResultAndClose(keys => {
expectInspectorResultAndClose((keys) => {
const length = keys.length;
expect(keys[length - 2].innerText).equals('A:');
expect(keys[length - 1].innerText).equals('B:');
});
// Disable row with refId A
e2e.components.QueryEditorRow.actionButton('Disable/enable query')
.eq(1)
.should('be.visible')
.click();
e2e.components.QueryEditorRow.actionButton('Disable/enable query').eq(1).should('be.visible').click();
e2e().wait('@apiPostQuery');
expectInspectorResultAndClose(keys => {
expectInspectorResultAndClose((keys) => {
const length = keys.length;
expect(keys[length - 1].innerText).equals('B:');
});
// Enable row with refId B
e2e.components.QueryEditorRow.actionButton('Disable/enable query')
.eq(1)
.should('be.visible')
.click();
e2e.components.QueryEditorRow.actionButton('Disable/enable query').eq(1).should('be.visible').click();
e2e().wait('@apiPostQuery');
expectInspectorResultAndClose(keys => {
expectInspectorResultAndClose((keys) => {
const length = keys.length;
expect(keys[length - 2].innerText).equals('A:');
expect(keys[length - 1].innerText).equals('B:');
@ -123,13 +101,9 @@ e2e.scenario({
});
const expectInspectorResultAndClose = (expectCallBack: (keys: any[]) => void) => {
e2e.components.QueryTab.queryInspectorButton()
.should('be.visible')
.click();
e2e.components.QueryTab.queryInspectorButton().should('be.visible').click();
e2e.components.PanelInspector.Query.refreshButton()
.should('be.visible')
.click();
e2e.components.PanelInspector.Query.refreshButton().should('be.visible').click();
e2e().wait('@apiPostQuery');
@ -137,7 +111,5 @@ const expectInspectorResultAndClose = (expectCallBack: (keys: any[]) => void) =>
.should('be.visible')
.within((keys: any) => expectCallBack(keys));
e2e.components.Drawer.General.close()
.should('be.visible')
.click();
e2e.components.Drawer.General.close().should('be.visible').click();
};

View File

@ -13,13 +13,9 @@ e2e.scenario({
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Edit, PANEL_UNDER_TEST);
e2e.components.Tab.title('Transform')
.should('be.visible')
.click();
e2e.components.Tab.title('Transform').should('be.visible').click();
e2e.components.TransformTab.newTransform('Reduce')
.should('be.visible')
.click();
e2e.components.TransformTab.newTransform('Reduce').should('be.visible').click();
e2e.components.Transforms.Reduce.calculationsLabel().should('be.visible');
},

View File

@ -11,21 +11,13 @@ e2e.scenario({
e2e.components.DataSourcePicker.container()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.should('be.visible')
.click();
e2e.components.Select.input().should('be.visible').click();
cy.contains('gdev-prometheus')
.scrollIntoView()
.should('be.visible')
.click();
cy.contains('gdev-prometheus').scrollIntoView().should('be.visible').click();
});
const queryText = 'http_requests_total';
e2e.components.QueryField.container()
.should('be.visible')
.type(queryText)
.type('{backspace}');
e2e.components.QueryField.container().should('be.visible').type(queryText).type('{backspace}');
cy.contains(queryText.slice(0, -1)).should('be.visible');

View File

@ -13,18 +13,11 @@ e2e.scenario({
e2e.components.FolderPicker.container()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.should('be.visible')
.click();
e2e.components.Select.input().should('be.visible').click();
e2e.components.Select.option()
.should('be.visible')
.first()
.click();
e2e.components.Select.option().should('be.visible').first().click();
e2e.components.Select.input()
.should('be.visible')
.should('have.focus');
e2e.components.Select.input().should('be.visible').should('have.focus');
});
e2e.pages.Dashboard.Settings.General.title().click();
@ -32,9 +25,7 @@ e2e.scenario({
e2e.components.FolderPicker.container()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.should('be.visible')
.should('not.have.focus');
e2e.components.Select.input().should('be.visible').should('not.have.focus');
});
},
});

View File

@ -10,8 +10,6 @@ e2e.scenario({
// open Panel Tests - Bar Gauge
e2e.pages.SoloPanel.visit('ZqZnVvFZz/datasource-tests-shared-queries?orgId=1&panelId=4');
e2e()
.get('canvas')
.should('have.length', 6);
e2e().get('canvas').should('have.length', 6);
},
});

View File

@ -28,7 +28,7 @@ e2e.scenario({
const verifyLinks = (variableValue: string) => {
e2e.components.DashboardLinks.link()
.should('be.visible')
.and(links => {
.and((links) => {
expect(links).to.have.length.greaterThan(13);
for (let index = 0; index < links.length; index++) {
@ -46,20 +46,13 @@ e2e.scenario({
// verify all links, should have All value
verifyLinks('All');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('p2')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('p2').should('be.visible').click();
e2e.pages.Dashboard.Toolbar.navBar().click();
e2e.components.DashboardLinks.dropDown()
.should('be.visible')
.click()
.wait('@tagsTemplatingSearch');
e2e.components.DashboardLinks.dropDown().should('be.visible').click().wait('@tagsTemplatingSearch');
// verify all links, should have p2 value
verifyLinks('p2');

View File

@ -16,16 +16,12 @@ describe('Variables - Load options from Url', () => {
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -33,16 +29,12 @@ describe('Variables - Load options from Url', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('B').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('C').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AA')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AA').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -50,16 +42,12 @@ describe('Variables - Load options from Url', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('AB').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('AC').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -81,16 +69,12 @@ describe('Variables - Load options from Url', () => {
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('B')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('B').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -98,16 +82,12 @@ describe('Variables - Load options from Url', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('B').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('C').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BB')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BB').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -115,16 +95,12 @@ describe('Variables - Load options from Url', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BB').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BC').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BBB')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BBB').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -136,7 +112,7 @@ describe('Variables - Load options from Url', () => {
it('options set in url that do not exist should load correct options', () => {
e2e.flows.login('admin', 'admin');
// @ts-ignore some typing issue
e2e().on('uncaught:exception', err => {
e2e().on('uncaught:exception', (err) => {
if (err.stack?.indexOf("Couldn't find any field of type string in the results.") !== -1) {
// return false to prevent the error from
// failing this test
@ -157,16 +133,12 @@ describe('Variables - Load options from Url', () => {
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('X')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('X').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -174,26 +146,18 @@ describe('Variables - Load options from Url', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('B').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('C').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AA')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AA').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 0);
e2e().get('.variable-option').should('have.length', 0);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 0);
e2e().get('.variable-option').should('have.length', 0);
});
});
});

View File

@ -7,63 +7,59 @@ describe('Variables - Add variable', () => {
e2e.flows.login('admin', 'admin');
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?editview=templating` });
e2e.pages.Dashboard.Settings.Variables.List.newButton()
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.Variables.List.newButton().should('be.visible').click();
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInput()
.should('be.visible')
.within(input => {
.within((input) => {
expect(input.attr('placeholder')).equals('name');
expect(input.val()).equals('query0');
});
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelect()
.should('be.visible')
.within(select => {
e2e.components.Select.singleValue()
.should('be.visible')
.should('have.text', 'Query');
.within((select) => {
e2e.components.Select.singleValue().should('be.visible').should('have.text', 'Query');
});
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInput()
.should('be.visible')
.within(input => {
.within((input) => {
expect(input.attr('placeholder')).equals('optional display name');
expect(input.val()).equals('');
});
e2e()
.get('#Description')
.should('be.visible')
.within(input => {
.within((input) => {
expect(input.attr('placeholder')).equals('descriptive text');
expect(input.val()).equals('');
});
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalHideSelect()
.should('be.visible')
.within(select => {
.within((select) => {
e2e.components.Select.singleValue().should('have.text', '');
});
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect()
.should('be.visible')
.within(select => {
.within((select) => {
e2e.components.Select.singleValue().should('have.text', 'gdev-testdata');
});
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsRefreshSelect()
.should('be.visible')
.within(select => {
.within((select) => {
e2e.components.Select.singleValue().should('have.text', 'Never');
});
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsRegExInput()
.should('be.visible')
.within(input => {
.within((input) => {
const placeholder = '/.*-(?<text>.*)-(?<value>.*)-.*/';
expect(input.attr('placeholder')).equals(placeholder);
expect(input.val()).equals('');
});
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsSortSelect()
.should('be.visible')
.within(select => {
.within((select) => {
e2e.components.Select.singleValue().should('have.text', 'Disabled');
});
e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsMultiSwitch().should('not.be.checked');
@ -79,28 +75,19 @@ describe('Variables - Add variable', () => {
e2e.flows.login('admin', 'admin');
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?editview=templating` });
e2e.pages.Dashboard.Settings.Variables.List.newButton()
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.Variables.List.newButton().should('be.visible').click();
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInput()
.should('be.visible')
.clear()
.type('a label');
e2e()
.get('#Description')
.should('be.visible')
.clear()
.type('a description');
e2e().get('#Description').should('be.visible').clear().type('a description');
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.should('be.visible')
.type('gdev-testdata')
.type('{enter}');
e2e.components.Select.input().should('be.visible').type('gdev-testdata').type('{enter}');
});
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput()
@ -110,29 +97,20 @@ describe('Variables - Add variable', () => {
e2e.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption().should('exist');
e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton()
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().should('be.visible').click();
e2e().wait(500);
e2e.components.BackButton.backArrow()
.should('be.visible')
.click({ force: true });
e2e.components.BackButton.backArrow().should('be.visible').click({ force: true });
e2e.pages.Dashboard.SubMenu.submenuItemLabels('a label').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A')
.eq(1)
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A').eq(1).should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 3);
e2e().get('.variable-option').should('have.length', 3);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('A').should('be.visible');
@ -144,28 +122,19 @@ describe('Variables - Add variable', () => {
e2e.flows.login('admin', 'admin');
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?editview=templating` });
e2e.pages.Dashboard.Settings.Variables.List.newButton()
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.Variables.List.newButton().should('be.visible').click();
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInput()
.should('be.visible')
.clear()
.type('a label');
e2e()
.get('#Description')
.should('be.visible')
.clear()
.type('a description');
e2e().get('#Description').should('be.visible').clear().type('a description');
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect()
.should('be.visible')
.within(() => {
e2e.components.Select.input()
.should('be.visible')
.type('gdev-testdata')
.type('{enter}');
e2e.components.Select.input().should('be.visible').type('gdev-testdata').type('{enter}');
});
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput()
@ -181,36 +150,27 @@ describe('Variables - Add variable', () => {
.click({ force: true })
.should('be.checked');
e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsCustomAllInput().within(input => {
e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsCustomAllInput().within((input) => {
expect(input.attr('placeholder')).equals('blank = auto');
expect(input.val()).equals('');
});
e2e.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption().should('exist');
e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton()
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().should('be.visible').click();
e2e().wait(500);
e2e.components.BackButton.backArrow()
.should('be.visible')
.click({ force: true });
e2e.components.BackButton.backArrow().should('be.visible').click({ force: true });
e2e.pages.Dashboard.SubMenu.submenuItemLabels('a label').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A')
.eq(1)
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A').eq(1).should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');

View File

@ -16,37 +16,24 @@ describe('Variables - Set options from ui', () => {
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('A')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('B')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('A').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('B').should('be.visible').click();
e2e.pages.Dashboard.Toolbar.navBar().click();
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('B')
.scrollIntoView()
.should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('B').scrollIntoView().should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').should('have.length', 2);
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All')
.eq(0)
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').eq(0).should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -54,16 +41,12 @@ describe('Variables - Set options from ui', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BB').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BC').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('All').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 10);
e2e().get('.variable-option').should('have.length', 10);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -91,32 +74,22 @@ describe('Variables - Set options from ui', () => {
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('B')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('B').should('be.visible').click();
e2e.pages.Dashboard.Toolbar.navBar().click();
e2e().wait('@query');
e2e().wait(500);
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A + B')
.scrollIntoView()
.should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A + B').scrollIntoView().should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AA')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AA').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 7);
e2e().get('.variable-option').should('have.length', 7);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -127,16 +100,12 @@ describe('Variables - Set options from ui', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BB').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BC').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AAA')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('AAA').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -160,32 +129,22 @@ describe('Variables - Set options from ui', () => {
e2e().wait('@query');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A + B')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('A')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('A + B').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('A').should('be.visible').click();
e2e.pages.Dashboard.Toolbar.navBar().click();
e2e().wait('@query');
e2e().wait(500);
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('B')
.scrollIntoView()
.should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('B').scrollIntoView().should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BB')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BB').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('All').should('be.visible');
@ -193,16 +152,12 @@ describe('Variables - Set options from ui', () => {
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BB').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BC').should('be.visible');
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BBB')
.should('be.visible')
.click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts('BBB').should('be.visible').click();
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownDropDown()
.should('be.visible')
.within(() => {
e2e()
.get('.variable-option')
.should('have.length', 4);
e2e().get('.variable-option').should('have.length', 4);
});
e2e.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts('BBA').should('be.visible');

View File

@ -2,8 +2,8 @@ import { e2e } from '@grafana/e2e';
const PAGE_UNDER_TEST = 'AejrN1AMz';
describe('TextBox - load options scenarios', function() {
it('default options should be correct', function() {
describe('TextBox - load options scenarios', function () {
it('default options should be correct', function () {
e2e.flows.login('admin', 'admin');
e2e.flows.openDashboard({ uid: PAGE_UNDER_TEST });
e2e().server();
@ -19,7 +19,7 @@ describe('TextBox - load options scenarios', function() {
validateTextboxAndMarkup('default value');
});
it('loading variable from url should be correct', function() {
it('loading variable from url should be correct', function () {
e2e.flows.login('admin', 'admin');
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?var-text=not default value` });
e2e().server();
@ -36,15 +36,13 @@ describe('TextBox - load options scenarios', function() {
});
});
describe.skip('TextBox - change query scenarios', function() {
it('when changing the query value and not saving current as default should revert query value', function() {
describe.skip('TextBox - change query scenarios', function () {
it('when changing the query value and not saving current as default should revert query value', function () {
copyExistingDashboard();
changeQueryInput();
e2e.components.BackButton.backArrow()
.should('be.visible')
.click({ force: true });
e2e.components.BackButton.backArrow().should('be.visible').click({ force: true });
validateTextboxAndMarkup('changed value');
@ -65,14 +63,12 @@ describe.skip('TextBox - change query scenarios', function() {
});
});
it('when changing the query value and saving current as default should change query value', function() {
it('when changing the query value and saving current as default should change query value', function () {
copyExistingDashboard();
changeQueryInput();
e2e.components.BackButton.backArrow()
.should('be.visible')
.click({ force: true });
e2e.components.BackButton.backArrow().should('be.visible').click({ force: true });
validateTextboxAndMarkup('changed value');
@ -94,8 +90,8 @@ describe.skip('TextBox - change query scenarios', function() {
});
});
describe.skip('TextBox - change picker value scenarios', function() {
it('when changing the input value and not saving current as default should revert query value', function() {
describe.skip('TextBox - change picker value scenarios', function () {
it('when changing the input value and not saving current as default should revert query value', function () {
copyExistingDashboard();
changeTextBoxInput();
@ -118,7 +114,7 @@ describe.skip('TextBox - change picker value scenarios', function() {
});
});
it('when changing the input value and saving current as default should change query value', function() {
it('when changing the input value and saving current as default should change query value', function () {
copyExistingDashboard();
changeTextBoxInput();
@ -167,17 +163,11 @@ function copyExistingDashboard() {
e2e().wait('@dash-settings');
e2e.pages.Dashboard.Settings.General.saveAsDashBoard()
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.General.saveAsDashBoard().should('be.visible').click();
e2e.pages.SaveDashboardAsModal.newName()
.should('be.visible')
.type(`${Date.now()}`);
e2e.pages.SaveDashboardAsModal.newName().should('be.visible').type(`${Date.now()}`);
e2e.pages.SaveDashboardAsModal.save()
.should('be.visible')
.click();
e2e.pages.SaveDashboardAsModal.save().should('be.visible').click();
e2e().wait('@save-dash');
e2e().wait('@load-dash');
@ -186,30 +176,22 @@ function copyExistingDashboard() {
e2e()
.location()
.then(loc => {
.then((loc) => {
const dashuid = /\/d\/(\w+)\//.exec(loc.href)![1];
e2e()
.wrap(dashuid)
.as('dashuid');
e2e().wrap(dashuid).as('dashuid');
});
e2e().wait(500);
}
function saveDashboard(saveVariables: boolean) {
e2e.pages.Dashboard.Toolbar.toolbarItems('Save dashboard')
.should('be.visible')
.click();
e2e.pages.Dashboard.Toolbar.toolbarItems('Save dashboard').should('be.visible').click();
if (saveVariables) {
e2e.pages.SaveDashboardModal.saveVariables()
.should('exist')
.click({ force: true });
e2e.pages.SaveDashboardModal.saveVariables().should('exist').click({ force: true });
}
e2e.pages.SaveDashboardModal.save()
.should('be.visible')
.click();
e2e.pages.SaveDashboardModal.save().should('be.visible').click();
e2e().wait('@save-dash');
}
@ -219,34 +201,22 @@ function validateTextboxAndMarkup(value: string) {
.should('be.visible')
.within(() => {
e2e.pages.Dashboard.SubMenu.submenuItemLabels('text').should('be.visible');
e2e()
.get('input')
.should('be.visible')
.should('have.value', value);
e2e().get('input').should('be.visible').should('have.value', value);
});
e2e.components.Panels.Visualization.Text.container()
.should('be.visible')
.within(() => {
e2e()
.get('h1')
.should('be.visible')
.should('have.text', `variable: ${value}`);
e2e().get('h1').should('be.visible').should('have.text', `variable: ${value}`);
});
}
function validateVariable(value: string) {
e2e.pages.Dashboard.Toolbar.toolbarItems('Dashboard settings')
.should('be.visible')
.click();
e2e.pages.Dashboard.Toolbar.toolbarItems('Dashboard settings').should('be.visible').click();
e2e.pages.Dashboard.Settings.General.sectionItems('Variables')
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.General.sectionItems('Variables').should('be.visible').click();
e2e.pages.Dashboard.Settings.Variables.List.tableRowNameFields('text')
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.Variables.List.tableRowNameFields('text').should('be.visible').click();
e2e.pages.Dashboard.Settings.Variables.Edit.TextBoxVariable.textBoxOptionsQueryInput()
.should('be.visible')
@ -269,23 +239,17 @@ function changeTextBoxInput() {
e2e()
.location()
.should(loc => {
.should((loc) => {
expect(loc.search).to.contain('var-text=changed%20value');
});
}
function changeQueryInput() {
e2e.pages.Dashboard.Toolbar.toolbarItems('Dashboard settings')
.should('be.visible')
.click();
e2e.pages.Dashboard.Toolbar.toolbarItems('Dashboard settings').should('be.visible').click();
e2e.pages.Dashboard.Settings.General.sectionItems('Variables')
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.General.sectionItems('Variables').should('be.visible').click();
e2e.pages.Dashboard.Settings.Variables.List.tableRowNameFields('text')
.should('be.visible')
.click();
e2e.pages.Dashboard.Settings.Variables.List.tableRowNameFields('text').should('be.visible').click();
e2e.pages.Dashboard.Settings.Variables.Edit.TextBoxVariable.textBoxOptionsQueryInput()
.should('be.visible')

View File

@ -1,4 +1,4 @@
module.exports = function() {
module.exports = function () {
'use strict';
return {
options: {

View File

@ -1,4 +1,4 @@
module.exports = function(config) {
module.exports = function (config) {
return {
dist: ['dist'],
};

View File

@ -1,4 +1,4 @@
module.exports = function(grunt) {
module.exports = function (grunt) {
// load grunt config
require('load-grunt-config')(grunt);
};

View File

@ -31,7 +31,7 @@
"packages:clean": "lerna run clean",
"precommit": "yarn run lint-staged",
"prettier:check": "prettier --list-different \"**/*.{ts,tsx,scss}\"",
"prettier:write": "prettier --list-different \"**/*.{ts,tsx,scss}\" --write",
"prettier:write": "prettier --list-different \"**/*.{ts,tsx,scss,js}\" --write",
"start": "grafana-toolkit core:start --watchTheme",
"start:hot": "grafana-toolkit core:start --hot --watchTheme",
"start:ignoreTheme": "grafana-toolkit core:start --hot",
@ -76,7 +76,7 @@
"@emotion/core": "10.0.27",
"@grafana/api-documenter": "7.11.2",
"@grafana/api-extractor": "7.10.1",
"@grafana/eslint-config": "2.0.6",
"@grafana/eslint-config": "2.1.1",
"@rtsao/plugin-proposal-class-properties": "7.0.1-patch.1",
"@testing-library/jest-dom": "5.11.5",
"@testing-library/react": "11.1.2",
@ -138,10 +138,10 @@
"es6-promise": "4.2.8",
"es6-shim": "0.35.5",
"eslint": "^7.14.0",
"eslint-config-prettier": "6.11.0",
"eslint-config-prettier": "7.2.0",
"eslint-plugin-jsdoc": "28.6.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-prettier": "3.3.1",
"eslint-plugin-react": "7.21.5",
"eslint-plugin-react-hooks": "4.1.2",
"expect.js": "0.3.1",
@ -172,7 +172,7 @@
"postcss-browser-reporter": "0.6.0",
"postcss-loader": "3.0.0",
"postcss-reporter": "6.0.1",
"prettier": "1.19.1",
"prettier": "2.2.1",
"react-hot-loader": "4.8.0",
"react-test-renderer": "16.12.0",
"redux-mock-store": "1.5.4",

View File

@ -14,15 +14,15 @@ describe('Array DataFrame', () => {
const frame = new ArrayDataFrame(input);
frame.name = 'Hello';
frame.refId = 'Z';
frame.setFieldType('phantom', FieldType.string, v => '🦥');
const field = frame.fields.find(f => f.name === 'value');
frame.setFieldType('phantom', FieldType.string, (v) => '🦥');
const field = frame.fields.find((f) => f.name === 'value');
field!.config.unit = 'kwh';
test('Should support functional methods', () => {
const expectedNames = input.map(row => row.name);
const expectedNames = input.map((row) => row.name);
// Check map
expect(frame.map(row => row.name)).toEqual(expectedNames);
expect(frame.map((row) => row.name)).toEqual(expectedNames);
let names: string[] = [];
for (const row of frame) {
@ -31,7 +31,7 @@ describe('Array DataFrame', () => {
expect(names).toEqual(expectedNames);
names = [];
frame.forEach(row => {
frame.forEach((row) => {
names.push(row.name);
});
expect(names).toEqual(expectedNames);

View File

@ -6,7 +6,7 @@ import { FunctionalVector } from '../vector/FunctionalVector';
export type ValueConverter<T = any> = (val: any) => T;
const NOOP: ValueConverter = v => v;
const NOOP: ValueConverter = (v) => v;
class ArrayPropertyVector<T = any> implements Vector<T> {
converter = NOOP;
@ -49,7 +49,7 @@ export class ArrayDataFrame<T = any> extends FunctionalVector<T> implements Data
this.length = source.length;
const first: any = source.length ? source[0] : {};
if (names) {
this.fields = names.map(name => {
this.fields = names.map((name) => {
return {
name,
type: guessFieldTypeFromNameAndValue(name, first[name]),
@ -66,7 +66,7 @@ export class ArrayDataFrame<T = any> extends FunctionalVector<T> implements Data
* Add a field for each property in the object. This will guess the type
*/
setFieldsFromObject(obj: any) {
this.fields = Object.keys(obj).map(name => {
this.fields = Object.keys(obj).map((name) => {
return {
name,
type: guessFieldTypeFromNameAndValue(name, obj[name]),
@ -80,7 +80,7 @@ export class ArrayDataFrame<T = any> extends FunctionalVector<T> implements Data
* Configure how the object property is passed to the data frame
*/
setFieldType(name: string, type: FieldType, converter?: ValueConverter): Field {
let field = this.fields.find(f => f.name === name);
let field = this.fields.find((f) => f.name === name);
if (field) {
field.type = type;
} else {

View File

@ -21,7 +21,7 @@ export interface ArrowDataFrame extends DataFrame {
export function base64StringToArrowTable(text: string): Table {
const b64 = atob(text);
const arr = Uint8Array.from(b64, c => {
const arr = Uint8Array.from(b64, (c) => {
return c.charCodeAt(0);
});
return Table.from(arr);

View File

@ -20,7 +20,7 @@ describe('FieldCache', () => {
const expectedFieldNames = ['time', 'string', 'number', 'boolean', 'other', 'undefined'];
expect(allFields.map(f => f.name)).toEqual(expectedFieldNames);
expect(allFields.map((f) => f.name)).toEqual(expectedFieldNames);
expect(fieldCache.hasFieldOfType(FieldType.time)).toBeTruthy();
expect(fieldCache.hasFieldOfType(FieldType.string)).toBeTruthy();
@ -28,11 +28,11 @@ describe('FieldCache', () => {
expect(fieldCache.hasFieldOfType(FieldType.boolean)).toBeTruthy();
expect(fieldCache.hasFieldOfType(FieldType.other)).toBeTruthy();
expect(fieldCache.getFields(FieldType.time).map(f => f.name)).toEqual([expectedFieldNames[0]]);
expect(fieldCache.getFields(FieldType.string).map(f => f.name)).toEqual([expectedFieldNames[1]]);
expect(fieldCache.getFields(FieldType.number).map(f => f.name)).toEqual([expectedFieldNames[2]]);
expect(fieldCache.getFields(FieldType.boolean).map(f => f.name)).toEqual([expectedFieldNames[3]]);
expect(fieldCache.getFields(FieldType.other).map(f => f.name)).toEqual([
expect(fieldCache.getFields(FieldType.time).map((f) => f.name)).toEqual([expectedFieldNames[0]]);
expect(fieldCache.getFields(FieldType.string).map((f) => f.name)).toEqual([expectedFieldNames[1]]);
expect(fieldCache.getFields(FieldType.number).map((f) => f.name)).toEqual([expectedFieldNames[2]]);
expect(fieldCache.getFields(FieldType.boolean).map((f) => f.name)).toEqual([expectedFieldNames[3]]);
expect(fieldCache.getFields(FieldType.other).map((f) => f.name)).toEqual([
expectedFieldNames[4],
expectedFieldNames[5],
]);

View File

@ -59,7 +59,7 @@ export class FieldCache {
getFirstFieldOfType(type: FieldType, includeHidden = false): FieldWithIndex | undefined {
const fields = this.fieldByType[type];
const firstField = fields.find(field => includeHidden || !field.config.custom?.hidden);
const firstField = fields.find((field) => includeHidden || !field.config.custom?.hidden);
return firstField;
}
@ -68,7 +68,7 @@ export class FieldCache {
}
hasFieldWithNameAndType(name: string, type: FieldType): boolean {
return !!this.fieldByName[name] && this.fieldByType[type].filter(field => field.name === name).length > 0;
return !!this.fieldByName[name] && this.fieldByType[type].filter((field) => field.name === name).length > 0;
}
/**
@ -82,7 +82,7 @@ export class FieldCache {
* Returns the fields with the given label.
*/
getFieldsByLabel(label: string, value: string): FieldWithIndex[] {
return Object.values(this.fieldByName).filter(f => {
return Object.values(this.fieldByName).filter((f) => {
return f.labels && f.labels[label] === value;
});
}

View File

@ -33,7 +33,7 @@ export const getValueFromDimension = (dimension: Dimension, column: number, row:
};
export const getAllValuesFromDimension = (dimension: Dimension, column: number, row: number) => {
return dimension.columns.map(c => c.values.get(row));
return dimension.columns.map((c) => c.values.get(row));
};
export const getDimensionByName = (dimensions: Dimensions, name: string) => dimensions[name];

View File

@ -35,8 +35,8 @@ export function compareDataFrameStructures(a: DataFrame, b: DataFrame, skipPrope
let bKeys = Object.keys(cfgB);
if (skipProperties) {
aKeys = aKeys.filter(k => skipProperties.indexOf(k) < 0);
bKeys = aKeys.filter(k => skipProperties.indexOf(k) < 0);
aKeys = aKeys.filter((k) => skipProperties.indexOf(k) < 0);
bKeys = aKeys.filter((k) => skipProperties.indexOf(k) < 0);
}
if (aKeys.length !== bKeys.length) {
return false;

View File

@ -85,7 +85,7 @@ describe('toDataFrame', () => {
expect(frame).toEqual(array);
expect(frame instanceof ArrayDataFrame).toEqual(true);
expect(frame.length).toEqual(orig.length);
expect(frame.fields.map(f => f.name)).toEqual(['a', 'b']);
expect(frame.fields.map((f) => f.name)).toEqual(['a', 'b']);
});
it('throws when table rows is not array', () => {
@ -276,7 +276,7 @@ describe('SeriesData backwards compatibility', () => {
expect(table.refId).toBe(series.refId);
expect(table.meta).toEqual(series.meta);
const names = table.columns.map(c => c.text);
const names = table.columns.map((c) => c.text);
expect(names).toEqual(['T', 'N', 'S']);
});

View File

@ -27,7 +27,7 @@ import { fieldIndexComparer } from '../field/fieldComparers';
import { vectorToArray } from '../vector/vectorToArray';
function convertTableToDataFrame(table: TableData): DataFrame {
const fields = table.columns.map(c => {
const fields = table.columns.map((c) => {
// TODO: should be Column but type does not exists there so not sure whats up here.
const { text, type, ...disp } = c as any;
return {
@ -257,7 +257,7 @@ export const guessFieldTypes = (series: DataFrame, guessDefined = false): DataFr
// Something is missing a type, return a modified copy
return {
...series,
fields: series.fields.map(field => {
fields: series.fields.map((field) => {
if (field.type && field.type !== FieldType.other && !guessDefined) {
return field;
}
@ -368,7 +368,7 @@ export const toLegacyResponseData = (frame: DataFrame): TimeSeries | TableData =
}
return {
columns: fields.map(f => {
columns: fields.map((f) => {
const { name, config } = f;
if (config) {
// keep unit etc
@ -402,7 +402,7 @@ export function sortDataFrame(data: DataFrame, sortIndex?: number, reverse = fal
return {
...data,
fields: data.fields.map(f => {
fields: data.fields.map((f) => {
return {
...f,
values: new SortedVector(f.values, index),
@ -417,7 +417,7 @@ export function sortDataFrame(data: DataFrame, sortIndex?: number, reverse = fal
export function reverseDataFrame(data: DataFrame): DataFrame {
return {
...data,
fields: data.fields.map(f => {
fields: data.fields.map((f) => {
const copy = [...f.values.toArray()];
copy.reverse();
return {
@ -443,7 +443,7 @@ export function getDataFrameRow(data: DataFrame, row: number): any[] {
* Returns a copy that does not include functions
*/
export function toDataFrameDTO(data: DataFrame): DataFrameDTO {
const fields: FieldDTO[] = data.fields.map(f => {
const fields: FieldDTO[] = data.fields.map((f) => {
let values = f.values.toArray();
// The byte buffers serialize like objects
if (values instanceof Float64Array) {

View File

@ -4,9 +4,9 @@ export const isTimeSerie = (frame: DataFrame): boolean => {
if (frame.fields.length > 2) {
return false;
}
return !!frame.fields.find(field => field.type === FieldType.time);
return !!frame.fields.find((field) => field.type === FieldType.time);
};
export const isTimeSeries = (data: DataFrame[]): boolean => {
return !data.find(frame => !isTimeSerie(frame));
return !data.find((frame) => !isTimeSerie(frame));
};

View File

@ -64,7 +64,7 @@ describe('DateMath', () => {
anchored = dateTime(anchor);
});
each(spans, span => {
each(spans, (span) => {
const nowEx = 'now-5' + span;
const thenEx = anchor + '||-5' + span;
@ -90,7 +90,7 @@ describe('DateMath', () => {
now = dateTime();
});
each(spans, span => {
each(spans, (span) => {
it('should round now to the beginning of the ' + span, () => {
expect(dateMath.parse('now/' + span)!.format(format)).toEqual(now.startOf(span).format(format));
});

View File

@ -111,7 +111,7 @@ export function localTimeFormat(
timeZoneName: 'Z',
};
return parts.map(part => mapping[part.type] || part.value).join('');
return parts.map((part) => mapping[part.type] || part.value).join('');
}
export const systemDateFormats = new SystemDateFormatsState();

View File

@ -88,7 +88,7 @@ export const getTimeZoneGroups = memoize((includeInternal = false): GroupedTimeZ
return groups;
}, {});
return Object.keys(groups).map(name => ({
return Object.keys(groups).map((name) => ({
name,
zones: groups[name],
}));

View File

@ -35,7 +35,7 @@ describe('EventBus', () => {
const bus = new EventBusSrv();
const events: LoginEvent[] = [];
bus.subscribe(LoginEvent, event => {
bus.subscribe(LoginEvent, (event) => {
events.push(event);
});
@ -69,11 +69,11 @@ describe('EventBus', () => {
const legacyEvents: any = [];
const newEvents: any = [];
bus.on(legacyEvent, event => {
bus.on(legacyEvent, (event) => {
legacyEvents.push(event);
});
bus.subscribe(AlertSuccessEvent, event => {
bus.subscribe(AlertSuccessEvent, (event) => {
newEvents.push(event);
});
@ -160,7 +160,7 @@ describe('EventBus', () => {
const bus = new EventBusSrv();
const events: LoginEvent[] = [];
bus.subscribe(LoginEvent, event => {
bus.subscribe(LoginEvent, (event) => {
events.push(event);
});

View File

@ -22,7 +22,7 @@ export class EventBusSrv implements EventBus, LegacyEmitter {
}
getStream<T extends BusEvent>(eventType: BusEventType<T>): Observable<T> {
return new Observable<T>(observer => {
return new Observable<T>((observer) => {
const handler = (event: T) => {
observer.next(event);
};

View File

@ -14,7 +14,7 @@ function getDisplayProcessorFromConfig(config: FieldConfig) {
}
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) {
processors.forEach(processor => {
processors.forEach((processor) => {
const value = processor(input);
for (const key of Object.keys(match)) {
expect((value as any)[key]).toEqual((match as any)[key]);

View File

@ -168,7 +168,7 @@ export class FieldColorSchemeMode implements FieldColorMode {
return this.colorCache;
}
this.colorCache = this.colors.map(c => getColorForTheme(c, theme));
this.colorCache = this.colors.map((c) => getColorForTheme(c, theme));
return this.colorCache;
}

View File

@ -35,7 +35,7 @@ describe('FieldDisplay', () => {
},
});
const display = getFieldDisplayValues(options);
expect(display.map(v => v.display.text)).toEqual(['1', '2']);
expect(display.map((v) => v.display.text)).toEqual(['1', '2']);
});
it('show last numeric values', () => {
@ -45,7 +45,7 @@ describe('FieldDisplay', () => {
},
});
const display = getFieldDisplayValues(options);
expect(display.map(v => v.display.numeric)).toEqual([5, 6]);
expect(display.map((v) => v.display.numeric)).toEqual([5, 6]);
});
it('show all numeric values', () => {
@ -57,7 +57,7 @@ describe('FieldDisplay', () => {
},
});
const display = getFieldDisplayValues(options);
expect(display.map(v => v.display.numeric)).toEqual([1, 3, 5, 2, 4, 6]);
expect(display.map((v) => v.display.numeric)).toEqual([1, 3, 5, 2, 4, 6]);
});
it('show 2 numeric values (limit)', () => {
@ -69,7 +69,7 @@ describe('FieldDisplay', () => {
},
});
const display = getFieldDisplayValues(options);
expect(display.map(v => v.display.numeric)).toEqual([1, 3]); // First 2 are from the first field
expect(display.map((v) => v.display.numeric)).toEqual([1, 3]); // First 2 are from the first field
});
it('Should return field thresholds when there is no data', () => {

View File

@ -244,7 +244,7 @@ describe('applyFieldOverrides', () => {
overrides: [],
},
fieldConfigRegistry: customFieldRegistry,
replaceVariables: v => v,
replaceVariables: (v) => v,
theme: getTestTheme(),
})[0];

View File

@ -107,7 +107,7 @@ export function applyFieldOverrides(options: ApplyFieldOverrideOptions): DataFra
__series: { text: 'Series', value: { name: getFrameDisplayName(frame, index) } }, // might be missing
};
const fields: Field[] = frame.fields.map(field => {
const fields: Field[] = frame.fields.map((field) => {
// Config is mutable within this scope
const fieldScopedVars = { ...scopedVars };
const displayName = getFieldDisplayName(field, frame, options.data);

View File

@ -10,7 +10,7 @@ export function getFrameDisplayName(frame: DataFrame, index?: number) {
}
// Single field with tags
const valuesWithLabels = frame.fields.filter(f => f.labels !== undefined);
const valuesWithLabels = frame.fields.filter((f) => f.labels !== undefined);
if (valuesWithLabels.length === 1) {
return formatLabels(valuesWithLabels[0].labels!);
}
@ -18,8 +18,8 @@ export function getFrameDisplayName(frame: DataFrame, index?: number) {
// list all the
if (index === undefined) {
return frame.fields
.filter(f => f.type !== FieldType.time)
.map(f => getFieldDisplayName(f, frame))
.filter((f) => f.type !== FieldType.time)
.map((f) => getFieldDisplayName(f, frame))
.join(', ');
}

View File

@ -21,7 +21,7 @@ export function getFieldDisplayValuesProxy(
return new Proxy({} as Record<string, DisplayValue>, {
get: (obj: any, key: string) => {
// 1. Match the name
let field = frame.fields.find(f => key === f.name);
let field = frame.fields.find((f) => key === f.name);
if (!field) {
// 2. Match the array index
const k = toNumber(key);
@ -29,7 +29,7 @@ export function getFieldDisplayValuesProxy(
}
if (!field) {
// 3. Match the title
field = frame.fields.find(f => key === f.config.displayName);
field = frame.fields.find((f) => key === f.config.displayName);
}
if (!field) {
return undefined;

View File

@ -26,9 +26,7 @@ export function getTemplateProxyForField(field: Field, frame?: DataFrame, frames
}
return {
...field.labels,
__values: Object.values(field.labels)
.sort()
.join(', '),
__values: Object.values(field.labels).sort().join(', '),
toString: () => {
return formatLabels(field.labels!, '', true);
},

View File

@ -13,7 +13,7 @@ describe('thresholds', () => {
],
mode: ThresholdsMode.Absolute,
};
const sorted = sortThresholds(thresholds.steps).map(t => t.value);
const sorted = sortThresholds(thresholds.steps).map((t) => t.value);
expect(sorted).toEqual([1, 10, 100]);
const config: FieldConfig = { thresholds };

View File

@ -33,7 +33,7 @@ describe('PanelPlugin', () => {
});
panel.useFieldConfig({
useCustomConfig: builder => {
useCustomConfig: (builder) => {
builder.addCustomEditor({
id: 'custom',
path: 'custom',
@ -58,7 +58,7 @@ describe('PanelPlugin', () => {
return <div>Panel</div>;
});
panel.setPanelOptions(builder => {
panel.setPanelOptions((builder) => {
builder.addCustomEditor({
id: 'option',
path: 'option',
@ -82,7 +82,7 @@ describe('PanelPlugin', () => {
return <div>Panel</div>;
});
panel.setPanelOptions(builder => {
panel.setPanelOptions((builder) => {
builder
.addNumberInput({
path: 'numericOption',
@ -120,7 +120,7 @@ describe('PanelPlugin', () => {
return <div>Panel</div>;
});
panel.setPanelOptions(builder => {
panel.setPanelOptions((builder) => {
builder.addNumberInput({
path: 'numericOption.nested',
name: 'Option editor',
@ -144,7 +144,7 @@ describe('PanelPlugin', () => {
});
panel.useFieldConfig({
useCustomConfig: builder => {
useCustomConfig: (builder) => {
builder
.addNumberInput({
path: 'numericOption',
@ -188,7 +188,7 @@ describe('PanelPlugin', () => {
});
panel.useFieldConfig({
useCustomConfig: builder => {
useCustomConfig: (builder) => {
builder.addNumberInput({
path: 'numericOption.nested',
name: 'Option editor',

View File

@ -82,9 +82,10 @@ export interface SetFieldConfigOptionsArgs<TFieldConfigOptions = any> {
useCustomConfig?: (builder: FieldConfigEditorBuilder<TFieldConfigOptions>) => void;
}
export class PanelPlugin<TOptions = any, TFieldConfigOptions extends object = any> extends GrafanaPlugin<
PanelPluginMeta
> {
export class PanelPlugin<
TOptions = any,
TFieldConfigOptions extends object = any
> extends GrafanaPlugin<PanelPluginMeta> {
private _defaults?: TOptions;
private _fieldConfigDefaults: FieldConfigSource<TFieldConfigOptions> = {
defaults: {},

View File

@ -36,9 +36,5 @@ export function hasAnsiCodes(input: string): boolean {
}
export function escapeHtml(str: string): string {
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

View File

@ -46,7 +46,7 @@ describe('Stats Calculators', () => {
const stats = fieldReducers.list(names);
expect(stats.length).toBe(2);
const found = stats.map(v => v.id);
const found = stats.map((v) => v.id);
const notFound = difference(names, found);
expect(notFound.length).toBe(2);

View File

@ -11,7 +11,7 @@ const anyFieldMatcher: FieldMatcherInfo<MatcherConfig[]> = {
defaultOptions: [], // empty array
get: (options: MatcherConfig[]) => {
const children = options.map(option => {
const children = options.map((option) => {
return getFieldMatcher(option);
});
return (field: Field, frame: DataFrame, allFrames: DataFrame[]) => {
@ -45,7 +45,7 @@ const anyFrameMatcher: FrameMatcherInfo<MatcherConfig[]> = {
defaultOptions: [], // empty array
get: (options: MatcherConfig[]) => {
const children = options.map(option => {
const children = options.map((option) => {
return getFrameMatchers(option);
});
return (frame: DataFrame) => {
@ -79,7 +79,7 @@ const allFieldsMatcher: FieldMatcherInfo<MatcherConfig[]> = {
defaultOptions: [], // empty array
get: (options: MatcherConfig[]) => {
const children = options.map(option => {
const children = options.map((option) => {
return getFieldMatcher(option);
});
return (field: Field, frame: DataFrame, allFrames: DataFrame[]) => {
@ -113,7 +113,7 @@ const allFramesMatcher: FrameMatcherInfo<MatcherConfig[]> = {
defaultOptions: [], // empty array
get: (options: MatcherConfig[]) => {
const children = options.map(option => {
const children = options.map((option) => {
return getFrameMatchers(option);
});
return (frame: DataFrame) => {

View File

@ -25,7 +25,7 @@ const firstTimeFieldMatcher: FieldMatcherInfo = {
get: (type: FieldType) => {
return (field: Field, frame: DataFrame, allFrames: DataFrame[]) => {
return field.type === FieldType.time && field === frame.fields.find(f => f.type === FieldType.time);
return field.type === FieldType.time && field === frame.fields.find((f) => f.type === FieldType.time);
};
},

View File

@ -7,7 +7,7 @@ const isEqualValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions> = {
id: ValueMatcherID.equal,
name: 'Is equal',
description: 'Match where value for given field is equal to options value.',
get: options => {
get: (options) => {
return (valueIndex: number, field: Field) => {
const value = field.values.get(valueIndex);
// eslint-disable-next-line eqeqeq
@ -25,7 +25,7 @@ const isNotEqualValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions> = {
id: ValueMatcherID.notEqual,
name: 'Is not equal',
description: 'Match where value for given field is not equal to options value.',
get: options => {
get: (options) => {
return (valueIndex: number, field: Field) => {
const value = field.values.get(valueIndex);
// eslint-disable-next-line eqeqeq

View File

@ -7,7 +7,7 @@ const isGreaterValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<number>>
id: ValueMatcherID.greater,
name: 'Is greater',
description: 'Match when field value is greater than option.',
get: options => {
get: (options) => {
return (valueIndex: number, field: Field) => {
const value = field.values.get(valueIndex);
if (isNaN(value)) {
@ -16,10 +16,10 @@ const isGreaterValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<number>>
return value > options.value;
};
},
getOptionsDisplayText: options => {
getOptionsDisplayText: (options) => {
return `Matches all rows where field value is greater than: ${options.value}.`;
},
isApplicable: field => field.type === FieldType.number,
isApplicable: (field) => field.type === FieldType.number,
getDefaultOptions: () => ({ value: 0 }),
};
@ -27,7 +27,7 @@ const isGreaterOrEqualValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<nu
id: ValueMatcherID.greaterOrEqual,
name: 'Is greater or equal',
description: 'Match when field value is lower or greater than option.',
get: options => {
get: (options) => {
return (valueIndex: number, field: Field) => {
const value = field.values.get(valueIndex);
if (isNaN(value)) {
@ -36,10 +36,10 @@ const isGreaterOrEqualValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<nu
return value >= options.value;
};
},
getOptionsDisplayText: options => {
getOptionsDisplayText: (options) => {
return `Matches all rows where field value is lower or greater than: ${options.value}.`;
},
isApplicable: field => field.type === FieldType.number,
isApplicable: (field) => field.type === FieldType.number,
getDefaultOptions: () => ({ value: 0 }),
};
@ -47,7 +47,7 @@ const isLowerValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<number>> =
id: ValueMatcherID.lower,
name: 'Is lower',
description: 'Match when field value is lower than option.',
get: options => {
get: (options) => {
return (valueIndex: number, field: Field) => {
const value = field.values.get(valueIndex);
if (isNaN(value)) {
@ -56,10 +56,10 @@ const isLowerValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<number>> =
return value < options.value;
};
},
getOptionsDisplayText: options => {
getOptionsDisplayText: (options) => {
return `Matches all rows where field value is lower than: ${options.value}.`;
},
isApplicable: field => field.type === FieldType.number,
isApplicable: (field) => field.type === FieldType.number,
getDefaultOptions: () => ({ value: 0 }),
};
@ -67,7 +67,7 @@ const isLowerOrEqualValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<numb
id: ValueMatcherID.lowerOrEqual,
name: 'Is lower or equal',
description: 'Match when field value is lower or equal than option.',
get: options => {
get: (options) => {
return (valueIndex: number, field: Field) => {
const value = field.values.get(valueIndex);
if (isNaN(value)) {
@ -76,10 +76,10 @@ const isLowerOrEqualValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<numb
return value <= options.value;
};
},
getOptionsDisplayText: options => {
getOptionsDisplayText: (options) => {
return `Matches all rows where field value is lower or equal than: ${options.value}.`;
},
isApplicable: field => field.type === FieldType.number,
isApplicable: (field) => field.type === FieldType.number,
getDefaultOptions: () => ({ value: 0 }),
};

View File

@ -7,7 +7,7 @@ const isBetweenValueMatcher: ValueMatcherInfo<RangeValueMatcherOptions<number>>
id: ValueMatcherID.between,
name: 'Is between',
description: 'Match when field value is between given option values.',
get: options => {
get: (options) => {
return (valueIndex: number, field: Field) => {
const value = field.values.get(valueIndex);
if (isNaN(value)) {
@ -16,10 +16,10 @@ const isBetweenValueMatcher: ValueMatcherInfo<RangeValueMatcherOptions<number>>
return value > options.from && value < options.to;
};
},
getOptionsDisplayText: options => {
getOptionsDisplayText: (options) => {
return `Matches all rows where field value is between ${options.from} and ${options.to}.`;
},
isApplicable: field => field.type === FieldType.number,
isApplicable: (field) => field.type === FieldType.number,
getDefaultOptions: () => ({ from: 0, to: 100 }),
};

View File

@ -7,7 +7,7 @@ const regexValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<string>> = {
id: ValueMatcherID.regex,
name: 'Regex',
description: 'Match when field value is matching regex.',
get: options => {
get: (options) => {
const regex = new RegExp(options.value);
return (valueIndex: number, field: Field) => {
@ -15,7 +15,7 @@ const regexValueMatcher: ValueMatcherInfo<BasicValueMatcherOptions<string>> = {
return regex.test(value);
};
},
getOptionsDisplayText: options => {
getOptionsDisplayText: (options) => {
return `Matches all rows where field value is matching regex: ${options.value}`;
},
isApplicable: () => true,

View File

@ -4,7 +4,7 @@ import { map, mergeMap } from 'rxjs/operators';
import { DataFrame, DataTransformerConfig } from '../types';
import { standardTransformersRegistry, TransformerRegistyItem } from './standardTransformersRegistry';
const getOperator = (config: DataTransformerConfig): MonoTypeOperatorFunction<DataFrame[]> => source => {
const getOperator = (config: DataTransformerConfig): MonoTypeOperatorFunction<DataFrame[]> => (source) => {
const info = standardTransformersRegistry.get(config.id);
if (!info) {
@ -15,16 +15,16 @@ const getOperator = (config: DataTransformerConfig): MonoTypeOperatorFunction<Da
const options = { ...defaultOptions, ...config.options };
return source.pipe(
mergeMap(before => of(before).pipe(info.transformation.operator(options), postProcessTransform(before, info)))
mergeMap((before) => of(before).pipe(info.transformation.operator(options), postProcessTransform(before, info)))
);
};
const postProcessTransform = (
before: DataFrame[],
info: TransformerRegistyItem<any>
): MonoTypeOperatorFunction<DataFrame[]> => source =>
): MonoTypeOperatorFunction<DataFrame[]> => (source) =>
source.pipe(
map(after => {
map((after) => {
if (after === before) {
return after;
}

View File

@ -38,7 +38,7 @@ describe('calculateField transformer w/ timeseries', () => {
},
};
await expect(transformDataFrame([cfg], [seriesA, seriesBC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesBC])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
const rows = new DataFrameView(filtered).toArray();
@ -75,7 +75,7 @@ describe('calculateField transformer w/ timeseries', () => {
},
};
await expect(transformDataFrame([cfg], [seriesA, seriesBC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesBC])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
const rows = new DataFrameView(filtered).toArray();
@ -105,7 +105,7 @@ describe('calculateField transformer w/ timeseries', () => {
},
};
await expect(transformDataFrame([cfg], [seriesBC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesBC])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
const rows = new DataFrameView(filtered).toArray();
@ -136,7 +136,7 @@ describe('calculateField transformer w/ timeseries', () => {
},
};
await expect(transformDataFrame([cfg], [seriesBC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesBC])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
const rows = new DataFrameView(filtered).toArray();
@ -167,7 +167,7 @@ describe('calculateField transformer w/ timeseries', () => {
},
};
await expect(transformDataFrame([cfg], [seriesBC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesBC])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
const rows = new DataFrameView(filtered).toArray();

View File

@ -70,13 +70,13 @@ export const calculateFieldTransformer: DataTransformerInfo<CalculateFieldTransf
reducer: ReducerID.sum,
},
},
operator: options => outerSource => {
operator: (options) => (outerSource) => {
const operator =
options && options.timeSeries !== false ? ensureColumnsTransformer.operator(null) : noopTransformer.operator({});
return outerSource.pipe(
operator,
map(data => {
map((data) => {
const mode = options.mode ?? CalculateFieldMode.ReduceRow;
let creator: ValuesCreator | undefined = undefined;
@ -91,7 +91,7 @@ export const calculateFieldTransformer: DataTransformerInfo<CalculateFieldTransf
return data;
}
return data.map(frame => {
return data.map((frame) => {
// delegate field creation to the specific function
const values = creator!(frame);
if (!values) {

View File

@ -23,7 +23,7 @@ describe('Concat Transformer', () => {
it('dropping frame name', () => {
const frame = concatenateFields([simpleABC, simpleXYZ], { frameNameMode: ConcatenateFrameNameMode.Drop });
expect(frame.length).toBe(3);
expect(frame.fields.map(f => ({ name: f.name, labels: f.labels }))).toMatchInlineSnapshot(`
expect(frame.fields.map((f) => ({ name: f.name, labels: f.labels }))).toMatchInlineSnapshot(`
Array [
Object {
"labels": undefined,
@ -56,7 +56,7 @@ describe('Concat Transformer', () => {
it('using field name', () => {
const frame = concatenateFields([simpleABC, simpleXYZ], { frameNameMode: ConcatenateFrameNameMode.FieldName });
expect(frame.length).toBe(3);
expect(frame.fields.map(f => ({ name: f.name, labels: f.labels }))).toMatchInlineSnapshot(`
expect(frame.fields.map((f) => ({ name: f.name, labels: f.labels }))).toMatchInlineSnapshot(`
Array [
Object {
"labels": undefined,
@ -92,7 +92,7 @@ describe('Concat Transformer', () => {
frameNameLabel: 'sensor',
});
expect(frame.length).toBe(3);
expect(frame.fields.map(f => ({ name: f.name, labels: f.labels }))).toMatchInlineSnapshot(`
expect(frame.fields.map((f) => ({ name: f.name, labels: f.labels }))).toMatchInlineSnapshot(`
Array [
Object {
"labels": Object {

View File

@ -38,9 +38,9 @@ export const concatenateTransformer: DataTransformerInfo<ConcatenateTransformerO
frameNameMode: ConcatenateFrameNameMode.FieldName,
frameNameLabel: 'frame',
},
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(dataFrames => {
map((dataFrames) => {
if (!Array.isArray(dataFrames) || dataFrames.length < 2) {
return dataFrames; // noop with single frame
}
@ -85,7 +85,7 @@ export function concatenateFields(data: DataFrame[], opts: ConcatenateTransforme
// Make sure all fields have the same length
if (!sameLength) {
fields = fields.map(f => {
fields = fields.map((f) => {
if (f.values.length === maxLength) {
return f;
}

View File

@ -43,7 +43,7 @@ describe('ensureColumns transformer', () => {
const data = [seriesA, seriesBC];
await expect(transformDataFrame([cfg], data)).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], data)).toEmitValuesWith((received) => {
const filtered = received[0];
expect(filtered.length).toEqual(1);

View File

@ -11,9 +11,9 @@ export const ensureColumnsTransformer: DataTransformerInfo = {
id: DataTransformerID.ensureColumns,
name: 'Ensure Columns Transformer',
description: 'Will check if current data frames is series or columns. If in series it will convert to columns.',
operator: (options = {}) => source =>
operator: (options = {}) => (source) =>
source.pipe(
mergeMap(data => {
mergeMap((data) => {
// Assume timeseries should first be joined by time
const timeFieldName = findConsistentTimeFieldName(data);

View File

@ -28,7 +28,7 @@ describe('Filter Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [simpleSeriesWithTypes])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [simpleSeriesWithTypes])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(1);

View File

@ -21,13 +21,13 @@ export const filterFieldsTransformer: DataTransformerInfo<FilterOptions> = {
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: (options: FilterOptions) => source => {
operator: (options: FilterOptions) => (source) => {
if (!options.include && !options.exclude) {
return source.pipe(noopTransformer.operator({}));
}
return source.pipe(
map(data => {
map((data) => {
const include = options.include ? getFieldMatcher(options.include) : null;
const exclude = options.exclude ? getFieldMatcher(options.exclude) : null;
@ -76,13 +76,13 @@ export const filterFramesTransformer: DataTransformerInfo<FilterOptions> = {
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source => {
operator: (options) => (source) => {
if (!options.include && !options.exclude) {
return source.pipe(noopTransformer.operator({}));
}
return source.pipe(
map(data => {
map((data) => {
const include = options.include ? getFrameMatchers(options.include) : null;
const exclude = options.exclude ? getFrameMatchers(options.exclude) : null;

View File

@ -26,7 +26,7 @@ describe('filterByName transformer', () => {
options: {},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(4);
@ -44,7 +44,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(2);
@ -62,7 +62,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(2);
@ -79,7 +79,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(1);
@ -97,7 +97,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(2);
@ -115,7 +115,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(2);
@ -132,7 +132,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(1);
@ -151,7 +151,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(2);
@ -170,7 +170,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(2);
@ -187,7 +187,7 @@ describe('filterByName transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesWithNamesToMatch])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields.length).toBe(1);

View File

@ -19,7 +19,7 @@ export const filterFieldsByNameTransformer: DataTransformerInfo<FilterFieldsByNa
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
filterFieldsTransformer.operator({
include: getMatcherConfig(options.include),

View File

@ -30,7 +30,7 @@ describe('filterByRefId transformer', () => {
options: {},
};
await expect(transformDataFrame([cfg], allSeries)).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], allSeries)).toEmitValuesWith((received) => {
const filtered = received[0];
expect(filtered.length).toBe(3);
});
@ -45,9 +45,9 @@ describe('filterByRefId transformer', () => {
},
};
await expect(transformDataFrame([cfg], allSeries)).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], allSeries)).toEmitValuesWith((received) => {
const filtered = received[0];
expect(filtered.map(f => f.refId)).toEqual(['A', 'B']);
expect(filtered.map((f) => f.refId)).toEqual(['A', 'B']);
});
});
});

View File

@ -18,7 +18,7 @@ export const filterFramesByRefIdTransformer: DataTransformerInfo<FilterFramesByR
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source => {
operator: (options) => (source) => {
const filterOptions: FilterOptions = {};
if (options.include) {
filterOptions.include = {

View File

@ -47,7 +47,7 @@ describe('FilterByValue transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith((received) => {
const processed = received[0];
expect(processed.length).toEqual(1);
@ -90,7 +90,7 @@ describe('FilterByValue transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith((received) => {
const processed = received[0];
expect(processed.length).toEqual(1);
@ -142,7 +142,7 @@ describe('FilterByValue transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith((received) => {
const processed = received[0];
expect(processed.length).toEqual(1);
@ -194,7 +194,7 @@ describe('FilterByValue transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith((received) => {
const processed = received[0];
expect(processed.length).toEqual(1);

View File

@ -39,7 +39,7 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
match: FilterByValueMatch.any,
},
operator: options => source => {
operator: (options) => (source) => {
const filters = options.filters;
const matchAll = options.match === FilterByValueMatch.all;
const include = options.type === FilterByValueType.include;
@ -49,7 +49,7 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
}
return source.pipe(
map(data => {
map((data) => {
if (!Array.isArray(data) || data.length === 0) {
return data;
}
@ -137,7 +137,7 @@ const createFilterValueMatchers = (
): Array<(index: number, frame: DataFrame, data: DataFrame[]) => boolean> => {
const noop = () => false;
return filters.map(filter => {
return filters.map((filter) => {
const fieldIndex = fieldIndexByName[filter.fieldName] ?? -1;
if (fieldIndex < 0) {

View File

@ -35,7 +35,7 @@ describe('GroupBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith((received) => {
const result = received[0];
expect(result[0]).toBe(testSeries);
});
@ -63,7 +63,7 @@ describe('GroupBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
{
@ -104,7 +104,7 @@ describe('GroupBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
{
@ -155,7 +155,7 @@ describe('GroupBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [testSeries])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
{
@ -224,7 +224,7 @@ describe('GroupBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], testSeries)).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], testSeries)).toEmitValuesWith((received) => {
const result = received[0];
const expectedA: Field[] = [
{

View File

@ -35,11 +35,11 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
const hasValidConfig = Object.keys(options.fields).find(
name => options.fields[name].operation === GroupByOperationID.groupBy
(name) => options.fields[name].operation === GroupByOperationID.groupBy
);
if (!hasValidConfig) {
@ -65,7 +65,7 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
// group for a given field.
const valuesByGroupKey: Record<string, Record<string, MutableField>> = {};
for (let rowIndex = 0; rowIndex < frame.length; rowIndex++) {
const groupKey = String(groupByFields.map(field => field.values.get(rowIndex)));
const groupKey = String(groupByFields.map((field) => field.values.get(rowIndex)));
const valuesByField = valuesByGroupKey[groupKey] ?? {};
if (!valuesByGroupKey[groupKey]) {

View File

@ -24,7 +24,7 @@ describe('Labels as Columns', () => {
],
});
await expect(transformDataFrame([cfg], [source])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [source])).toEmitValuesWith((received) => {
const data = received[0];
const result = toDataFrameDTO(data[0]);
@ -67,7 +67,7 @@ describe('Labels as Columns', () => {
],
});
await expect(transformDataFrame([cfg], [source])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [source])).toEmitValuesWith((received) => {
const data = received[0];
const result = toDataFrameDTO(data[0]);
@ -108,7 +108,7 @@ describe('Labels as Columns', () => {
],
});
await expect(transformDataFrame([cfg], [oneValueOneLabelA, oneValueOneLabelB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [oneValueOneLabelA, oneValueOneLabelB])).toEmitValuesWith((received) => {
const data = received[0];
const result = toDataFrameDTO(data[0]);

View File

@ -17,9 +17,9 @@ export const labelsToFieldsTransformer: DataTransformerInfo<LabelsToFieldsOption
name: 'Labels to fields',
description: 'Extract time series labels to fields (columns)',
defaultOptions: {},
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
const result: DataFrame[] = [];
for (const frame of data) {

View File

@ -33,7 +33,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [1000, 2000]),
@ -61,7 +61,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200, 100, 125, 126]),
@ -97,7 +97,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [seriesA, seriesB, seriesC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesB, seriesC])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [1000, 2000, 500]),
@ -135,7 +135,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [tableA, seriesB, tableB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [tableA, seriesB, tableB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [1000, 1000, 500]),
@ -174,7 +174,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [tableA, seriesB, tableC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [tableA, seriesB, tableC])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, ['2019-10-01T11:10:23Z', '2019-09-01T11:10:23Z', '2019-11-01T11:10:23Z']),
@ -212,7 +212,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [tableA, tableB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [tableA, tableB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Country', FieldType.string, [
@ -272,7 +272,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [tableA, tableB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [tableA, tableB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('AgeGroup', FieldType.string, [
@ -329,7 +329,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [tableA, tableB, tableC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [tableA, tableB, tableC])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200, 100, 125, 126, 100, 124, 149]),
@ -359,7 +359,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200, 100, 125, 126]),
@ -392,7 +392,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200, 100, 125, 126], {}, displayProcessor),
@ -423,7 +423,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200, 100, 125, 126]),
@ -454,7 +454,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200, 100, 125, 126]),
@ -482,7 +482,7 @@ describe('Merge multiple to single', () => {
fields: [],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200]),
@ -518,7 +518,7 @@ describe('Merge multiple to single', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB, serieC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB, serieC])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200]),
@ -549,7 +549,7 @@ describe('Merge multiple to single', () => {
fields: [],
});
await expect(transformDataFrame([cfg], [serieA, serieB, serieC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB, serieC])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [];
const fields = unwrap(result[0].fields);
@ -565,7 +565,7 @@ const createField = (name: string, type: FieldType, values: any[], config = {},
};
const unwrap = (fields: Field[]): Field[] => {
return fields.map(field =>
return fields.map((field) =>
createField(
field.name,
field.type,

View File

@ -19,14 +19,14 @@ export const mergeTransformer: DataTransformerInfo<MergeTransformerOptions> = {
name: 'Merge series/tables',
description: 'Merges multiple series/tables into a single serie/table',
defaultOptions: {},
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(dataFrames => {
map((dataFrames) => {
if (!Array.isArray(dataFrames) || dataFrames.length === 0) {
return dataFrames;
}
const data = dataFrames.filter(frame => frame.fields.length > 0);
const data = dataFrames.filter((frame) => frame.fields.length > 0);
if (data.length === 0) {
return [dataFrames[0]];
@ -85,7 +85,7 @@ export const mergeTransformer: DataTransformerInfo<MergeTransformerOptions> = {
let valueWasMerged = false;
valuesByKey[key] = valuesByKey[key].map(existing => {
valuesByKey[key] = valuesByKey[key].map((existing) => {
if (!isMergable(existing, value)) {
return existing;
}

View File

@ -16,5 +16,5 @@ export const noopTransformer: DataTransformerInfo<NoopTransformerOptions> = {
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: (options: NoopTransformerOptions) => source => source,
operator: (options: NoopTransformerOptions) => (source) => source,
};

View File

@ -35,7 +35,7 @@ describe('Order Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const ordered = data[0];
expect(ordered.fields).toEqual([
@ -96,7 +96,7 @@ describe('Order Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const ordered = data[0];
expect(ordered.fields).toEqual([
@ -153,7 +153,7 @@ describe('Order Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const ordered = data[0];
expect(ordered.fields).toEqual([

View File

@ -20,16 +20,16 @@ export const orderFieldsTransformer: DataTransformerInfo<OrderFieldsTransformerO
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
const orderer = createFieldsOrderer(options.indexByName);
if (!Array.isArray(data) || data.length === 0) {
return data;
}
return data.map(frame => ({
return data.map((frame) => ({
...frame,
fields: orderer(frame.fields, data, frame),
}));

View File

@ -42,7 +42,7 @@ describe('OrganizeFields Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const organized = data[0];
expect(organized.fields).toEqual([
@ -101,7 +101,7 @@ describe('OrganizeFields Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const organized = data[0];
expect(organized.fields).toEqual([

View File

@ -24,7 +24,7 @@ export const organizeFieldsTransformer: DataTransformerInfo<OrganizeFieldsTransf
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
filterFieldsByNameTransformer.operator({
exclude: { names: mapToExcludeArray(options.excludeByName) },
@ -39,5 +39,5 @@ const mapToExcludeArray = (excludeByName: Record<string, boolean>): string[] =>
return [];
}
return Object.keys(excludeByName).filter(name => excludeByName[name]);
return Object.keys(excludeByName).filter((name) => excludeByName[name]);
};

View File

@ -57,7 +57,7 @@ describe('Reducer Transformer', () => {
};
await expect(transformDataFrame([cfg], [seriesAWithMultipleFields, seriesBWithMultipleFields])).toEmitValuesWith(
received => {
(received) => {
const processed = received[0];
const expected: Field[] = [
{
@ -108,7 +108,7 @@ describe('Reducer Transformer', () => {
};
await expect(transformDataFrame([cfg], [seriesAWithSingleField, seriesBWithSingleField])).toEmitValuesWith(
received => {
(received) => {
const processed = received[0];
const expected: Field[] = [
{
@ -158,7 +158,7 @@ describe('Reducer Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesAWithMultipleFields])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesAWithMultipleFields])).toEmitValuesWith((received) => {
const processed = received[0];
const expected: Field[] = [
{
@ -207,7 +207,7 @@ describe('Reducer Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesAWithSingleField])).toEmitValuesWith((received) => {
const processed = received[0];
const expected: Field[] = [
{

View File

@ -35,9 +35,9 @@ export const reduceTransformer: DataTransformerInfo<ReduceTransformerOptions> =
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
if (!options?.reducers?.length) {
return data; // nothing selected
}
@ -69,7 +69,7 @@ export function reduceSeriesToRows(
reducerId: ReducerID[]
): DataFrame | undefined {
const calculators = fieldReducers.list(reducerId);
const reducers = calculators.map(c => c.id);
const reducers = calculators.map((c) => c.id);
const processed: DataFrame[] = [];
for (const series of data) {
@ -173,7 +173,7 @@ export function mergeResults(data: DataFrame[]): DataFrame | undefined {
*/
export function reduceFields(data: DataFrame[], matcher: FieldMatcher, reducerId: ReducerID[]): DataFrame[] {
const calculators = fieldReducers.list(reducerId);
const reducers = calculators.map(c => c.id);
const reducers = calculators.map((c) => c.id);
const processed: DataFrame[] = [];
for (const series of data) {

View File

@ -36,7 +36,7 @@ describe('Rename Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const renamed = data[0];
expect(renamed.fields).toEqual([
@ -103,7 +103,7 @@ describe('Rename Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const renamed = data[0];
expect(renamed.fields).toEqual([
@ -164,7 +164,7 @@ describe('Rename Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const renamed = data[0];
expect(renamed.fields).toEqual([

View File

@ -20,16 +20,16 @@ export const renameFieldsTransformer: DataTransformerInfo<RenameFieldsTransforme
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
const renamer = createRenamer(options.renameByName);
if (!Array.isArray(data) || data.length === 0) {
return data;
}
return data.map(frame => ({
return data.map((frame) => ({
...frame,
fields: renamer(frame),
}));
@ -42,7 +42,7 @@ const createRenamer = (renameByName: Record<string, string>) => (frame: DataFram
return frame.fields;
}
return frame.fields.map(field => {
return frame.fields.map((field) => {
const displayName = getFieldDisplayName(field, frame);
const renameTo = renameByName[displayName];

View File

@ -34,7 +34,7 @@ describe('Rename By Regex Transformer', () => {
renamePattern: '$1',
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const frame = data[0];
expect(frame.fields).toMatchInlineSnapshot(`
@ -84,7 +84,7 @@ describe('Rename By Regex Transformer', () => {
renamePattern: '$1',
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const frame = data[0];
expect(frame.fields).toMatchInlineSnapshot(`
@ -134,7 +134,7 @@ describe('Rename By Regex Transformer', () => {
renamePattern: '',
},
};
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => {
const data = received[0];
const frame = data[0];
expect(frame.fields).toMatchInlineSnapshot(`

View File

@ -33,9 +33,9 @@ export const renameByRegexTransformer: DataTransformerInfo<RenameByRegexTransfor
* Return a modified copy of the series. If the transform is not or should not
* be applied, just return the input series
*/
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
if (!Array.isArray(data) || data.length === 0) {
return data;
}
@ -46,7 +46,7 @@ export const renameByRegexTransformer: DataTransformerInfo<RenameByRegexTransfor
const renameFieldsByRegex = (options: RenameByRegexTransformerOptions) => (frame: DataFrame) => {
const regex = new RegExp(options.regex);
const fields = frame.fields.map(field => {
const fields = frame.fields.map((field) => {
const displayName = getFieldDisplayName(field, frame);
if (!regex.test(displayName)) {
return field;

View File

@ -41,62 +41,64 @@ describe('SeriesToColumns Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [everySecondSeries, everyOtherSecondSeries])).toEmitValuesWith(received => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([
{
name: 'time',
state: {
displayName: 'time',
await expect(transformDataFrame([cfg], [everySecondSeries, everyOtherSecondSeries])).toEmitValuesWith(
(received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([
{
name: 'time',
state: {
displayName: 'time',
},
type: FieldType.time,
values: new ArrayVector([1000, 3000, 4000, 5000, 6000, 7000]),
config: {},
labels: undefined,
},
type: FieldType.time,
values: new ArrayVector([1000, 3000, 4000, 5000, 6000, 7000]),
config: {},
labels: undefined,
},
{
name: 'temperature',
state: {
displayName: 'temperature even',
{
name: 'temperature',
state: {
displayName: 'temperature even',
},
type: FieldType.number,
values: new ArrayVector([null, 10.3, 10.4, 10.5, 10.6, null]),
config: {},
labels: { name: 'even' },
},
type: FieldType.number,
values: new ArrayVector([null, 10.3, 10.4, 10.5, 10.6, null]),
config: {},
labels: { name: 'even' },
},
{
name: 'humidity',
state: {
displayName: 'humidity even',
{
name: 'humidity',
state: {
displayName: 'humidity even',
},
type: FieldType.number,
values: new ArrayVector([null, 10000.3, 10000.4, 10000.5, 10000.6, null]),
config: {},
labels: { name: 'even' },
},
type: FieldType.number,
values: new ArrayVector([null, 10000.3, 10000.4, 10000.5, 10000.6, null]),
config: {},
labels: { name: 'even' },
},
{
name: 'temperature',
state: {
displayName: 'temperature odd',
{
name: 'temperature',
state: {
displayName: 'temperature odd',
},
type: FieldType.number,
values: new ArrayVector([11.1, 11.3, null, 11.5, null, 11.7]),
config: {},
labels: { name: 'odd' },
},
type: FieldType.number,
values: new ArrayVector([11.1, 11.3, null, 11.5, null, 11.7]),
config: {},
labels: { name: 'odd' },
},
{
name: 'humidity',
state: {
displayName: 'humidity odd',
{
name: 'humidity',
state: {
displayName: 'humidity odd',
},
type: FieldType.number,
values: new ArrayVector([11000.1, 11000.3, null, 11000.5, null, 11000.7]),
config: {},
labels: { name: 'odd' },
},
type: FieldType.number,
values: new ArrayVector([11000.1, 11000.3, null, 11000.5, null, 11000.7]),
config: {},
labels: { name: 'odd' },
},
]);
});
]);
}
);
});
it('joins by temperature field', async () => {
@ -107,62 +109,64 @@ describe('SeriesToColumns Transformer', () => {
},
};
await expect(transformDataFrame([cfg], [everySecondSeries, everyOtherSecondSeries])).toEmitValuesWith(received => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([
{
name: 'temperature',
state: {
displayName: 'temperature',
await expect(transformDataFrame([cfg], [everySecondSeries, everyOtherSecondSeries])).toEmitValuesWith(
(received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([
{
name: 'temperature',
state: {
displayName: 'temperature',
},
type: FieldType.number,
values: new ArrayVector([10.3, 10.4, 10.5, 10.6, 11.1, 11.3, 11.5, 11.7]),
config: {},
labels: undefined,
},
type: FieldType.number,
values: new ArrayVector([10.3, 10.4, 10.5, 10.6, 11.1, 11.3, 11.5, 11.7]),
config: {},
labels: undefined,
},
{
name: 'time',
state: {
displayName: 'time even',
{
name: 'time',
state: {
displayName: 'time even',
},
type: FieldType.time,
values: new ArrayVector([3000, 4000, 5000, 6000, null, null, null, null]),
config: {},
labels: { name: 'even' },
},
type: FieldType.time,
values: new ArrayVector([3000, 4000, 5000, 6000, null, null, null, null]),
config: {},
labels: { name: 'even' },
},
{
name: 'humidity',
state: {
displayName: 'humidity even',
{
name: 'humidity',
state: {
displayName: 'humidity even',
},
type: FieldType.number,
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6, null, null, null, null]),
config: {},
labels: { name: 'even' },
},
type: FieldType.number,
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6, null, null, null, null]),
config: {},
labels: { name: 'even' },
},
{
name: 'time',
state: {
displayName: 'time odd',
{
name: 'time',
state: {
displayName: 'time odd',
},
type: FieldType.time,
values: new ArrayVector([null, null, null, null, 1000, 3000, 5000, 7000]),
config: {},
labels: { name: 'odd' },
},
type: FieldType.time,
values: new ArrayVector([null, null, null, null, 1000, 3000, 5000, 7000]),
config: {},
labels: { name: 'odd' },
},
{
name: 'humidity',
state: {
displayName: 'humidity odd',
{
name: 'humidity',
state: {
displayName: 'humidity odd',
},
type: FieldType.number,
values: new ArrayVector([null, null, null, null, 11000.1, 11000.3, 11000.5, 11000.7]),
config: {},
labels: { name: 'odd' },
},
type: FieldType.number,
values: new ArrayVector([null, null, null, null, 11000.1, 11000.3, 11000.5, 11000.7]),
config: {},
labels: { name: 'odd' },
},
]);
});
]);
}
);
});
it('joins by time field in reverse order', async () => {
@ -177,62 +181,64 @@ describe('SeriesToColumns Transformer', () => {
everySecondSeries.fields[1].values = new ArrayVector(everySecondSeries.fields[1].values.toArray().reverse());
everySecondSeries.fields[2].values = new ArrayVector(everySecondSeries.fields[2].values.toArray().reverse());
await expect(transformDataFrame([cfg], [everySecondSeries, everyOtherSecondSeries])).toEmitValuesWith(received => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([
{
name: 'time',
state: {
displayName: 'time',
await expect(transformDataFrame([cfg], [everySecondSeries, everyOtherSecondSeries])).toEmitValuesWith(
(received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([
{
name: 'time',
state: {
displayName: 'time',
},
type: FieldType.time,
values: new ArrayVector([1000, 3000, 4000, 5000, 6000, 7000]),
config: {},
labels: undefined,
},
type: FieldType.time,
values: new ArrayVector([1000, 3000, 4000, 5000, 6000, 7000]),
config: {},
labels: undefined,
},
{
name: 'temperature',
state: {
displayName: 'temperature even',
{
name: 'temperature',
state: {
displayName: 'temperature even',
},
type: FieldType.number,
values: new ArrayVector([null, 10.3, 10.4, 10.5, 10.6, null]),
config: {},
labels: { name: 'even' },
},
type: FieldType.number,
values: new ArrayVector([null, 10.3, 10.4, 10.5, 10.6, null]),
config: {},
labels: { name: 'even' },
},
{
name: 'humidity',
state: {
displayName: 'humidity even',
{
name: 'humidity',
state: {
displayName: 'humidity even',
},
type: FieldType.number,
values: new ArrayVector([null, 10000.3, 10000.4, 10000.5, 10000.6, null]),
config: {},
labels: { name: 'even' },
},
type: FieldType.number,
values: new ArrayVector([null, 10000.3, 10000.4, 10000.5, 10000.6, null]),
config: {},
labels: { name: 'even' },
},
{
name: 'temperature',
state: {
displayName: 'temperature odd',
{
name: 'temperature',
state: {
displayName: 'temperature odd',
},
type: FieldType.number,
values: new ArrayVector([11.1, 11.3, null, 11.5, null, 11.7]),
config: {},
labels: { name: 'odd' },
},
type: FieldType.number,
values: new ArrayVector([11.1, 11.3, null, 11.5, null, 11.7]),
config: {},
labels: { name: 'odd' },
},
{
name: 'humidity',
state: {
displayName: 'humidity odd',
{
name: 'humidity',
state: {
displayName: 'humidity odd',
},
type: FieldType.number,
values: new ArrayVector([11000.1, 11000.3, null, 11000.5, null, 11000.7]),
config: {},
labels: { name: 'odd' },
},
type: FieldType.number,
values: new ArrayVector([11000.1, 11000.3, null, 11000.5, null, 11000.7]),
config: {},
labels: { name: 'odd' },
},
]);
});
]);
}
);
});
describe('Field names', () => {
@ -261,7 +267,7 @@ describe('SeriesToColumns Transformer', () => {
};
await expect(transformDataFrame([cfg], [seriesWithSameFieldAndDataFrameName, seriesB])).toEmitValuesWith(
received => {
(received) => {
const data = received[0];
const filtered = data[0];
const expected: Field[] = [
@ -332,7 +338,7 @@ describe('SeriesToColumns Transformer', () => {
],
});
await expect(transformDataFrame([cfg], [frame1, frame2, frame3])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [frame1, frame2, frame3])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([
@ -385,7 +391,7 @@ describe('SeriesToColumns Transformer', () => {
],
});
await expect(transformDataFrame([cfg], [frame1, frame2])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [frame1, frame2])).toEmitValuesWith((received) => {
const data = received[0];
const filtered = data[0];
expect(filtered.fields).toEqual([

View File

@ -19,9 +19,9 @@ export const seriesToColumnsTransformer: DataTransformerInfo<SeriesToColumnsOpti
defaultOptions: {
byField: DEFAULT_KEY_FIELD,
},
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
return outerJoinDataFrames(data, options);
})
),

View File

@ -33,7 +33,7 @@ describe('Series to rows', () => {
],
});
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
@ -68,7 +68,7 @@ describe('Series to rows', () => {
],
});
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
@ -111,7 +111,7 @@ describe('Series to rows', () => {
],
});
await expect(transformDataFrame([cfg], [seriesA, seriesB, seriesC])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [seriesA, seriesB, seriesC])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
@ -151,7 +151,7 @@ describe('Series to rows', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
@ -189,7 +189,7 @@ describe('Series to rows', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
@ -227,7 +227,7 @@ describe('Series to rows', () => {
],
});
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [serieA, serieB])).toEmitValuesWith((received) => {
const result = received[0];
const expected: Field[] = [
@ -249,7 +249,7 @@ const createField = (name: string, type: FieldType, values: any[], config = {}):
};
const unwrap = (fields: Field[]): Field[] => {
return fields.map(field =>
return fields.map((field) =>
createField(
field.name,
field.type,

View File

@ -22,9 +22,9 @@ export const seriesToRowsTransformer: DataTransformerInfo<SeriesToRowsTransforme
name: 'Series to rows',
description: 'Combines multiple series into a single serie and appends a column with metric name per value.',
defaultOptions: {},
operator: options => source =>
operator: (options) => (source) =>
source.pipe(
map(data => {
map((data) => {
if (!Array.isArray(data) || data.length <= 1) {
return data;
}

View File

@ -28,7 +28,7 @@ describe('SortBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], [testFrame])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [testFrame])).toEmitValuesWith((received) => {
const result = received[0];
expect(result[0]).toBe(testFrame);
});
@ -46,7 +46,7 @@ describe('SortBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], [testFrame])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [testFrame])).toEmitValuesWith((received) => {
expect(getFieldSnapshot(received[0][0].fields[0])).toMatchInlineSnapshot(`
Object {
"name": "time",
@ -76,7 +76,7 @@ describe('SortBy transformer', () => {
},
};
await expect(transformDataFrame([cfg], [testFrame])).toEmitValuesWith(received => {
await expect(transformDataFrame([cfg], [testFrame])).toEmitValuesWith((received) => {
expect(getFieldSnapshot(received[0][0].fields[0])).toMatchInlineSnapshot(`
Object {
"name": "time",

Some files were not shown because too many files have changed in this diff Show More