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

build(deps): bump yaml and stylelint #1180

Open
wants to merge 7 commits into
base: dev
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
6 changes: 4 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
quote_type = single
max_line_length = 140
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ rules:
- tab
- ignoredNodes:
- TemplateLiteral
no-mixed-spaces-and-tabs:
- error

2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:lts-alpine AS builder
RUN apk add --no-cache python3 make g++
ENV NODE_OPTIONS="--dns-result-order=ipv4first --openssl-legacy-provider"
WORKDIR /app
COPY . .
RUN npm install && npm run build
Expand Down
47 changes: 47 additions & 0 deletions __tests__/TestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,53 @@ const TestHelper = {
cosignatures,
innerTransactions
};
},
generateNodePeerStatus: isAvailable => {
return {
isAvailable,
lastStatusCheck: 1676809816662
};
},
generateNodeApiStatus: isAvailable => {
return {
isAvailable,
nodePublicKey: '4DA6FB57FA168EEBBCB68DA4DDC8DA7BCF41EC93FB22A33DF510DB0F2670F623',
chainHeight: 2027193,
finalization: {
height: 2031992,
epoch: 1413,
point: 7,
hash: '6B687D9B689611C90A1094A7430E78914F22A2570C80D3E42D520EB08091A973'
},
nodeStatus: {
apiNode: 'up',
db: 'up'
},
restVersion: '2.4.2',
restGatewayUrl: 'localhost.com',
isHttpsEnabled: true
};
},
nodeCommonField: {
version: 16777989,
publicKey: '016DC1622EE42EF9E4D215FA1112E89040DD7AED83007283725CE9BA550272F5',
networkGenerationHashSeed: '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6',
port: 7900,
networkIdentifier: 104,
host: 'node.com',
friendlyName: 'node',
lastAvailable: '2023-02-19T12:36:04.524Z',
hostDetail: {},
location: '',
ip: '127.0.0.1',
organization: '',
as: '',
continent: '',
country: '',
region: '',
city: '',
district: '',
zip: ''
}
};

Expand Down
121 changes: 121 additions & 0 deletions __tests__/components/widgets/NodeStatsWidget.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import NodeStatsWidget from '../../../src/components/widgets/NodeStatsWidget.vue';
import { i18n } from '../../../src/config';
import { createLocalVue, mount } from '@vue/test-utils';
import Vuex from 'vuex';

const setupStoreMount = stats => {
const nodeModule = {
namespaced: true,
getters: {
nodeStats:() => stats
}
};

const uiModule = {
namespaced: true,
getters: {
getNameByKey: state => key => i18n.getName(key)
}
};

const store = new Vuex.Store({
modules: {
node: nodeModule,
ui:uiModule
}
});

const propsData = {
dataGetter: 'node/nodeStats'
};

return mount(NodeStatsWidget, {
store,
localVue,
propsData,
stubs: {
'b-card': true,
'b-container': true,
'b-row': true,
'b-col': true,
'b-button': true,
'router-link': true
}
});
};

const localVue = createLocalVue();
localVue.use(Vuex);

describe('NodeStatsWidget', () => {
describe('nodeRoles', () => {
const assertNodeStatCounts = (stats, expected) => {
// Arrange + Act:
const wrapper = setupStoreMount(stats);

// Assert:
expect(wrapper.vm.nodeRoles).toEqual(expected);
};

const generateNodeStats = stats => {
return [
{
name: 'Total count',
count: stats.reduce((acc, val) => acc + val, 0)
},
{
name: 'Peer node',
count: stats[0]
},
{
name: 'Api node',
count: stats[1]
},
{
name: 'Peer Api node',
count: stats[2]
},
{
name: 'Voting node',
count: stats[3]
},
{
name: 'Peer Voting node',
count: stats[4]
},
{
name: 'Api Voting node',
count: stats[5]
},
{
name: 'Peer Api Voting node',
count: stats[6]
}
];
};

it('returns node types stats when data is present', () => {
assertNodeStatCounts(
{
1: 3,
2: 7,
3: 4,
4: 6,
5: 8,
6: 12,
7: 5
},
generateNodeStats([3, 7, 4, 6, 8, 12, 5])
);
});

it('returns node types stats with 0 count when no data is present', () => {
assertNodeStatCounts(
{},
generateNodeStats([0, 0, 0, 0, 0, 0, 0])
);
});

it('returns empty when data is undefined', () => assertNodeStatCounts(undefined, []));
});
});
Loading