Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Development fixing deprecated dependencies #547

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
28 changes: 13 additions & 15 deletions cypress/e2e/verify_explorer_stats.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("TF Grid Dashboard", function () {
cy.request({
method: "GET",
url: "https://gridproxy.dev.grid.tf/stats?status=up",
}).should(res => {
}).then(res => {
//Get the stats from the grid_proxy
const nodesOnline = JSON.stringify(res.body.nodes);
const farms = JSON.stringify(res.body.farms);
Expand All @@ -36,20 +36,18 @@ describe("TF Grid Dashboard", function () {
const contracts = JSON.stringify(res.body.contracts);

//Verify the values appearing in the statisticspage from the grid proxy
statsPage.VerifyStats(
nodesOnline,
farms,
countries,
totalCru,
totalSru,
totalHru,
totalMru,
accessNodes,
gateways,
twins,
publicIps,
contracts,
);
statsPage.VerifyStats(1, nodesOnline);
statsPage.VerifyStats(3, farms);
statsPage.VerifyStats(6, countries);
statsPage.VerifyStats(9, totalCru);
statsPage.VerifyStats(12, totalSru);
statsPage.VerifyStats(15, totalHru);
statsPage.VerifyStats(18, totalMru);
statsPage.VerifyStats(21, accessNodes);
statsPage.VerifyStats(24, gateways);
statsPage.VerifyStats(27, twins);
statsPage.VerifyStats(30, publicIps);
statsPage.VerifyStats(33, contracts);
});
});
});
76 changes: 2 additions & 74 deletions cypress/page-objects/stats-page.ts
Original file line number Diff line number Diff line change
@@ -1,85 +1,13 @@
/// <reference types="cypress"/>
/// <reference types="cypress-xpath"/>

class StatsPage {
get getNodesCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[1]/div/div/p');
}

get getFarmsCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[2]/div/div/p');
}

get getCountriesCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[3]/div/div/p');
}

get getCpuCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[4]/div/div/p');
}

get getSsdCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[5]/div/div/p');
}

get getHddCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[6]/div/div/p');
}

get getRamCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[7]/div/div/p');
}

get getAccessNodesCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[8]/div/div/p');
}

get getGatewaysCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[9]/div/div/p');
}

get getTwinsCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[10]/div/div/p');
}

get getPublicIpsCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[11]/div/div/p');
}

get getContractsCard() {
return cy.xpath('//*[@id="app"]/div[1]/div[3]/div/div[2]/section/div[12]/div/div/p');
}

// Navigate to the Statistics Page in the dashboard
Visit() {
return cy.visit("/explorer/statistics");
}

//Verify the stats of each card in the statistics page
VerifyStats(nodes, farms, countries, cpu, ssd, hdd, ram, accessNodes, gateways, twins, publicIps, contracts) {
this.getNodesCard.contains(nodes);

this.getFarmsCard.contains(farms);

this.getCountriesCard.contains(countries);

this.getCpuCard.contains(cpu);

this.getSsdCard.contains(ssd);

this.getHddCard.contains(hdd);

this.getRamCard.contains(ram);

this.getAccessNodesCard.contains(accessNodes);

this.getGatewaysCard.contains(gateways);

this.getTwinsCard.contains(twins);

this.getPublicIpsCard.contains(publicIps);

this.getContractsCard.contains(contracts);
VerifyStats(divNum, statName) {
cy.get(".container").find(".items").find("div").eq(divNum).find(".item__data").contains(statName);
}
}

Expand Down
2 changes: 1 addition & 1 deletion cypress/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Utils {
formatBytes(bytes, decimals = 0) {
formatBytes(bytes, decimals = 2) {
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;

Expand Down
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
preset: "@vue/cli-plugin-unit-jest/presets/typescript-and-babel",
testMatch: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
transform: {
"^.+\\.(ts|tsx)$": ["ts-jest", { tsconfig: "tsconfig-node.json" }],
},
};
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lint": "vue-cli-service lint",
"check-eslint": "eslint .eslintrc.js .",
"check-prettier": "npx prettier .prettierrc .",
"prepare": "husky install"
"prepare": "husky install",
"test": "jest"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,vue}": "eslint --fix",
Expand All @@ -36,6 +37,7 @@
"core-js": "^3.8.3",
"country-code-lookup": "^0.0.20",
"crypto-browserify": "^3.12.0",
"cypress": "^12.7.0",
"debounce": "^1.2.1",
"ethers": "^5.6.8",
"get-ip-range": "^4.0.1",
Expand Down Expand Up @@ -68,7 +70,7 @@
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@fortawesome/fontawesome-free": "^6.1.1",
"@types/debounce": "^1.2.1",
"@types/jest": "^27.0.1",
"@types/jest": "^29.4.0",
"@types/lodash": "^4.14.182",
"@types/long": "^4.0.2",
"@types/marked": "^4.0.3",
Expand All @@ -78,25 +80,21 @@
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-typescript": "~5.0.0",
"@vue/cli-plugin-unit-jest": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@vue/eslint-config-typescript": "^9.1.0",
"@vue/test-utils": "^1.1.3",
"@vue/vue2-jest": "^27.0.0-alpha.2",
"babel-jest": "^27.0.6",
"cypress-xpath": "^2.0.1",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-vue": "^8.0.3",
"husky": "^8.0.2",
"jest": "^27.0.5",
"jest": "^29.5.0",
"lint-staged": "^13.0.3",
"node-polyfill-webpack-plugin": "^1.1.4",
"prettier": "^2.7.1",
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"ts-jest": "^27.0.4",
"ts-jest": "^29.0.5",
"typescript": "~4.5.5",
"vue-cli-plugin-vuetify": "~2.4.8",
"vue-template-compiler": "^2.6.14",
Expand Down
12 changes: 0 additions & 12 deletions tests/unit/example.spec.ts

This file was deleted.

7 changes: 7 additions & 0 deletions tests/unit/example.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function sum(a: number, b: number): number {
return a + b;
}

test("adds 1 + 2 to equal 3", () => {
expect(sum(1, 2)).toBe(3);
});
mohamedamer453 marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 28 additions & 0 deletions tsconfig-node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "esnext",
"lib": [
"ESNext",
"DOM"
],
"types": [
"node",
"jest"
],
"declaration": true,
"declarationMap": true,
"outDir": "./dist/node",
"esModuleInterop": true,
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowJs": true,
"baseUrl": ".",
"skipLibCheck": true /* Skip type checking all .d.ts files. */

},
"include": [
"src/**/*"
]
}
Loading