test(status-pill): add StatusPill tests
This commit is contained in:
parent
e918f319ba
commit
8fc737081a
|
@ -0,0 +1,20 @@
|
||||||
|
// @flow
|
||||||
|
import { getApp } from '../setup/utils';
|
||||||
|
|
||||||
|
const app = getApp();
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await app.start();
|
||||||
|
await app.client.waitUntilWindowLoaded();
|
||||||
|
await app.client.waitUntilTextExists('#sidebar', 'Dashboard', 120000);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => app.stop());
|
||||||
|
|
||||||
|
describe('Status Pill', () => {
|
||||||
|
test('should show status pill in the header', async () => expect(
|
||||||
|
app.client
|
||||||
|
.waitUntilTextExists('#status-pill', '50.00%')
|
||||||
|
.getText('#status-pill'),
|
||||||
|
).resolves.toEqual(expect.stringContaining('50.00%')));
|
||||||
|
});
|
|
@ -78,25 +78,25 @@ export class StatusPill extends Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
getBlockchainStatus = async () => {
|
getBlockchainStatus = async () => {
|
||||||
const [blockchainErr, blockchaininfo] = await eres(
|
const [blockchainErr, blockchaininfo] = await eres(rpc.getblockchaininfo());
|
||||||
rpc.getblockchaininfo(),
|
|
||||||
);
|
|
||||||
|
|
||||||
const newProgress = blockchaininfo.verificationprogress * 100;
|
const newProgress = blockchaininfo.verificationprogress * 100;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
progress: newProgress,
|
progress: newProgress,
|
||||||
...(newProgress > 99.99 ? {
|
...(newProgress > 99.99
|
||||||
type: 'ready',
|
? {
|
||||||
icon: readyIcon,
|
type: 'ready',
|
||||||
isSynching: false,
|
icon: readyIcon,
|
||||||
} : {}),
|
isSynching: false,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (blockchainErr) {
|
if (blockchainErr) {
|
||||||
this.setState(() => ({ type: 'error', icon: errorIcon }));
|
this.setState(() => ({ type: 'error', icon: errorIcon }));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
|
@ -105,7 +105,7 @@ export class StatusPill extends Component<Props, State> {
|
||||||
const showPercent = isSynching ? `(${progress.toFixed(2)}%)` : '';
|
const showPercent = isSynching ? `(${progress.toFixed(2)}%)` : '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper id='status-pill'>
|
||||||
<Icon src={icon} animated={isSynching} />
|
<Icon src={icon} animated={isSynching} />
|
||||||
<StatusPillLabel value={`${type} ${showPercent}`} />
|
<StatusPillLabel value={`${type} ${showPercent}`} />
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
|
|
Loading…
Reference in New Issue