Skip to content

Commit

Permalink
Prettier: Upgrade to 2 (grafana#30387)
Browse files Browse the repository at this point in the history
* Updated package json but not updated source files

* Update eslint plugin

* updated files
  • Loading branch information
torkelo authored Jan 20, 2021
1 parent f27450e commit 1d68988
Show file tree
Hide file tree
Showing 1,069 changed files with 4,371 additions and 5,261 deletions.
10 changes: 5 additions & 5 deletions devenv/docker/loadtest/annotations_by_tag_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const setup = () => {
};
};

export default data => {
export default (data) => {
client.withOrgId(data.orgId);

group('annotation by tag test', () => {
Expand All @@ -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,
});
});
Expand Down Expand Up @@ -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,
});
}
});
Expand All @@ -73,4 +73,4 @@ export default data => {
sleep(5);
};

export const teardown = data => {};
export const teardown = (data) => {};
9 changes: 4 additions & 5 deletions devenv/docker/loadtest/auth_key_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -28,7 +27,7 @@ export const setup = () => {
};
};

export default data => {
export default (data) => {
client.withOrgId(data.orgId);

group('API key test', () => {
Expand All @@ -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,
});
});
}
Expand Down Expand Up @@ -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,
});
}
});
Expand All @@ -79,4 +78,4 @@ export default data => {
sleep(5);
};

export const teardown = data => {};
export const teardown = (data) => {};
6 changes: 3 additions & 3 deletions devenv/docker/loadtest/auth_proxy_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
});
}
});
Expand All @@ -53,4 +53,4 @@ export default data => {
sleep(5);
};

export const teardown = data => {};
export const teardown = (data) => {};
10 changes: 5 additions & 5 deletions devenv/docker/loadtest/auth_token_slow_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)`, () => {
Expand All @@ -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,
});
});
Expand Down Expand Up @@ -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,
});
}
});
Expand All @@ -75,4 +75,4 @@ export default data => {
sleep(5);
};

export const teardown = data => {};
export const teardown = (data) => {};
10 changes: 5 additions & 5 deletions devenv/docker/loadtest/auth_token_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const setup = () => {
};
};

export default data => {
export default (data) => {
client.withOrgId(data.orgId);

group('user auth token test', () => {
Expand All @@ -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,
});
});
Expand Down Expand Up @@ -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,
});
}
});
Expand All @@ -74,4 +74,4 @@ export default data => {
sleep(5);
};

export const teardown = data => {};
export const teardown = (data) => {};
6 changes: 3 additions & 3 deletions devenv/docker/loadtest/modules/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ''));
};

Expand All @@ -210,4 +210,4 @@ export const createBasicAuthClient = (url, username, password) => {

export const createBearerAuthClient = (url, token) => {
return new GrafanaClient(new BearerAuthClient(url, '', token));
}
};
5 changes: 2 additions & 3 deletions devenv/docker/loadtest/modules/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const createTestOrgIfNotExists = client => {
export const createTestOrgIfNotExists = (client) => {
let orgId = 0;

let res = client.orgs.getByName('k6');
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion devenv/e2e-api-tests/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 2 additions & 7 deletions e2e/shared/smokeTestScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion e2e/suite1/specs/dashboard-templating.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ e2e.scenario({
e2e()
.get('.markdown-html li')
.should('have.length', 23)
.each(element => {
.each((element) => {
items.push(element.text());
})
.then(() => {
Expand Down
26 changes: 7 additions & 19 deletions e2e/suite1/specs/dashboard-time-zone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ e2e.scenario({
.labels()
.should('be.visible')
.last()
.should(element => {
.should((element) => {
timesInUtc[title] = element.text();
})
);
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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;
};
9 changes: 2 additions & 7 deletions e2e/suite1/specs/explore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 1 addition & 4 deletions e2e/suite1/specs/gauge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
23 changes: 6 additions & 17 deletions e2e/suite1/specs/inspect-drawer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 1d68988

Please sign in to comment.