From a27b2f1f164edc2f4ca45e34c9de58565da09208 Mon Sep 17 00:00:00 2001 From: cbullinger Date: Sat, 4 May 2024 11:31:02 -0400 Subject: [PATCH] Update tests to skip in CI --- examples/dart/test/app_services_test.dart | 40 ++++++----- ...services_test.snippet.change-base-url.dart | 5 +- ...services_test.snippet.custom-base-url.dart | 7 +- ...ices_test.snippet.import-experimental.dart | 1 - .../flutter/app-services/connect-to-app.txt | 72 +++++++++---------- 5 files changed, 64 insertions(+), 61 deletions(-) delete mode 100644 source/examples/generated/flutter/app_services_test.snippet.import-experimental.dart diff --git a/examples/dart/test/app_services_test.dart b/examples/dart/test/app_services_test.dart index 16ddeaa876..622ef460f6 100644 --- a/examples/dart/test/app_services_test.dart +++ b/examples/dart/test/app_services_test.dart @@ -1,14 +1,15 @@ -import "dart:html_common"; - import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import "dart:io"; import "dart:convert"; import "dart:isolate"; +import 'utils.dart'; void main() { const APP_ID = "example-testers-kvjdy"; - const EDGE_SERVER_APP_ID = "edge-server-npqxd"; + const EDGE_SERVER_APP_ID = "sync-edge-server-cskhoow"; + const baseUrl = 'http://localhost'; + const newBaseUrl = 'https://services.cloud.mongodb.com'; group('App Services client - ', () { test('Access App client', () { @@ -33,36 +34,39 @@ void main() { }); test('Custom BaseUrl', () { - // :snippet-start: import-experimental - @Experimental() - // :snippet-end: - // :snippet-start: custom-base-url - // Specify a baseUrl to connect to a server other than the default. - // In this case, an Edge Server instance running on the device. - final appConfig = AppConfiguration(EDGE_SERVER_APP_ID, - baseUrl: Uri.parse('http://localhost:80')); + // :snippet-start: custom-base-url + // Specify a baseUrl to connect to a server other than the default + final appConfig = + AppConfiguration(APP_ID, baseUrl: Uri.parse('https://example.com')); var app = App(appConfig); // :snippet-end: - expect(app.baseUrl.toString(), 'http://localhost:80'); + expect(app.baseUrl.toString(), 'https://example.com'); }); - test('Change BaseUrl', () { - @Experimental() + test('Change BaseUrl', () async { // :snippet-start: change-base-url // Specify a custom baseUrl to connect to. + // In this case, final appConfig = AppConfiguration(EDGE_SERVER_APP_ID, baseUrl: Uri.parse('http://localhost:80')); var app = App(appConfig); - expect(app.baseUrl.toString(), 'http://localhost:80'); // :remove: // ... log in a user and use the app ... + // :remove-start: + expect(app.baseUrl.toString(), baseUrl); + await app.logIn(Credentials.anonymous()); + expect(app.currentUser != null, true); + // :remove-end: - // Later, change the baseUrl to a different server - app.updateBaseUrl(Uri.parse('https://services.cloud.mongodb.com')); + // Later, change the baseUrl to the default: https://services.cloud.mongodb.com + await app.updateBaseUrl(null); // :snippet-end: - }); + expect(app.baseUrl.toString(), newBaseUrl); + }, + skip: + """Skipping until we get Edge Server running in a CI and we can write automated tests for full flow (this was tested locally and succeeded)"""); test('Access App on background isolate by id', () async { // :snippet-start: access-app-by-id diff --git a/source/examples/generated/flutter/app_services_test.snippet.change-base-url.dart b/source/examples/generated/flutter/app_services_test.snippet.change-base-url.dart index 31b446412e..37fcd13a82 100644 --- a/source/examples/generated/flutter/app_services_test.snippet.change-base-url.dart +++ b/source/examples/generated/flutter/app_services_test.snippet.change-base-url.dart @@ -1,4 +1,5 @@ // Specify a custom baseUrl to connect to. +// In this case, final appConfig = AppConfiguration(EDGE_SERVER_APP_ID, baseUrl: Uri.parse('http://localhost:80')); @@ -6,5 +7,5 @@ var app = App(appConfig); // ... log in a user and use the app ... -// Later, change the baseUrl to a different server -app.updateBaseUrl(Uri.parse('https://services.cloud.mongodb.com')); +// Later, change the baseUrl to the default: https://services.cloud.mongodb.com +await app.updateBaseUrl(null); diff --git a/source/examples/generated/flutter/app_services_test.snippet.custom-base-url.dart b/source/examples/generated/flutter/app_services_test.snippet.custom-base-url.dart index 51d577114a..8ee460fc4a 100644 --- a/source/examples/generated/flutter/app_services_test.snippet.custom-base-url.dart +++ b/source/examples/generated/flutter/app_services_test.snippet.custom-base-url.dart @@ -1,6 +1,5 @@ - // Specify a baseUrl to connect to a server other than the default. - // In this case, an Edge Server instance running on the device. - final appConfig = AppConfiguration(EDGE_SERVER_APP_ID, - baseUrl: Uri.parse('http://localhost:80')); +// Specify a baseUrl to connect to a server other than the default +final appConfig = + AppConfiguration(APP_ID, baseUrl: Uri.parse('https://example.com')); var app = App(appConfig); diff --git a/source/examples/generated/flutter/app_services_test.snippet.import-experimental.dart b/source/examples/generated/flutter/app_services_test.snippet.import-experimental.dart deleted file mode 100644 index e44d44a229..0000000000 --- a/source/examples/generated/flutter/app_services_test.snippet.import-experimental.dart +++ /dev/null @@ -1 +0,0 @@ -@Experimental() diff --git a/source/sdk/flutter/app-services/connect-to-app.txt b/source/sdk/flutter/app-services/connect-to-app.txt index 6a9e53fdc3..b9798649c8 100644 --- a/source/sdk/flutter/app-services/connect-to-app.txt +++ b/source/sdk/flutter/app-services/connect-to-app.txt @@ -36,44 +36,44 @@ Access the App Client .. versionchanged:: 1.7.0 ``App`` must be created on the main isolate. -Create an ``App`` instance to access App Services features throughout your -client application. We recommend that you create the ``App`` instance only +Create an ``App`` instance to access App Services features throughout your +client application. We recommend that you create the ``App`` instance only once on the main isolate, ideally as soon as the app starts. -#. Get your App Services App's ID from the App Services UI. To learn how, +#. Get your App Services App's ID from the App Services UI. To learn how, refer to :ref:`Find your App ID `. #. Create an :flutter-sdk:`AppConfiguration ` object with your App's App ID as the argument. #. Create an :flutter-sdk:`App ` - with the ``AppConfiguration`` you just created. In Flutter v1.7.0 and later, - this must be done on the main isolate, otherwise the SDK throws an error. + with the ``AppConfiguration`` you just created. In Flutter v1.7.0 and later, + this must be done on the main isolate, otherwise the SDK throws an error. -After you create the ``App``, you can access the constructed ``App`` instance +After you create the ``App``, you can access the constructed ``App`` instance on a background isolate using ``App.getById``. Refer to the -:ref:`Get App by ID ` section on this page for more +:ref:`Get App by ID ` section on this page for more information. .. literalinclude:: /examples/generated/flutter/app_services_test.snippet.access-app-client.dart :language: dart You can create multiple App client instances to connect to multiple -Apps. All App client instances that share the same App ID use the same +Apps. All App client instances that share the same App ID use the same underlying connection. .. important:: Changing an App Config After Initializing the App .. versionchanged:: 1.8.0 ``baseUrl`` is not cached in the ``AppConfiguration`` - - When you initialize the App client, the configuration is cached internally. + + When you initialize the App client, the configuration is cached internally. Attempting to close and then re-open an App with a changed configuration - within the same process has no effect. The client continues to use the - cached configuration. + within the same process has no effect. The client continues to use the + cached configuration. - In Flutter SDK version 1.8.0 and later, the :flutter-sdk:`baseUrl ` - is *no longer* cached in the App configuration. This means that you can change the - ``baseUrl``, and the App client will use the updated configuration. In - earlier SDK versions, changes to the ``baseUrl`` in a cached App + In Flutter SDK version 1.8.0 and later, the :flutter-sdk:`baseUrl ` + is *no longer* cached in the App configuration. This means that you can change the + ``baseUrl``, and the App client will use the updated configuration. In + earlier SDK versions, changes to the ``baseUrl`` in a cached App configuration have no effect. .. _flutter-app-client-configuration: @@ -91,7 +91,7 @@ To learn about the available configuration options, refer to the :flutter-sdk:`AppConfiguration ` reference documentation. .. literalinclude:: /examples/generated/flutter/app_services_test.snippet.app-client-advanced-configuration.dart - :language: dart + :language: dart .. note:: Connect Using Android 7 or Older @@ -107,8 +107,8 @@ Get App by ID .. versionadded:: 1.7.0 -After you have created an ``App`` instance on the main isolate, you can access -the constructed instance on a background isolate by passing the App ID to the +After you have created an ``App`` instance on the main isolate, you can access +the constructed instance on a background isolate by passing the App ID to the :flutter-sdk:`App.getById() ` method. Then, you can use it to work with the ``App`` and users as needed. .. literalinclude:: /examples/generated/flutter/app_services_test.snippet.access-app-by-id.dart @@ -128,35 +128,34 @@ connect to a different server: - You want to connect to an Edge Server instance. For more information, refer to the :ref:`edge-server-connect-from-client` App Services documentation. -You can specify a ``baseUrl`` in the +You can specify a ``baseUrl`` in the :flutter-sdk:`AppConfiguration `: -.. literalinclude:: /examples/generated/code/start/RealmApp.snippet.custom-base-url.swift - :language: swift +.. literalinclude:: /examples/generated/flutter/app_services_test.snippet.custom-base-url.dart + :language: dart Connect to a Different Server During Runtime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 2.2.0 +.. versionadded:: 1.8.0 +.. versionchanged:: 2.2.0 + ``updateBaseUrl`` accepts ``null`` value In some cases, you might want to change the ``baseUrl`` while the app is running. For example, you might want to roam between Edge Servers or -move from an App Services connection to an Edge Server connection. +move from an App Services connection to an Edge Server connection. -To change the ``baseUrl`` during runtime, call the -:flutter-sdk:`app.updateBaseUrl ` method: +To change the ``baseUrl`` during runtime, call the experimental +:flutter-sdk:`app.updateBaseUrl ` method. You can +pass ``null`` to reset the ``baseUrl`` to the default value. -.. literalinclude:: /examples/generated/code/start/RealmApp.snippet.change-base-url.swift - :language: swift - -This API is experimental, so you must use the ``@experimental`` import in the -file where you want to use this API: +.. literalinclude:: /examples/generated/flutter/app_services_test.snippet.change-base-url.dart + :language: dart -.. literalinclude:: /examples/generated/code/start/RealmApp.snippet.import-experimental.swift - :language: swift +This API is experimental and may change in future releases. -Change ``baseUrl`` After Opening Synced Database with User -`````````````````````````````````````````````````````````` +Change Server with Logged-In User +````````````````````````````````` If you want to change the ``baseUrl`` after you have logged in a user and have opened a synced database, the app must perform a client reset. For more @@ -170,4 +169,5 @@ Perform the following in your code: 4. Open a synced database pulling data from the new server Both the server and the client *must* be online for the user to authenticate and -connect to the new server. If the server is not online or the client does not have a network connection, the user cannot authenticate and open the database. +connect to the new server. If the server is not online or the client does not +have a network connection, the user cannot authenticate and open the database.