-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[gis_web] Migrate to package:web. #5581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8585b59
[gis_web] Remove bespoke dom.dart files
ditman cf6438c
Update package deps.
ditman 4ebef20
Add a file with tweaks to package web.
ditman 95c665c
Migrate js_loader and its related js-interop.
ditman 85d9ce2
Migrate accounts.id to package:web.
ditman d2c16e9
Migrate oauth2 lib.
ditman 2e10ba1
Update example apps
ditman 5c3fb76
Migrate dart test tests.
ditman f9446db
Migrate integration tests to new APIs
ditman f6969c4
Update changelog and pubspec. v0.3.0.
ditman a1feea0
Specify deps identically to other package:web migrations.
ditman 7c2059e
CHANGELOG style
ditman 949ba0c
Fix example app dep on package:web.
ditman 6aaf828
Don't lie on some comments.
ditman 4037074
Add ignores for downgraded analysis.
ditman 5a66e9d
Remove test client ids.
ditman a2e3974
Exclude from all_packages_app, until google_sign_in_web takes the lat…
ditman f88491f
Make not optional, and assert it is not empty.
ditman 0c1e1c3
Make scope required again, otherwise the SDK crashes at init.
ditman 046662b
Address some more PR comments.
ditman 329a098
Unify deps. Use http compatible with wasm.
ditman 114601a
Specify minimum flutter version.
ditman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,15 +2,17 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // the following ignore is needed for downgraded analyzer (casts to JSObject). | ||
| // ignore_for_file: unnecessary_cast | ||
|
|
||
| import 'dart:async'; | ||
| import 'dart:js_interop'; | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:google_identity_services_web/id.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
| import 'package:js/js.dart'; | ||
| import 'package:js/js_util.dart' as js_util show getProperty; | ||
| import 'package:web/web.dart' as web; | ||
|
|
||
| import 'src/dom.dart'; | ||
| import 'utils.dart' as utils; | ||
|
|
||
| void main() async { | ||
|
|
@@ -23,11 +25,12 @@ void main() async { | |
|
|
||
| group('renderButton', () { | ||
| testWidgets('supports a js-interop target from any library', (_) async { | ||
| final DomElement target = createDomElement('div'); | ||
| final web.HTMLDivElement target = | ||
| web.document.createElement('div') as web.HTMLDivElement; | ||
|
|
||
| id.renderButton(target); | ||
|
|
||
| final DomElement? button = target.querySelector('button'); | ||
| final web.Element? button = target.querySelector('button'); | ||
| expect(button, isNotNull); | ||
| }); | ||
| }); | ||
|
|
@@ -37,45 +40,46 @@ void main() async { | |
| final IdConfiguration config = IdConfiguration( | ||
| client_id: 'testing_1-2-3', | ||
| auto_select: false, | ||
| callback: allowInterop((_) {}), | ||
| callback: (_) {}, | ||
| login_uri: Uri.parse('https://www.example.com/login'), | ||
| native_callback: allowInterop((_) {}), | ||
| native_callback: (_) {}, | ||
| cancel_on_tap_outside: false, | ||
| prompt_parent_id: 'some_dom_id', | ||
| nonce: 's0m3_r4ndOM_vALu3', | ||
| context: OneTapContext.signin, | ||
| state_cookie_domain: 'subdomain.example.com', | ||
| ux_mode: UxMode.popup, | ||
| allowed_parent_origin: <String>['allowed', 'another'], | ||
| intermediate_iframe_close_callback: allowInterop((_) {}), | ||
| intermediate_iframe_close_callback: () {}, | ||
| itp_support: true, | ||
| login_hint: '[email protected]', | ||
| hd: 'hd_value', | ||
| use_fedcm_for_prompt: true, | ||
| ); | ||
|
|
||
| // Save some keystrokes below by partially applying to the 'config' above. | ||
| void expectConfigValue(String name, Object? matcher) { | ||
| expect(js_util.getProperty(config, name), matcher, reason: name); | ||
| } | ||
| final utils.ExpectConfigValueFn expectConfigValue = | ||
| utils.createExpectConfigValue(config as JSObject); | ||
|
|
||
| expectConfigValue('allowed_parent_origin', hasLength(2)); | ||
| expectConfigValue('client_id', 'testing_1-2-3'); | ||
| expectConfigValue('auto_select', isFalse); | ||
| expectConfigValue('callback', isA<Function>()); | ||
| expectConfigValue('callback', utils.isAJs('function')); | ||
| expectConfigValue('login_uri', 'https://www.example.com/login'); | ||
| expectConfigValue('native_callback', utils.isAJs('function')); | ||
| expectConfigValue('cancel_on_tap_outside', isFalse); | ||
| expectConfigValue('client_id', 'testing_1-2-3'); | ||
| expectConfigValue('context', isA<OneTapContext>()); | ||
| expectConfigValue('hd', 'hd_value'); | ||
| expectConfigValue('intermediate_iframe_close_callback', isA<Function>()); | ||
| expectConfigValue('itp_support', isTrue); | ||
| expectConfigValue('login_hint', '[email protected]'); | ||
| expectConfigValue('login_uri', isA<Uri>()); | ||
| expectConfigValue('native_callback', isA<Function>()); | ||
| expectConfigValue('nonce', 's0m3_r4ndOM_vALu3'); | ||
| expectConfigValue('allowed_parent_origin', isA<JSArray>()); | ||
| expectConfigValue('prompt_parent_id', 'some_dom_id'); | ||
| expectConfigValue('nonce', 's0m3_r4ndOM_vALu3'); | ||
| expectConfigValue('context', 'signin'); | ||
| expectConfigValue('state_cookie_domain', 'subdomain.example.com'); | ||
| expectConfigValue('ux_mode', 'popup'); | ||
| expectConfigValue( | ||
| 'allowed_parent_origin', <String>['allowed', 'another']); | ||
| expectConfigValue( | ||
| 'intermediate_iframe_close_callback', utils.isAJs('function')); | ||
| expectConfigValue('itp_support', isTrue); | ||
| expectConfigValue('login_hint', '[email protected]'); | ||
| expectConfigValue('hd', 'hd_value'); | ||
| expectConfigValue('use_fedcm_for_prompt', isTrue); | ||
| expectConfigValue('ux_mode', isA<UxMode>()); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -86,7 +90,7 @@ void main() async { | |
| final StreamController<PromptMomentNotification> controller = | ||
| StreamController<PromptMomentNotification>(); | ||
|
|
||
| id.prompt(allowInterop(controller.add)); | ||
| id.prompt(controller.add); | ||
|
|
||
| final PromptMomentNotification moment = await controller.stream.first; | ||
|
|
||
|
|
@@ -104,7 +108,7 @@ void main() async { | |
|
|
||
| id.initialize(IdConfiguration( | ||
| client_id: 'testing_1-2-3', | ||
| callback: allowInterop(controller.add), | ||
| callback: controller.add, | ||
| )); | ||
|
|
||
| id.prompt(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,15 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // the following ignore is needed for downgraded analyzer (casts to JSObject). | ||
| // ignore_for_file: unnecessary_cast | ||
|
|
||
| import 'dart:async'; | ||
| import 'dart:js_interop'; | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:google_identity_services_web/oauth2.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
| import 'package:js/js.dart'; | ||
|
|
||
| import 'utils.dart' as utils; | ||
|
|
||
|
|
@@ -19,12 +22,96 @@ void main() async { | |
| await utils.installGisMock(); | ||
| }); | ||
|
|
||
| group('Config objects pass values from Dart to JS - ', () { | ||
| testWidgets('TokenClientConfig', (_) async { | ||
| final TokenClientConfig config = TokenClientConfig( | ||
| client_id: 'testing_1-2-3', | ||
| callback: (_) {}, | ||
| scope: <String>['one', 'two', 'three'], | ||
| include_granted_scopes: true, | ||
| prompt: 'some-prompt', | ||
| enable_granular_consent: true, | ||
| login_hint: '[email protected]', | ||
| hd: 'hd_value', | ||
| state: 'some-state', | ||
| error_callback: (_) {}, | ||
| ); | ||
|
|
||
| final utils.ExpectConfigValueFn expectConfigValue = | ||
| utils.createExpectConfigValue(config as JSObject); | ||
|
|
||
| expectConfigValue('client_id', 'testing_1-2-3'); | ||
| expectConfigValue('callback', utils.isAJs('function')); | ||
| expectConfigValue('scope', 'one two three'); | ||
| expectConfigValue('include_granted_scopes', isTrue); | ||
| expectConfigValue('prompt', 'some-prompt'); | ||
| expectConfigValue('enable_granular_consent', isTrue); | ||
| expectConfigValue('login_hint', '[email protected]'); | ||
| expectConfigValue('hd', 'hd_value'); | ||
| expectConfigValue('state', 'some-state'); | ||
| expectConfigValue('error_callback', utils.isAJs('function')); | ||
| }); | ||
|
|
||
| testWidgets('OverridableTokenClientConfig', (_) async { | ||
| final OverridableTokenClientConfig config = OverridableTokenClientConfig( | ||
| scope: <String>['one', 'two', 'three'], | ||
| include_granted_scopes: true, | ||
| prompt: 'some-prompt', | ||
| enable_granular_consent: true, | ||
| login_hint: '[email protected]', | ||
| state: 'some-state', | ||
| ); | ||
|
|
||
| final utils.ExpectConfigValueFn expectConfigValue = | ||
| utils.createExpectConfigValue(config as JSObject); | ||
|
|
||
| expectConfigValue('scope', 'one two three'); | ||
| expectConfigValue('include_granted_scopes', isTrue); | ||
| expectConfigValue('prompt', 'some-prompt'); | ||
| expectConfigValue('enable_granular_consent', isTrue); | ||
| expectConfigValue('login_hint', '[email protected]'); | ||
| expectConfigValue('state', 'some-state'); | ||
| }); | ||
|
|
||
| testWidgets('CodeClientConfig', (_) async { | ||
| final CodeClientConfig config = CodeClientConfig( | ||
| client_id: 'testing_1-2-3', | ||
| scope: <String>['one', 'two', 'three'], | ||
| include_granted_scopes: true, | ||
| redirect_uri: Uri.parse('https://www.example.com/login'), | ||
| callback: (_) {}, | ||
| state: 'some-state', | ||
| enable_granular_consent: true, | ||
| login_hint: '[email protected]', | ||
| hd: 'hd_value', | ||
| ux_mode: UxMode.popup, | ||
| select_account: true, | ||
| error_callback: (_) {}, | ||
| ); | ||
|
|
||
| final utils.ExpectConfigValueFn expectConfigValue = | ||
| utils.createExpectConfigValue(config as JSObject); | ||
|
|
||
| expectConfigValue('scope', 'one two three'); | ||
| expectConfigValue('include_granted_scopes', isTrue); | ||
| expectConfigValue('redirect_uri', 'https://www.example.com/login'); | ||
| expectConfigValue('callback', utils.isAJs('function')); | ||
| expectConfigValue('state', 'some-state'); | ||
| expectConfigValue('enable_granular_consent', isTrue); | ||
| expectConfigValue('login_hint', '[email protected]'); | ||
| expectConfigValue('hd', 'hd_value'); | ||
| expectConfigValue('ux_mode', 'popup'); | ||
| expectConfigValue('select_account', isTrue); | ||
| expectConfigValue('error_callback', utils.isAJs('function')); | ||
| }); | ||
| }); | ||
|
|
||
| group('initTokenClient', () { | ||
| testWidgets('returns a tokenClient', (_) async { | ||
| final TokenClient client = oauth2.initTokenClient(TokenClientConfig( | ||
| client_id: 'for-tests', | ||
| callback: null, | ||
| scope: 'some_scope for_tests not_real', | ||
| callback: (_) {}, | ||
| scope: <String>['some_scope', 'for_tests', 'not_real'], | ||
| )); | ||
|
|
||
| expect(client, isNotNull); | ||
|
|
@@ -40,8 +127,8 @@ void main() async { | |
|
|
||
| final TokenClient client = oauth2.initTokenClient(TokenClientConfig( | ||
| client_id: 'for-tests', | ||
| callback: allowInterop(controller.add), | ||
| scope: scopes.join(' '), | ||
| callback: controller.add, | ||
| scope: scopes, | ||
| )); | ||
|
|
||
| utils.setMockTokenResponse(client, 'some-non-null-auth-token-value'); | ||
|
|
@@ -52,7 +139,7 @@ void main() async { | |
|
|
||
| expect(response, isNotNull); | ||
| expect(response.error, isNull); | ||
| expect(response.scope, scopes.join(' ')); | ||
| expect(response.scope, scopes); | ||
| }); | ||
|
|
||
| testWidgets('configuration can be overridden', (_) async { | ||
|
|
@@ -63,21 +150,21 @@ void main() async { | |
|
|
||
| final TokenClient client = oauth2.initTokenClient(TokenClientConfig( | ||
| client_id: 'for-tests', | ||
| callback: allowInterop(controller.add), | ||
| scope: 'blank', | ||
| callback: controller.add, | ||
| scope: <String>['blank'], | ||
| )); | ||
|
|
||
| utils.setMockTokenResponse(client, 'some-non-null-auth-token-value'); | ||
|
|
||
| client.requestAccessToken(OverridableTokenClientConfig( | ||
| scope: scopes.join(' '), | ||
| scope: scopes, | ||
| )); | ||
|
|
||
| final TokenResponse response = await controller.stream.first; | ||
|
|
||
| expect(response, isNotNull); | ||
| expect(response.error, isNull); | ||
| expect(response.scope, scopes.join(' ')); | ||
| expect(response.scope, scopes); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
31 changes: 0 additions & 31 deletions
31
packages/google_identity_services_web/example/integration_test/src/dom.dart
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.