Files
flipper/desktop/app/src/reducers/__tests__/connections.node.tsx
Anton Nikolaev 7bc38c1735 Allow selecting disabled, unsupported and not installed plugins
Summary:
This diffs removes restrictions on selecting disabled, uninstalled and unsupported plugins. Now it will be possible to select them, however for now empty view will be shown in such case.

In next diffs I'll add Plugin Info view which will be shown in case disabled plugin is selected. It will show static info about plugin - readme, version, oncall, user feedback group etc. This will make it possible for users to browse info about all plugins, even unsupported by selected device/app.

There is one problem that our analytics will be screwed by this change as even disabled plugins will be counted as used. I'll address this later in this stack.

If you see other potential problems with removing restrictions on selecting disabled plugins - please let me know.

Reviewed By: passy

Differential Revision: D29186005

fbshipit-source-id: 2e55c5fd3bb402594f4dbace6e287725de65bc6f
2021-06-29 13:02:05 -07:00

82 lines
2.6 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import reducer from '../connections';
import {State, selectPlugin} from '../connections';
import BaseDevice from '../../devices/BaseDevice';
import MacDevice from '../../devices/MacDevice';
import {FlipperDevicePlugin} from '../../plugin';
import MetroDevice from '../../devices/MetroDevice';
import {TestUtils} from 'flipper-plugin';
test('doing a double REGISTER_DEVICE keeps the last', () => {
const device1 = new BaseDevice('serial', 'physical', 'title', 'Android');
const device2 = new BaseDevice('serial', 'physical', 'title2', 'Android');
const initialState: State = reducer(undefined, {
type: 'REGISTER_DEVICE',
payload: device1,
});
expect(initialState.devices.length).toBe(1);
expect(initialState.devices[0]).toBe(device1);
const endState = reducer(initialState, {
type: 'REGISTER_DEVICE',
payload: device2,
});
expect(endState.devices.length).toBe(1);
expect(endState.devices[0]).toBe(device2);
});
test('register, remove, re-register a metro device works correctly', () => {
const device1 = new MetroDevice('http://localhost:8081', undefined);
let state: State = reducer(undefined, {
type: 'REGISTER_DEVICE',
payload: device1,
});
expect(state.devices.length).toBe(1);
expect(state.devices[0].displayTitle()).toBe('React Native');
device1.disconnect();
expect(state.devices.length).toBe(1);
expect(state.devices[0].displayTitle()).toBe('React Native (Offline)');
state = reducer(state, {
type: 'REGISTER_DEVICE',
payload: new MetroDevice('http://localhost:8081', undefined),
});
expect(state.devices.length).toBe(1);
expect(state.devices[0].displayTitle()).toBe('React Native');
expect(state.devices[0]).not.toBe(device1);
});
test('selectPlugin sets deepLinkPayload correctly', () => {
const state = reducer(
undefined,
selectPlugin({selectedPlugin: 'myPlugin', deepLinkPayload: 'myPayload'}),
);
expect(state.deepLinkPayload).toBe('myPayload');
});
test('UNREGISTER_DEVICE removes device', () => {
const device = new BaseDevice('serial', 'physical', 'title', 'Android');
const initialState: State = reducer(undefined, {
type: 'REGISTER_DEVICE',
payload: new BaseDevice('serial', 'physical', 'title', 'Android'),
});
expect(initialState.devices).toEqual([device]);
const endState = reducer(initialState, {
type: 'UNREGISTER_DEVICES',
payload: new Set(['serial']),
});
expect(endState.devices).toEqual([]);
});