Keep Navigation plugin alive even when disabled

Summary:
Navigation plugin is a special cause that will remain connected and process messages directly even when disabled, this is to make sure the bookmarks feature keeps working even when the plugin is not enabled.

Changelog: [Sandy][Navigation] on Android, the currently active deeplink of the application will now be shown in the sidebar

Reviewed By: jknoxville

Differential Revision: D24890375

fbshipit-source-id: eb5e4141740e0436396cea5a7aae24337f2e903e
This commit is contained in:
Michel Weststrate
2020-11-12 04:13:16 -08:00
committed by Facebook GitHub Bot
parent 273b895e30
commit b66f452271
4 changed files with 122 additions and 4 deletions

View File

@@ -210,6 +210,56 @@ test('queue - events are NOT processed immediately if plugin is NOT selected (bu
});
});
test('queue - events ARE processed immediately if plugin is NOT selected / enabled BUT NAVIGATION', async () => {
const NavigationPlugin = new SandyPluginDefinition(
TestUtils.createMockPluginDetails({
id: 'Navigation',
}),
{
plugin,
Component() {
return null;
},
},
);
const {store, client, sendMessage} = await createMockFlipperWithPlugin(
NavigationPlugin,
);
// Pre setup, deselect AND disable
selectDeviceLogs(store);
expect(store.getState().connections.selectedPlugin).toBe('DeviceLogs');
store.dispatch(
starPlugin({
plugin: NavigationPlugin,
selectedApp: client.query.app,
}),
);
expect(store.getState().connections.userStarredPlugins)
.toMatchInlineSnapshot(`
Object {
"TestApp": Array [],
}
`);
// ...mesages are still going to arrive
const pluginState = () =>
client.sandyPluginStates.get(NavigationPlugin.id)!.instanceApi.state;
sendMessage('inc', {});
sendMessage('inc', {delta: 2});
sendMessage('inc', {delta: 3});
// the first message is already visible cause of the leading debounce
expect(pluginState().count).toBe(1);
// message queue was never involved due to the bypass...
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(
`Object {}`,
);
// flush will make the others visible
client.flushMessageBuffer();
expect(pluginState().count).toBe(6);
});
test('queue - events are queued for plugins that are favorite when app is not selected', async () => {
const {
client,