mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-22 01:32:20 +01:00
chore: add recommanded checks from eslint-plugin-jest
chore: use jest/valid-describe-callback as it has only 2 places that fails, so I ignored them in-code
This commit is contained in:
committed by
Peter Sanderson
parent
7fb87d5a86
commit
55d663ca2d
23
.eslintrc.js
23
.eslintrc.js
@@ -25,6 +25,7 @@ module.exports = {
|
||||
'plugin:react/recommended',
|
||||
'plugin:import/typescript',
|
||||
'plugin:react-hooks/recommended',
|
||||
'plugin:jest/recommended',
|
||||
],
|
||||
settings: {
|
||||
react: {
|
||||
@@ -307,6 +308,16 @@ module.exports = {
|
||||
'error',
|
||||
{ packageNames: ['@trezor/product-components', '@trezor/components'] },
|
||||
],
|
||||
|
||||
// Jest plugin config
|
||||
'jest/valid-title': 'off', // This rule does not use Typescript and produces false positives
|
||||
'jest/no-disabled-tests': 'off', // we still have a lot of skipped tests (WIP)
|
||||
'jest/no-conditional-expect': 'off', // Todo: we shall solve this, this is bad practice
|
||||
'jest/expect-expect': 'off', // Todo: we have test with no assertions, this may be legit but it needs to be checked
|
||||
'jest/no-standalone-expect': [
|
||||
'error',
|
||||
{ additionalTestBlockFunctions: ['conditionalTest'] },
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
@@ -373,5 +384,17 @@ module.exports = {
|
||||
'import/no-default-export': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['packages/suite-web/e2e/**/*'],
|
||||
rules: {
|
||||
'jest/valid-expect': 'off', // Cypress
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['packages/connect/e2e/**/*'],
|
||||
rules: {
|
||||
'jest/no-jasmine-globals': 'off', // Kamma tests
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -131,17 +131,19 @@ backends.forEach((b, i) => {
|
||||
}, 10000);
|
||||
|
||||
describe('Event listeners', () => {
|
||||
it('Handle connect event', done => {
|
||||
blockchain.on('connected', () => done());
|
||||
blockchain.connect();
|
||||
});
|
||||
it('Handle connect event', () =>
|
||||
new Promise<void>(done => {
|
||||
blockchain.on('connected', () => done());
|
||||
blockchain.connect();
|
||||
}));
|
||||
|
||||
it('Handle disconnect event', done => {
|
||||
blockchain.on('disconnected', () => done());
|
||||
blockchain.connect().then(() => {
|
||||
blockchain.disconnect();
|
||||
});
|
||||
});
|
||||
it('Handle disconnect event', () =>
|
||||
new Promise<void>(done => {
|
||||
blockchain.on('disconnected', () => done());
|
||||
blockchain.connect().then(() => {
|
||||
blockchain.disconnect();
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,7 +111,7 @@ const fixtures = {
|
||||
],
|
||||
};
|
||||
|
||||
export const solanaApi = {
|
||||
const solanaApi = {
|
||||
getGenesisHash: () => '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d',
|
||||
getVersion: () => ({ 'feature-set': 1879391783, 'solana-core': '1.14.22' }),
|
||||
getParsedBlock: () => ({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable jest/no-jasmine-globals */
|
||||
import { BackendWebsocketServerMock } from '@trezor/e2e-utils';
|
||||
import workers from './worker';
|
||||
import BlockchainLink from '../../src';
|
||||
@@ -127,27 +128,29 @@ workers.forEach(instance => {
|
||||
expect(server.getFixtures()!.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('Handle connect event', done => {
|
||||
blockchain.on('connected', done);
|
||||
blockchain.connect().then(result => {
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
it('Handle connect event', () =>
|
||||
new Promise<void>(done => {
|
||||
blockchain.on('connected', done);
|
||||
blockchain.connect().then(result => {
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('Handle disconnect event', done => {
|
||||
blockchain.on('disconnected', done);
|
||||
blockchain.connect().then(() => {
|
||||
// TODO: ripple-lib throws error when disconnect is called immediately
|
||||
// investigate more, use setTimeout as a workaround
|
||||
// Error [ERR_UNHANDLED_ERROR]: Unhandled error. (websocket)
|
||||
// at Connection.RippleAPI.connection.on (../../node_modules/ripple-lib/src/api.ts:133:14)
|
||||
if (instance.name === 'ripple') {
|
||||
setTimeout(() => blockchain.disconnect(), 100);
|
||||
} else {
|
||||
blockchain.disconnect();
|
||||
}
|
||||
});
|
||||
});
|
||||
it('Handle disconnect event', () =>
|
||||
new Promise<void>(done => {
|
||||
blockchain.on('disconnected', done);
|
||||
blockchain.connect().then(() => {
|
||||
// TODO: ripple-lib throws error when disconnect is called immediately
|
||||
// investigate more, use setTimeout as a workaround
|
||||
// Error [ERR_UNHANDLED_ERROR]: Unhandled error. (websocket)
|
||||
// at Connection.RippleAPI.connection.on (../../node_modules/ripple-lib/src/api.ts:133:14)
|
||||
if (instance.name === 'ripple') {
|
||||
setTimeout(() => blockchain.disconnect(), 100);
|
||||
} else {
|
||||
blockchain.disconnect();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
it('Connect (only one endpoint is valid)', async () => {
|
||||
// blockfrost has only one valid endpoint
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable jest/no-jasmine-globals */
|
||||
import TinyWorker from 'tiny-worker';
|
||||
import BlockchainLink from '../../src';
|
||||
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
import { CoinjoinPrison } from '../../src/client/CoinjoinPrison';
|
||||
|
||||
describe('CoinjoinPrison', () => {
|
||||
it('release inmate when Round is no longer present in Status', done => {
|
||||
const inmate = {
|
||||
accountKey: 'account-A',
|
||||
type: 'input',
|
||||
sentenceStart: Date.now() - 10000,
|
||||
} as const;
|
||||
it('release inmate when Round is no longer present in Status', () =>
|
||||
new Promise<void>(done => {
|
||||
const inmate = {
|
||||
accountKey: 'account-A',
|
||||
type: 'input',
|
||||
sentenceStart: Date.now() - 10000,
|
||||
} as const;
|
||||
|
||||
const prison = new CoinjoinPrison([
|
||||
{ ...inmate, id: '00AA', roundId: '00', sentenceEnd: Date.now() + 10000 }, // will be released - round not present)
|
||||
{ ...inmate, id: '00AB', roundId: '00', sentenceEnd: Infinity }, // will NOT be released - sentence Infinity
|
||||
{ ...inmate, id: '01AA', roundId: '01', sentenceEnd: Date.now() + 10000 }, // wil NOT be released - round IS present
|
||||
{ ...inmate, id: '01AB', roundId: '01', sentenceEnd: Date.now() - 1 }, // will be released - sentence is lower
|
||||
]);
|
||||
const prison = new CoinjoinPrison([
|
||||
{ ...inmate, id: '00AA', roundId: '00', sentenceEnd: Date.now() + 10000 }, // will be released - round not present)
|
||||
{ ...inmate, id: '00AB', roundId: '00', sentenceEnd: Infinity }, // will NOT be released - sentence Infinity
|
||||
{ ...inmate, id: '01AA', roundId: '01', sentenceEnd: Date.now() + 10000 }, // wil NOT be released - round IS present
|
||||
{ ...inmate, id: '01AB', roundId: '01', sentenceEnd: Date.now() - 1 }, // will be released - sentence is lower
|
||||
]);
|
||||
|
||||
prison.on('change', () => done()); // end test after change event
|
||||
prison.on('change', () => done()); // end test after change event
|
||||
|
||||
prison.release(['01']); // only one round is present in Status
|
||||
prison.release(['01']); // only one round is present in Status
|
||||
|
||||
expect(prison.inmates.map(({ id }) => id)).toEqual(['00AB', '01AA']);
|
||||
});
|
||||
expect(prison.inmates.map(({ id }) => id)).toEqual(['00AB', '01AA']);
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -420,6 +420,7 @@ describe(`CoinjoinRound`, () => {
|
||||
round.on('changed', spyChanged);
|
||||
|
||||
// process but not wait for the result
|
||||
// eslint-disable-next-line jest/valid-expect-in-promise
|
||||
round.process([]).then(() => {
|
||||
expect(spyEnded).toHaveBeenCalledTimes(1);
|
||||
expect(spyChanged).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -208,25 +208,26 @@ describe('Status', () => {
|
||||
expect(identities.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('Status start and immediate stop', done => {
|
||||
status = new Status(server?.requestOptions);
|
||||
const errorListener = jest.fn();
|
||||
status.on('log', errorListener);
|
||||
const updateListener = jest.fn();
|
||||
status.on('update', updateListener);
|
||||
const requestListener = jest.fn();
|
||||
server?.addListener('test-handle-request', requestListener);
|
||||
it('Status start and immediate stop', () =>
|
||||
new Promise<void>(done => {
|
||||
status = new Status(server?.requestOptions);
|
||||
const errorListener = jest.fn();
|
||||
status.on('log', errorListener);
|
||||
const updateListener = jest.fn();
|
||||
status.on('update', updateListener);
|
||||
const requestListener = jest.fn();
|
||||
server?.addListener('test-handle-request', requestListener);
|
||||
|
||||
// start but not await
|
||||
status.start().then(() => {
|
||||
expect(requestListener).toHaveBeenCalledTimes(0); // aborted, request not sent
|
||||
expect(updateListener).toHaveBeenCalledTimes(0); // not emitted, listener removed by .stop()
|
||||
expect(errorListener).toHaveBeenCalledTimes(0); // not emitted, listener removed by .stop()
|
||||
done();
|
||||
});
|
||||
// immediate stop
|
||||
status.stop();
|
||||
});
|
||||
// start but not await
|
||||
status.start().then(() => {
|
||||
expect(requestListener).toHaveBeenCalledTimes(0); // aborted, request not sent
|
||||
expect(updateListener).toHaveBeenCalledTimes(0); // not emitted, listener removed by .stop()
|
||||
expect(errorListener).toHaveBeenCalledTimes(0); // not emitted, listener removed by .stop()
|
||||
done();
|
||||
});
|
||||
// immediate stop
|
||||
status.stop();
|
||||
}));
|
||||
|
||||
it('Status start attempts, keep lifecycle regardless of failed requests', async () => {
|
||||
jest.spyOn(STATUS_TIMEOUT, 'registered', 'get').mockReturnValue(250 as any);
|
||||
|
||||
@@ -196,38 +196,39 @@ describe('connectionConfirmation', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('connection-confirmation interval aborted, Alice unregistered', done => {
|
||||
const alice = createInput('account-A', 'A1', {
|
||||
registrationData: {
|
||||
AliceId: '01A1-01a1',
|
||||
},
|
||||
realAmountCredentials: {},
|
||||
realVsizeCredentials: {},
|
||||
});
|
||||
|
||||
const interval = confirmationInterval(
|
||||
createCoinjoinRound([alice], {
|
||||
...server?.requestOptions,
|
||||
roundParameters: {
|
||||
ConnectionConfirmationTimeout: '0d 0h 0m 2s', // intervalDelay = 1 sec
|
||||
it('connection-confirmation interval aborted, Alice unregistered', () =>
|
||||
new Promise<void>(done => {
|
||||
const alice = createInput('account-A', 'A1', {
|
||||
registrationData: {
|
||||
AliceId: '01A1-01a1',
|
||||
},
|
||||
round: {
|
||||
phaseDeadline: Date.now() + 1000, // phase will end in less than intervalDelay
|
||||
},
|
||||
}),
|
||||
alice,
|
||||
server?.requestOptions,
|
||||
);
|
||||
realAmountCredentials: {},
|
||||
realVsizeCredentials: {},
|
||||
});
|
||||
|
||||
server?.addListener('test-request', ({ url, resolve }) => {
|
||||
resolve();
|
||||
if (url.includes('input-unregistration')) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
const interval = confirmationInterval(
|
||||
createCoinjoinRound([alice], {
|
||||
...server?.requestOptions,
|
||||
roundParameters: {
|
||||
ConnectionConfirmationTimeout: '0d 0h 0m 2s', // intervalDelay = 1 sec
|
||||
},
|
||||
round: {
|
||||
phaseDeadline: Date.now() + 1000, // phase will end in less than intervalDelay
|
||||
},
|
||||
}),
|
||||
alice,
|
||||
server?.requestOptions,
|
||||
);
|
||||
|
||||
interval.abort();
|
||||
});
|
||||
server?.addListener('test-request', ({ url, resolve }) => {
|
||||
resolve();
|
||||
if (url.includes('input-unregistration')) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
interval.abort();
|
||||
}));
|
||||
|
||||
it('404 error in coordinator connection-confirmation', async () => {
|
||||
server?.addListener('test-request', ({ url, data, resolve, reject }) => {
|
||||
|
||||
@@ -146,20 +146,21 @@ describe('http', () => {
|
||||
).rejects.toThrow('Aborted by signal');
|
||||
});
|
||||
|
||||
it('successful', done => {
|
||||
coordinatorRequest('input-registration', {}, { baseUrl }).then(resp => {
|
||||
expect(resp).toMatchObject({ AliceId: expect.any(String) });
|
||||
});
|
||||
// without baseUrl
|
||||
coordinatorRequest<any>(`status`, {}, { baseUrl }).then(resp => {
|
||||
expect(resp.RoundStates.length).toEqual(1);
|
||||
});
|
||||
// without json response
|
||||
coordinatorRequest('ready-to-sign', {}, { baseUrl }).then(resp => {
|
||||
expect(resp).toEqual('');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('successful', () =>
|
||||
new Promise<void>(done => {
|
||||
coordinatorRequest('input-registration', {}, { baseUrl }).then(resp => {
|
||||
expect(resp).toMatchObject({ AliceId: expect.any(String) });
|
||||
});
|
||||
// without baseUrl
|
||||
coordinatorRequest<any>(`status`, {}, { baseUrl }).then(resp => {
|
||||
expect(resp.RoundStates.length).toEqual(1);
|
||||
});
|
||||
// without json response
|
||||
coordinatorRequest('ready-to-sign', {}, { baseUrl }).then(resp => {
|
||||
expect(resp).toEqual('');
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('with identity', async () => {
|
||||
const requestListener = jest.fn(req => {
|
||||
|
||||
@@ -342,15 +342,16 @@ describe('inputRegistration', () => {
|
||||
expect(spy.mock.calls.length).toBeGreaterThan(0);
|
||||
|
||||
// 2. wait for confirmation interval to resolve
|
||||
Promise.all(response.inputs.map(input => input.getConfirmationInterval()?.promise)).then(
|
||||
res => {
|
||||
res.forEach(input => {
|
||||
expect(input?.getConfirmationInterval()).toBeUndefined();
|
||||
});
|
||||
},
|
||||
const promises = Promise.all(
|
||||
response.inputs.map(input => input.getConfirmationInterval()?.promise),
|
||||
);
|
||||
|
||||
// 1. abort confirmation interval
|
||||
response.inputs.forEach(input => input.clearConfirmationInterval());
|
||||
|
||||
const res = await promises;
|
||||
res.forEach(input => {
|
||||
expect(input?.getConfirmationInterval()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,6 +50,7 @@ jasmine.getEnv().beforeAll(() => {
|
||||
return match;
|
||||
}, {});
|
||||
|
||||
// eslint-disable-next-line jest/no-standalone-expect
|
||||
expect(actual).toEqual(jasmine.objectContaining(nested(expected)));
|
||||
|
||||
return success;
|
||||
|
||||
@@ -110,6 +110,7 @@ describe('api/bitcoin/Fees', () => {
|
||||
|
||||
// const e2eNetworks = ['BTC', 'TEST', 'BCH', 'BTG', 'DASH', 'DGB', 'DOGE', 'LTC', 'NMC', 'VTC'];
|
||||
// e2eNetworks.forEach(network => {
|
||||
// eslint-disable-next-line jest/no-commented-out-tests
|
||||
// it.only(`${network} e2e smart FeeLevels`, async () => {
|
||||
// const coinInfo = getBitcoinNetwork(network)!;
|
||||
// if (!coinInfo) throw new Error('coinInfo is missing');
|
||||
|
||||
@@ -23,24 +23,26 @@ describe('helpers/paramsValidator', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
fixtures.getFirmwareRange.forEach(f => {
|
||||
it(f.description, done => {
|
||||
jest.resetModules();
|
||||
it(f.description, () => {
|
||||
return new Promise<void>(done => {
|
||||
jest.resetModules();
|
||||
|
||||
const mock = f.config;
|
||||
jest.mock('../../../data/config', () => {
|
||||
const actualConfig = jest.requireActual('../../../data/config').config;
|
||||
const mock = f.config;
|
||||
jest.mock('../../../data/config', () => {
|
||||
const actualConfig = jest.requireActual('../../../data/config').config;
|
||||
|
||||
return {
|
||||
__esModule: true,
|
||||
config: mock || actualConfig,
|
||||
};
|
||||
});
|
||||
return {
|
||||
__esModule: true,
|
||||
config: mock || actualConfig,
|
||||
};
|
||||
});
|
||||
|
||||
import('../paramsValidator').then(({ getFirmwareRange }) => {
|
||||
// added new capability
|
||||
// @ts-expect-error
|
||||
expect(getFirmwareRange(...f.params)).toEqual(f.result);
|
||||
done();
|
||||
import('../paramsValidator').then(({ getFirmwareRange }) => {
|
||||
// added new capability
|
||||
// @ts-expect-error
|
||||
expect(getFirmwareRange(...f.params)).toEqual(f.result);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('helpers/ethereumSignTypeData', () => {
|
||||
fixtures.parseArrayType.forEach(f => {
|
||||
it(`${f.description} - ${f.input}`, () => {
|
||||
if (f.error) {
|
||||
expect(() => parseArrayType(f.input)).toThrowError(...f.error);
|
||||
expect(() => parseArrayType(f.input)).toThrow(...f.error);
|
||||
} else {
|
||||
expect(parseArrayType(f.input)).toEqual(f.output);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ describe('helpers/ethereumSignTypeData', () => {
|
||||
const { typeName, types } = f.input;
|
||||
it(`${f.description} - ${typeName}`, () => {
|
||||
if (f.error) {
|
||||
expect(() => getFieldType(typeName, types as any)).toThrowError(...f.error);
|
||||
expect(() => getFieldType(typeName, types as any)).toThrow(...f.error);
|
||||
} else {
|
||||
expect(getFieldType(typeName, types as any)).toEqual(f.output);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ describe('helpers/ethereumSignTypeData', () => {
|
||||
const { typeName, data } = f.input;
|
||||
it(`${f.description}`, () => {
|
||||
if (f.error) {
|
||||
expect(() => encodeData(typeName, data)).toThrowError(...f.error);
|
||||
expect(() => encodeData(typeName, data)).toThrow(...f.error);
|
||||
} else {
|
||||
expect(encodeData(typeName, data)).toEqual(f.output);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,6 @@ describe('firmware/calculateFirmwareHash', () => {
|
||||
});
|
||||
|
||||
it('Firmware too big', () => {
|
||||
expect(() => calculateFirmwareHash(2, Buffer.alloc(100000000))).toThrowError(
|
||||
'Firmware too big',
|
||||
);
|
||||
expect(() => calculateFirmwareHash(2, Buffer.alloc(100000000))).toThrow('Firmware too big');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,6 +32,7 @@ describe('data/DataManager', () => {
|
||||
try {
|
||||
await DataManager.load(settings, false);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line jest/no-standalone-expect
|
||||
expect(err).toBe(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,6 +20,5 @@ describe('utils/accountUtils', () => {
|
||||
|
||||
// todo:
|
||||
describe.skip('getAccountAddressN', () => {});
|
||||
describe.skip('getAccountLabel', () => {});
|
||||
describe.skip('getPublicKeyLabel', () => {});
|
||||
});
|
||||
|
||||
@@ -223,54 +223,56 @@ describe('utils/deviceFeaturesUtils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('T2T1 update-required', done => {
|
||||
jest.resetModules();
|
||||
it('T2T1 update-required', () =>
|
||||
new Promise<void>(done => {
|
||||
jest.resetModules();
|
||||
|
||||
jest.mock('../../data/config', () => ({
|
||||
__esModule: true,
|
||||
config: {
|
||||
supportedFirmware: [
|
||||
{
|
||||
min: { T1B1: '0', T2T1: '2.99.99' },
|
||||
capabilities: ['newCapabilityOrFeature'],
|
||||
},
|
||||
],
|
||||
},
|
||||
jest.mock('../../data/config', () => ({
|
||||
__esModule: true,
|
||||
config: {
|
||||
supportedFirmware: [
|
||||
{
|
||||
min: { T1B1: '0', T2T1: '2.99.99' },
|
||||
capabilities: ['newCapabilityOrFeature'],
|
||||
},
|
||||
],
|
||||
},
|
||||
}));
|
||||
|
||||
import('../deviceFeaturesUtils').then(({ getUnavailableCapabilities }) => {
|
||||
// added new capability
|
||||
expect(getUnavailableCapabilities(featT2T1, coins)).toEqual({
|
||||
newCapabilityOrFeature: 'update-required',
|
||||
});
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
import('../deviceFeaturesUtils').then(({ getUnavailableCapabilities }) => {
|
||||
// added new capability
|
||||
expect(getUnavailableCapabilities(featT2T1, coins)).toEqual({
|
||||
newCapabilityOrFeature: 'update-required',
|
||||
it('T2T1 no-support', () =>
|
||||
new Promise<void>(done => {
|
||||
jest.resetModules();
|
||||
|
||||
jest.mock('../../data/config', () => ({
|
||||
__esModule: true,
|
||||
config: {
|
||||
supportedFirmware: [
|
||||
{
|
||||
min: { T1B1: '0', T2T1: '0' },
|
||||
capabilities: ['newCapabilityOrFeature'],
|
||||
},
|
||||
],
|
||||
},
|
||||
}));
|
||||
|
||||
import('../deviceFeaturesUtils').then(({ getUnavailableCapabilities }) => {
|
||||
// added new capability
|
||||
expect(getUnavailableCapabilities(featT2T1, coins)).toEqual({
|
||||
newCapabilityOrFeature: 'no-support',
|
||||
});
|
||||
done();
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('T2T1 no-support', done => {
|
||||
jest.resetModules();
|
||||
|
||||
jest.mock('../../data/config', () => ({
|
||||
__esModule: true,
|
||||
config: {
|
||||
supportedFirmware: [
|
||||
{
|
||||
min: { T1B1: '0', T2T1: '0' },
|
||||
capabilities: ['newCapabilityOrFeature'],
|
||||
},
|
||||
],
|
||||
},
|
||||
}));
|
||||
|
||||
import('../deviceFeaturesUtils').then(({ getUnavailableCapabilities }) => {
|
||||
// added new capability
|
||||
expect(getUnavailableCapabilities(featT2T1, coins)).toEqual({
|
||||
newCapabilityOrFeature: 'no-support',
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('handles duplicated shortcuts correctly, ', () => {
|
||||
const customCoins = [
|
||||
{ shortcut: 'BNB', type: 'ethereum', support: { T2T1: '2.4.4' } },
|
||||
|
||||
@@ -26,14 +26,17 @@ describe('HttpServer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(done => {
|
||||
server.stop().finally(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
afterEach(
|
||||
() =>
|
||||
new Promise<void>(done => {
|
||||
server.stop().finally(() => {
|
||||
done();
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
test('getServerAddress before server start', () => {
|
||||
expect(() => server.getServerAddress()).toThrowError();
|
||||
expect(() => server.getServerAddress()).toThrow();
|
||||
});
|
||||
|
||||
test('getServerAddress after server start', async () => {
|
||||
|
||||
@@ -541,6 +541,6 @@ describe('Real messages', () => {
|
||||
expect(() => {
|
||||
// @ts-expect-error
|
||||
encode(null, {});
|
||||
}).toThrowError();
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,21 +11,23 @@ describe('DesktopApi', () => {
|
||||
});
|
||||
|
||||
describe('Events', () => {
|
||||
it('DesktopApi.on omits event param', done => {
|
||||
api.on('tor/status', state => {
|
||||
expect(state).toBe(true);
|
||||
done();
|
||||
});
|
||||
ipcRenderer.emit('tor/status', new Event('ipc'), true); // Event param should be omitted
|
||||
});
|
||||
it('DesktopApi.on omits event param', () =>
|
||||
new Promise<void>(done => {
|
||||
api.on('tor/status', state => {
|
||||
expect(state).toBe(true);
|
||||
done();
|
||||
});
|
||||
ipcRenderer.emit('tor/status', new Event('ipc'), true); // Event param should be omitted
|
||||
}));
|
||||
|
||||
it('DesktopApi.once omits event param', done => {
|
||||
api.once('tor/status', state => {
|
||||
expect(state).toBe(true);
|
||||
done();
|
||||
});
|
||||
ipcRenderer.emit('tor/status', new Event('ipc'), true); // Event param should be omitted
|
||||
});
|
||||
it('DesktopApi.once omits event param', () =>
|
||||
new Promise<void>(done => {
|
||||
api.once('tor/status', state => {
|
||||
expect(state).toBe(true);
|
||||
done();
|
||||
});
|
||||
ipcRenderer.emit('tor/status', new Event('ipc'), true); // Event param should be omitted
|
||||
}));
|
||||
|
||||
it('DesktopApi.removeAllListener', () => {
|
||||
const spy = jest.fn();
|
||||
|
||||
@@ -3,7 +3,7 @@ import { factory } from '../factory';
|
||||
import { ipcRenderer } from './ipcRenderer';
|
||||
|
||||
describe('Renderer', () => {
|
||||
it('api is not defined', () => {
|
||||
it('api is not defined', async () => {
|
||||
const spyError = jest.spyOn(console, 'error').mockImplementation();
|
||||
expect(desktopApi.available).toBe(false);
|
||||
desktopApi.on('protocol/open', () => {});
|
||||
@@ -11,7 +11,7 @@ describe('Renderer', () => {
|
||||
desktopApi.removeAllListeners('protocol/open');
|
||||
desktopApi.clearStore();
|
||||
expect(spyError).toHaveBeenCalledTimes(4);
|
||||
expect(desktopApi.metadataRead({ file: 'foo.txt' })).rejects.toThrow();
|
||||
await expect(desktopApi.metadataRead({ file: 'foo.txt' })).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('api is defined', () => {
|
||||
|
||||
@@ -228,5 +228,3 @@ describe('Analytics Events', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -160,5 +160,3 @@ describe('Analytics Toggle - Enablement and Disablement', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -52,5 +52,3 @@ describe('Backup fail', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -68,5 +68,3 @@ describe('Backup misc', () => {
|
||||
cy.getTestElement('@backup/no-device');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -64,5 +64,3 @@ describe('Backup success', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -63,5 +63,3 @@ describe('Backup success', () => {
|
||||
onMultiShareBackupModal.finalizeMultiShareBackup();
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -30,5 +30,3 @@ describe('Android with non-chrome browser', () => {
|
||||
cy.getTestElement('@welcome/title');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -21,5 +21,3 @@ describe('iPhone with chrome browser ', () => {
|
||||
cy.get('html').should('not.contain.text', 'Continue at my own risk');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -32,5 +32,3 @@ describe('Windows 7 with outdated chrome ', () => {
|
||||
cy.getTestElement('@welcome/title');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -32,5 +32,3 @@ describe('Ubuntu with outdated firefox ', () => {
|
||||
cy.getTestElement('@welcome/title');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -31,5 +31,3 @@ describe('Safari on MacOS 14 ', () => {
|
||||
cy.getTestElement('@welcome/title');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -196,5 +196,3 @@ describe('Coinmarket buy', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -203,5 +203,3 @@ describe.skip('Coinmarket exchange', () => {
|
||||
cy.getTestElement('@coinmarket/exchange/payment/back-to-account').click();
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -75,5 +75,3 @@ describe.skip('Assets', () => {
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -39,5 +39,3 @@ describe('Dashboard', () => {
|
||||
// QA todo: test for graph
|
||||
// QA todo: dashboard appearance for seed with tx history vs seed without tx history
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -51,5 +51,3 @@ describe('Dashboard', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -59,5 +59,3 @@ describe('Firmware', () => {
|
||||
// );
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -122,5 +122,3 @@ Hovering over fields that may be labeled shows "add label" button upon which is
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -40,5 +40,3 @@ describe('Metadata - address labeling', () => {
|
||||
cy.getTestElement('@metadata/input').type(' meoew meow{enter}');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -189,5 +189,3 @@ describe('Dropbox api errors', () => {
|
||||
|
||||
// todo: add more possible errors
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -67,5 +67,3 @@ describe('Google api errors', () => {
|
||||
// todo: add more possible errors
|
||||
// https://developers.google.com/drive/api/v3/handle-errors
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -92,5 +92,3 @@ describe('Metadata - suite is watching cloud provider and syncs periodically', (
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -110,5 +110,3 @@ describe('Metadata - cancel metadata on device', () => {
|
||||
cy.task('pressNo');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -109,5 +109,3 @@ describe('Metadata - Output labeling', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -161,5 +161,3 @@ describe(
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
export {};
|
||||
|
||||
@@ -59,5 +59,3 @@ describe(`Metadata - switching between cloud providers`, () => {
|
||||
cy.getTestElement('@account-menu/btc/normal/0/label').should('contain', 'google label');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -151,5 +151,3 @@ describe('Metadata - wallet labeling', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -29,5 +29,3 @@ describe('Onboarding - analytics consent', () => {
|
||||
cy.getTestElement('@wallet/menu/wallet-send');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -100,5 +100,3 @@ describe.skip('fw update from empty device bootloader 2.0.3 to firmware 2.5.1',
|
||||
}).click();
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -69,5 +69,3 @@ describe('Onboarding - create wallet', () => {
|
||||
cy.getTestElement('@pin/input/1');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -47,5 +47,3 @@ describe('Onboarding - recover wallet T1B1', () => {
|
||||
// todo: finish reading from device. needs support in trezor-user-env
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -47,5 +47,3 @@ describe('Onboarding - recover wallet T1B1', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -78,5 +78,3 @@ describe('Onboarding - recover wallet T1B1', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -45,5 +45,3 @@ describe('Onboarding - create wallet', () => {
|
||||
cy.getTestElement('@onboarding/pin/continue-button');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -54,5 +54,3 @@ describe('Onboarding - recover wallet T2T1', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -138,5 +138,3 @@ describe('Onboarding - T2T1 in recovery mode', () => {
|
||||
cy.getTestElement('@onboarding/skip-button').click();
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -58,5 +58,3 @@ describe('Onboarding - recover wallet T2T1', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -13,5 +13,3 @@ describe('Onboarding - transport webusb/bridge', () => {
|
||||
cy.getTestElement('@connect-device-prompt/no-device-detected').click();
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -24,5 +24,3 @@ describe.skip('Recovery - dry run', () => {
|
||||
// todo: elaborate more, seems like finally T1B1 tests are stable so it would make finally sense to finish this
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -61,5 +61,3 @@ describe('Recovery - dry run', () => {
|
||||
cy.getTestElement('@recovery/success-title');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -30,5 +30,3 @@ describe('ApplicationLog', () => {
|
||||
// todo: check it really exports something;
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -32,5 +32,3 @@ describe('Language and theme detection', () => {
|
||||
cy.get('body').should('have.css', 'background-color', 'rgb(23, 23, 23)');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -130,5 +130,3 @@ describe('Coin Settings', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -62,5 +62,3 @@ describe('Install custom firmware', () => {
|
||||
cy.getTestElement('@firmware/reconnect-device').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -105,5 +105,3 @@ describe('General settings', () => {
|
||||
// cy.getTestElement('@onboarding/welcome', { timeout: 20000 }).should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -41,5 +41,3 @@ describe('Check notification toast', () => {
|
||||
cy.getTestElement('@toast/settings-applied').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -74,5 +74,3 @@ describe('Safety Checks Settings', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -93,5 +93,3 @@ describe('T1B1 - Device settings', () => {
|
||||
// TODO: keyboard handling
|
||||
// TODO: set auto-lock (needs pin)
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -148,5 +148,3 @@ describe('T2B1 - Device settings', () => {
|
||||
cy.task('pressYes');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -136,5 +136,3 @@ describe('T2T1 - Device settings', () => {
|
||||
// TODO: upload custom image
|
||||
// TODO: set auto-lock (needs pin)
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -36,5 +36,3 @@ describe('Settings changes persist when device disconnected', () => {
|
||||
cy.location('pathname').should('match', /\/accounts\/send$/);
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -20,5 +20,3 @@ describe('Bridge page', () => {
|
||||
cy.getTestElement('@connect-device-prompt');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -47,5 +47,3 @@ describe('Stories of bug report forms', () => {
|
||||
cy.getTestElement('@toast/user-feedback-send-success').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -169,5 +169,3 @@ describe('Database migration', () => {
|
||||
cy.get('body').should('have.css', 'background-color', 'rgb(23, 23, 23)');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -68,5 +68,3 @@ describe('Test Guide', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -36,5 +36,3 @@ describe('Suite initial run', () => {
|
||||
cy.getTestElement('@menu/switch-device').should('contain.text', 'Connected');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -35,5 +35,3 @@ describe('Passphrase cancel', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -92,5 +92,3 @@ describe('Passphrase with cardano', () => {
|
||||
cy.getTestElement('@toast/verify-address-error');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -68,5 +68,3 @@ describe.skip('Suite switch wallet modal', () => {
|
||||
cy.getTestElement('@menu/switch-device').click();
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -43,5 +43,3 @@ describe('Passphrase', () => {
|
||||
// QA todo: continue to discovered wallet
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -76,5 +76,3 @@ describe('Passphrase', () => {
|
||||
// todo: select part of test + copy/paste
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -66,5 +66,3 @@ describe('Passphrase numbering', () => {
|
||||
|
||||
// TODO: add coverage for different wallet names displaying in the device switcher component
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -165,5 +165,3 @@ describe('Passphrase', () => {
|
||||
cy.task('pressYes');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -6,6 +6,7 @@ import { onNavBar } from '../../support/pageObjects/topBarObject';
|
||||
|
||||
// TODO: enable this test once https://github.com/trezor/trezor-user-env/issues/54
|
||||
// is resolved
|
||||
// eslint-disable-next-line jest/no-commented-out-tests
|
||||
// describe('safety_checks Warning For PromptAlways', () => {
|
||||
// beforeEach(() => {
|
||||
// cy.task('startEmu', { wipe: true });
|
||||
@@ -17,6 +18,7 @@ import { onNavBar } from '../../support/pageObjects/topBarObject';
|
||||
// // TODO: set safety_checks to `PromptAlways`
|
||||
// });
|
||||
|
||||
// eslint-disable-next-line jest/no-commented-out-tests
|
||||
// it('Non-dismissible warning appears', () => {
|
||||
// cy.getTestElement('@banner/safety-checks/button');
|
||||
// cy.getTestElement('@banner/safety-checks/dismiss').should('not.exist');
|
||||
@@ -102,5 +104,3 @@ describe('safety_checks Warning For PromptTemporarily', () => {
|
||||
cy.getTestElement('@banner/safety-checks/button');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -24,7 +24,6 @@ describe.skip('Test tooltip links', () => {
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
// TODO: review this test if it's indeed obsolete
|
||||
describe.skip('Test tooltip conditional rendering', () => {
|
||||
beforeEach(() => {
|
||||
@@ -60,5 +59,3 @@ describe.skip('Test tooltip conditional rendering', () => {
|
||||
.should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -34,5 +34,3 @@ describe('unacquired device', () => {
|
||||
// - also firmware update, maybe standalone backup/recovery might have custom implementation that might be worth revisiting
|
||||
// - device state is incorrect is wrong copy!!!
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -15,5 +15,3 @@ describe('There is a hidden route (not accessible in UI)', () => {
|
||||
cy.getTestElement('@modal/version').screenshot('version-modal');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -163,5 +163,3 @@ describe('Account types suite', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -75,5 +75,3 @@ describe('Cardano', () => {
|
||||
cy.getTestElement('@app').matchImageSnapshot('staking-not-enabled');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -54,5 +54,3 @@ describe('Check coins XPUB', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -45,5 +45,3 @@ describe('Dashboard with regtest', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -95,5 +95,3 @@ describe('Custom-blockbook-discovery', () => {
|
||||
cy.getTestElement('@dashboard/graph').should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -49,5 +49,3 @@ describe('Discovery', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -73,5 +73,3 @@ describe('Export transactions', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -75,5 +75,3 @@ describe('Import a BTC csv file', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -46,5 +46,3 @@ describe('Look up a BTC account', () => {
|
||||
cy.getTestElement('@account-menu/ltc/normal/0').should('not.exist');
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
@@ -51,5 +51,3 @@ describe('Overview and transactions check', () => {
|
||||
onAccountsPage.accountsPaginationCheck();
|
||||
});
|
||||
});
|
||||
|
||||
export {};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user