Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-7 add git hooks, run lint fix against whole project #793

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"functions": "always-multiline"
}
],
"eol-last": ["error", "always"],
"no-restricted-imports": 0,
"no-param-reassign": ["error", { "ignorePropertyModificationsForRegex": ["^acc$"] }],
"max-len": ["error", { "code": 130, "ignoreStrings": true, "ignoreRegExpLiterals": true }],
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run pre-commit
5 changes: 5 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"allowJs": true,
},
}
18 changes: 17 additions & 1 deletion package-lock.json

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

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
"url": "https://github.com/percona/pmm-ui-tests.git"
},
"scripts": {
"gen:types": "npx codeceptjs def --config=pr.codecept.js",
"lint:tests": "eslint --ext .js --fix tests/",
"e2e": "npx codeceptjs run-multiple parallel --debug --steps --reporter mocha-multi -c pr.codecept.js --grep '(?=.*)^(?!.*@not-ui-pipeline)^(?!.*@not-pr-pipeline)'",
"e2e:ia": "npx codeceptjs run -c pr.codecept.js --grep '@ia'",
"e2e:stt": "npx codeceptjs run -c pr.codecept.js --grep '@stt'",
"e2e:dbaas": "npx codeceptjs run -c pr.codecept.js --grep '@dbaas'",
"e2e:grafana-pr": "npx codeceptjs run -c pr.codecept.js --grep '@grafana-pr'"
"e2e:grafana-pr": "npx codeceptjs run -c pr.codecept.js --grep '@grafana-pr'",
"prepare": "husky install",
"pre-commit": "npm run lint:tests && echo 'Lint OK'"
},
"dependencies": {
"@faker-js/faker": "^5.5.3",
Expand Down Expand Up @@ -63,6 +66,7 @@
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-playwright": "^0.12.0"
"eslint-plugin-playwright": "^0.12.0",
"husky": "^8.0.0"
}
}
101 changes: 101 additions & 0 deletions steps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/// <reference types='codeceptjs' />
type steps_file = typeof import('./tests/custom_steps.js');
type codeceptjsConfig = typeof import('./pr.codecept.js');
type credentials = typeof import('./tests/pages/credentials.js');
type addInstanceAPI = typeof import('./tests/pages/api/addInstanceAPI.js');
type addInstancePage = typeof import('./tests/pages/addInstancePage.js');
type amiInstanceAPI = typeof import('./tests/pages/api/amiInstanceAPI.js');
type adminPage = typeof import('./tests/pages/adminPage.js');
type alertGroupsPage = typeof import('./tests/ia/pages/alertGroupsPage.js');
type alertRulesPage = typeof import('./tests/ia/pages/alertRulesPage.js');
type aiAdminPage = typeof import('./tests/ia/pages/alertingAdminPage.js');
type alertmanagerAPI = typeof import('./tests/pages/api/alertmanagerAPI.js');
type alertsAPI = typeof import('./tests/ia/pages/api/alertsAPI.js');
type alertsPage = typeof import('./tests/ia/pages/alertsPage.js');
type advisorsPage = typeof import('./tests/advisors/pages/advisorsPage.js');
type amiInstanceSetupPage = typeof import('./tests/pages/amiInstanceSetupPage.js');
type annotationAPI = typeof import('./tests/pages/api/annotationAPI.js');
type backupAPI = typeof import('./tests/backup/pages/api/backupAPI.js');
type backupInventoryPage = typeof import('./tests/backup/pages/inventoryPage.js');
type changePasswordPage = typeof import('./tests/configuration/pages/changePasswordPage.js');
type contactPointsAPI = typeof import('./tests/ia/pages/api/contactPointsAPI.js');
type contactPointsPage = typeof import('./tests/ia/pages/contactPointsPage.js');
type dashboardPage = typeof import('./tests/pages/dashboardPage.js');
type databaseChecksPage = typeof import('./tests/advisors/pages/databaseChecksPage.js');
type dbaasAPI = typeof import('./tests/DbaaS/api/dbaasAPI.js');
type dbaasPage = typeof import('./tests/DbaaS/pages/dbaasPage.js');
type dbaasActionsPage = typeof import('./tests/DbaaS/pages/dbaasActionsPage.js');
type dbaasManageVersionPage = typeof import('./tests/DbaaS/pages/dbaasManageVersionPage.js');
type dbClusterSummaryDashboardPage = typeof import('./tests/PageObjects/Dashboards/Experimental/dbClusterSummaryDashboard.js');
type dumpAPI = typeof import('./tests/pages/api/dumpAPI.js');
type dumpPage = typeof import('./tests/pages/dumpPage.js');
type explorePage = typeof import('./tests/pages/explorePage.js');
type experimentalPostgresqlDashboardsPage = typeof import('./tests/PageObjects/Dashboards/Postgresql/ExperimentalPostgresqlDashboards.js');
type grafanaAPI = typeof import('./tests/pages/api/grafanaAPI.js');
type homePage = typeof import('./tests/pages/homePage.js');
type inventoryAPI = typeof import('./tests/pages/api/inventoryAPI.js');
type mysqlTableDetailsPage = typeof import('./tests/pages/mysqlTableDetailsPage.js');
type leftNavMenu = typeof import('./tests/pages/leftNavMenu.js');
type links = typeof import('./tests/helper/linksHelper.js');
type locationsPage = typeof import('./tests/backup/pages/locationsPage.js');
type locationsAPI = typeof import('./tests/backup/pages/api/locationsAPI.js');
type nPoliciesPage = typeof import('./tests/ia/pages/notificationPolicies.js');
type psMySql = typeof import('./tests/helper/psMySql.js');
type organizationEntitlementsPage = typeof import('./tests/pages/organizationEntitlementsPage.js');
type organizationTicketsPage = typeof import('./tests/pages/organizationTicketsPage.js');
type perconaPlatformPage = typeof import('./tests/pages/perconaPlatformPage/perconaPlatformPage.js');
type pmmDemoPage = typeof import('./tests/pages/pmmDemoPage.js');
type pmmInventoryPage = typeof import('./tests/configuration/pages/pmmInventoryPage.js');
type agentsPage = typeof import('./tests/configuration/pages/agentsPage.js');
type pmmServerAdminSettingsPage = typeof import('./tests/configuration/pages/pmmServerAdminSettingsPage.js');
type pmmSettingsPage = typeof import('./tests/configuration/pages/pmmSettingsPage.js');
type portalAPI = typeof import('./tests/pages/api/portalAPI.js');
type profileAPI = typeof import('./tests/configuration/api/profileApi.js');
type qanDetails = typeof import('./tests/QAN/pages/qanDetailsFragment.js');
type qanFilters = typeof import('./tests/QAN/pages/qanFiltersFragment.js');
type qanOverview = typeof import('./tests/QAN/pages/qanOverviewFragment.js');
type qanPage = typeof import('./tests/QAN/pages/qanPage.js');
type qanPagination = typeof import('./tests/QAN/pages/qanPaginationFragment.js');
type remoteInstancesPage = typeof import('./tests/pages/remoteInstancesPage.js');
type remoteInstancesHelper = typeof import('./tests/remoteInstances/remoteInstancesHelper.js');
type restorePage = typeof import('./tests/backup/pages/restorePage.js');
type rulesAPI = typeof import('./tests/ia/pages/api/rulesAPI.js');
type ruleTemplatesPage = typeof import('./tests/ia/pages/ruleTemplatesPage.js');
type scheduledAPI = typeof import('./tests/backup/pages/api/scheduledAPI.js');
type scheduledPage = typeof import('./tests/backup/pages/scheduledPage.js');
type searchDashboardsModal = typeof import('./tests/dashboards/pages/searchDashboardsModal.js');
type serverApi = typeof import('./tests/pages/api/serverApi.js');
type silencesPage = typeof import('./tests/ia/pages/silencesPage.js');
type iaCommon = typeof import('./tests/ia/pages/iaCommonPage.js');
type platformAPI = typeof import('./tests/pages/api/platformAPI.js');
type advisorsAPI = typeof import('./tests/advisors/pages/api/advisorsAPI.js');
type settingsAPI = typeof import('./tests/pages/api/settingsAPI.js');
type templatesAPI = typeof import('./tests/ia/pages/api/templatesAPI.js');
type qanAPI = typeof import('./tests/QAN/api/qanAPI.js');
type environmentOverviewPage = typeof import('./tests/pages/environmentOverviewPage.js');
type tooltips = typeof import('./tests/helper/tooltipHelper.js');
type statsAndLicensePage = typeof import('./tests/server-admin/pages/statsAndLicensePage.js');
type dataSourcePage = typeof import('./tests/pages/pmmSettingsPages/dataSourcePage.js');
type pmmTourPage = typeof import('./tests/pages/pmmTourPage.js');
type loginPage = typeof import('./tests/pages/loginPage.js');
type nodesOverviewPage = typeof import('./tests/pages/nodesOverviewPage.js');
type MongoDBHelper = import('./tests/helper/mongoDB.js');
type PostgresqlDBHelper = import('codeceptjs-postgresqlhelper');
type Grafana = import('./tests/helper/grafana_helper.js');
type FileHelper = import('./tests/helper/file_helper.js');
type PerformanceHelper = import('./tests/helper/performance_helper.js');
type BrowserHelper = import('./tests/helper/browser_helper.js');
type Mailosaur = import('codeceptjs-mailosaurhelper');
type DbHelper = import('codeceptjs-dbhelper');
type ChaiWrapper = import('codeceptjs-chai');
type LocalStorageHelper = import('./tests/helper/localStorageHelper.js');
type ApiHelper = import('./tests/helper/apiHelper.js');

declare namespace CodeceptJS {
interface SupportObject { I: I, current: any, codeceptjsConfig: codeceptjsConfig, credentials: credentials, addInstanceAPI: addInstanceAPI, addInstancePage: addInstancePage, amiInstanceAPI: amiInstanceAPI, adminPage: adminPage, alertGroupsPage: alertGroupsPage, alertRulesPage: alertRulesPage, aiAdminPage: aiAdminPage, alertmanagerAPI: alertmanagerAPI, alertsAPI: alertsAPI, alertsPage: alertsPage, advisorsPage: advisorsPage, amiInstanceSetupPage: amiInstanceSetupPage, annotationAPI: annotationAPI, backupAPI: backupAPI, backupInventoryPage: backupInventoryPage, changePasswordPage: changePasswordPage, contactPointsAPI: contactPointsAPI, contactPointsPage: contactPointsPage, dashboardPage: dashboardPage, databaseChecksPage: databaseChecksPage, dbaasAPI: dbaasAPI, dbaasPage: dbaasPage, dbaasActionsPage: dbaasActionsPage, dbaasManageVersionPage: dbaasManageVersionPage, dbClusterSummaryDashboardPage: dbClusterSummaryDashboardPage, dumpAPI: dumpAPI, dumpPage: dumpPage, explorePage: explorePage, experimentalPostgresqlDashboardsPage: experimentalPostgresqlDashboardsPage, grafanaAPI: grafanaAPI, homePage: homePage, inventoryAPI: inventoryAPI, mysqlTableDetailsPage: mysqlTableDetailsPage, leftNavMenu: leftNavMenu, links: links, locationsPage: locationsPage, locationsAPI: locationsAPI, nPoliciesPage: nPoliciesPage, psMySql: psMySql, organizationEntitlementsPage: organizationEntitlementsPage, organizationTicketsPage: organizationTicketsPage, perconaPlatformPage: perconaPlatformPage, pmmDemoPage: pmmDemoPage, pmmInventoryPage: pmmInventoryPage, agentsPage: agentsPage, pmmServerAdminSettingsPage: pmmServerAdminSettingsPage, pmmSettingsPage: pmmSettingsPage, portalAPI: portalAPI, profileAPI: profileAPI, qanDetails: qanDetails, qanFilters: qanFilters, qanOverview: qanOverview, qanPage: qanPage, qanPagination: qanPagination, remoteInstancesPage: remoteInstancesPage, remoteInstancesHelper: remoteInstancesHelper, restorePage: restorePage, rulesAPI: rulesAPI, ruleTemplatesPage: ruleTemplatesPage, scheduledAPI: scheduledAPI, scheduledPage: scheduledPage, searchDashboardsModal: searchDashboardsModal, serverApi: serverApi, silencesPage: silencesPage, iaCommon: iaCommon, platformAPI: platformAPI, advisorsAPI: advisorsAPI, settingsAPI: settingsAPI, templatesAPI: templatesAPI, qanAPI: qanAPI, environmentOverviewPage: environmentOverviewPage, tooltips: tooltips, statsAndLicensePage: statsAndLicensePage, dataSourcePage: dataSourcePage, pmmTourPage: pmmTourPage, loginPage: loginPage, nodesOverviewPage: nodesOverviewPage }
interface Methods extends Playwright, MongoDBHelper, PostgresqlDBHelper, Grafana, FileHelper, FileSystem, PerformanceHelper, BrowserHelper, REST, Mailosaur, DbHelper, ChaiWrapper, LocalStorageHelper, ApiHelper {}
interface I extends ReturnType<steps_file>, WithTranslation<MongoDBHelper>, WithTranslation<PostgresqlDBHelper>, WithTranslation<Grafana>, WithTranslation<FileHelper>, WithTranslation<FileSystem>, WithTranslation<PerformanceHelper>, WithTranslation<BrowserHelper>, WithTranslation<Mailosaur>, WithTranslation<DbHelper>, WithTranslation<ChaiWrapper>, WithTranslation<LocalStorageHelper>, WithTranslation<ApiHelper> {}
namespace Translation {
interface Actions {}
}
}
44 changes: 24 additions & 20 deletions tests/configuration/verifyPMMInventory_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const assert = require('assert');
const {de} = require("@faker-js/faker/lib/locales");

const {
I, remoteInstancesPage, pmmInventoryPage, remoteInstancesHelper,
Expand Down Expand Up @@ -305,14 +304,15 @@ Scenario(
I.amOnPage(remoteInstancesPage.url);
remoteInstancesPage.waitUntilRemoteInstancesPageLoaded();
remoteInstancesPage.openAddRemotePage('external');
const inputs =await remoteInstancesPage.fillRemoteFields(externalExporterServiceName);
const inputs = await remoteInstancesPage.fillRemoteFields(externalExporterServiceName);

I.waitForVisible(remoteInstancesPage.fields.addService, 30);
I.click(remoteInstancesPage.fields.addService);
pmmInventoryPage.verifyRemoteServiceIsDisplayed(externalExporterServiceName);
const newLabels = {
environment: `${inputs.environment} edited` || `${externalExporterServiceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${externalExporterServiceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${externalExporterServiceName} replicationSet edited`,
environment: `${inputs.environment} edited` || `${externalExporterServiceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${externalExporterServiceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${externalExporterServiceName} replicationSet edited`,
};

pmmInventoryPage.openEditServiceWizard(externalExporterServiceName);
Expand All @@ -334,12 +334,13 @@ Scenario(
remoteInstancesPage.startMonitoringOfInstance(serviceName);
remoteInstancesPage.verifyAddInstancePageOpened();
const inputs = await remoteInstancesPage.fillRemoteRDSFields(serviceName);

remoteInstancesPage.createRemoteInstance(serviceName);
pmmInventoryPage.verifyRemoteServiceIsDisplayed(serviceName);
const newLabels = {
environment: `${inputs.environment} edited` || `${serviceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${serviceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${serviceName} replicationSet edited`,
environment: `${inputs.environment} edited` || `${serviceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${serviceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${serviceName} replicationSet edited`,
};

pmmInventoryPage.openEditServiceWizard(serviceName);
Expand Down Expand Up @@ -373,9 +374,9 @@ Scenario(
I.click(remoteInstancesPage.fields.addService);
pmmInventoryPage.verifyRemoteServiceIsDisplayed(haproxyServiceName);
const newLabels = {
environment: `${remoteInstancesHelper.remote_instance.haproxy.environment} edited` || `${haproxyServiceName} environment edited`,
cluster: `${remoteInstancesHelper.remote_instance.haproxy.clusterName} edited` || `${haproxyServiceName} cluster edited`,
replicationSet: `${remoteInstancesHelper.remote_instance.haproxy.replicationSet} edited` || `${haproxyServiceName} replicationSet edited`,
environment: `${remoteInstancesHelper.remote_instance.haproxy.environment} edited` || `${haproxyServiceName} environment edited`,
cluster: `${remoteInstancesHelper.remote_instance.haproxy.clusterName} edited` || `${haproxyServiceName} cluster edited`,
replicationSet: `${remoteInstancesHelper.remote_instance.haproxy.replicationSet} edited` || `${haproxyServiceName} replicationSet edited`,
};

pmmInventoryPage.openEditServiceWizard(haproxyServiceName);
Expand Down Expand Up @@ -403,13 +404,15 @@ Scenario(
assert.ok(grabbedHostname.startsWith(serviceName), `Hostname is incorrect: ${grabbedHostname}`);
I.seeInField(remoteInstancesPage.fields.serviceName, serviceName);
const inputs = await remoteInstancesPage.fillRemoteRDSFields(serviceName);

remoteInstancesPage.createRemoteInstance(serviceName);
pmmInventoryPage.verifyRemoteServiceIsDisplayed(serviceName);
const newLabels = {
environment: `${inputs.environment} edited` || `${serviceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${serviceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${serviceName} replicationSet edited`,
environment: `${inputs.environment} edited` || `${serviceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${serviceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${serviceName} replicationSet edited`,
};

pmmInventoryPage.openEditServiceWizard(serviceName);
pmmInventoryPage.updateServiceLabels(newLabels);
I.click(pmmInventoryPage.fields.showServiceDetails(serviceName));
Expand All @@ -431,12 +434,13 @@ Data(azureServices).Scenario(
remoteInstancesPage.startMonitoringOfInstance(current.instanceToMonitor);
remoteInstancesPage.verifyAddInstancePageOpened();
const inputs = await remoteInstancesPage.fillRemoteRDSFields(serviceName);

I.click(remoteInstancesPage.fields.addService);
pmmInventoryPage.verifyRemoteServiceIsDisplayed(serviceName);
const newLabels = {
environment: `${inputs.environment} edited` || `${serviceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${serviceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${serviceName} replicationSet edited`,
environment: `${inputs.environment} edited` || `${serviceName} environment edited`,
cluster: `${inputs.cluster} edited` || `${serviceName} cluster edited`,
replicationSet: `${inputs.replicationSet} edited` || `${serviceName} replicationSet edited`,
};

pmmInventoryPage.openEditServiceWizard(serviceName);
Expand Down Expand Up @@ -474,9 +478,9 @@ Data(aws_instances).Scenario('PMM-T2340 Verify adding and editing Aurora remote
I.amOnPage(pmmInventoryPage.url);
pmmInventoryPage.verifyRemoteServiceIsDisplayed(details.service_name);
const newLabels = {
environment: `${details.environment} edited` || `${details.service_name} environment edited`,
cluster: `${details.cluster} edited` || `${details.service_name} cluster edited`,
replicationSet: `${details.replicationSet} edited` || `${details.service_name} replicationSet edited`,
environment: `${details.environment} edited` || `${details.service_name} environment edited`,
cluster: `${details.cluster} edited` || `${details.service_name} cluster edited`,
replicationSet: `${details.replicationSet} edited` || `${details.service_name} replicationSet edited`,
};

pmmInventoryPage.openEditServiceWizard(details.service_name);
Expand Down
4 changes: 3 additions & 1 deletion tests/helper/file_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ class FileHelper extends Helper {

async fileSize(path, failOnError = true) {
try {
let stats = fs.statSync(path);
const stats = fs.statSync(path);

return stats.size;
} catch (e) {
if (!failOnError) assert.ok(false, `Could not get file size: ${path}, because of error: ${e}`);
}

return -1;
}
}
Expand Down
Loading
Loading