Skip to content

Write a test to check that ConnectionMode.polling is enabled #205

Description

@IvoneDjaja

Is your feature request related to a problem? Please describe.
I am trying to enable polling mode in LDClient and I want to test that the polling connection mode is enabled, but I can't because config is passed to private _connectionManager and not exposed.

Enable polling mode for the SDK when testing in BrowserStack. This is done by adjusting the configuration options when initializing the SDK.
From https://support.launchdarkly.com/hc/en-us/articles/17478871815963-How-to-configure-SDK-to-be-compatible-with-BrowserStack

# my_repository/lib/ld_client.dart
Future<LDClient> initLDClient({
  required String sdkKey,
}) async {
  final context = LDContextBuilder().build();
  final client = LDClient(
    LDConfig(
      sdkKey,
      AutoEnvAttributes.enabled,
      dataSourceConfig: DataSourceConfig(
        initialConnectionMode:
            ConnectionMode.polling,
      ),
    ),
    context,
  );
  return client;
}

Describe the solution you'd like

# launchdarkly_flutter_client_sdk-4.11.1/lib/src/ld_client.dart
interface class LDClient {
  // create a getter
 ConnectionMode get connectionMode => _connectionManager.config.initialConnectionMode;
}
# my_repository/test/ld_client_test.dart
test('Should set connection to polling', () async {
  final client = await initLDClient(
    sdkKey: 'test-sdk-key',
  );
  expect(client, isA<LDClient>());
  expect(client.connectionMode, ConnectionMode.polling);
});

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context about the feature request here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions