Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b22f6ce12 | ||
|
|
b5c4772168 |
No files matched your search
@@ -302,6 +302,33 @@ that contradicts displayed balances or usage without explaining the fixtures.
|
|||||||
- Keep unrelated accounts/history accessible during a pending operation. Do not
|
- Keep unrelated accounts/history accessible during a pending operation. Do not
|
||||||
block the whole product behind an exchange spinner.
|
block the whole product behind an exchange spinner.
|
||||||
|
|
||||||
|
## Empty currency accounts (task #66)
|
||||||
|
|
||||||
|
The shared empty-account message used on Accounts and transfer screens explains
|
||||||
|
that no currency accounts have been set up and directs the customer to support
|
||||||
|
to request setup. English and Russian no longer suggest that refreshing creates
|
||||||
|
accounts or imply that automatic provisioning is underway. This follows the
|
||||||
|
existing support guidance for missing funding and payout setup. The application
|
||||||
|
has no configured support contact channel; the message therefore provides text
|
||||||
|
guidance without a nonfunctional contact button or invented contact details.
|
||||||
|
|
||||||
|
UX review: the copy names the missing resource and the next step, retains the
|
||||||
|
existing wrapping text and accessible reading order, and does not alter loading,
|
||||||
|
error or populated-state behavior. Existing manual refresh remains available for
|
||||||
|
accounts provisioned externally. This copy-only change adds no controls or
|
||||||
|
journey outcomes and requires no new analytics events. Existing transaction
|
||||||
|
journey signals and their production measurement limitations below still apply;
|
||||||
|
support resolution and external account provisioning are not measured in-app.
|
||||||
|
|
||||||
|
Validation: `flutter gen-l10n`, `flutter analyze` in `frontend/app`,
|
||||||
|
`make test-frontend` (217 tests), and `git diff --check` passed. No Dart source
|
||||||
|
changed, so Dart formatting was not applicable. Existing responsive workspace
|
||||||
|
tests cover Russian at 320px with enlarged text; this copy-only change does not
|
||||||
|
add a dedicated empty-state rendering or native screen-reader test. No security
|
||||||
|
scan was requested. Delivery: [task #66](https://git.sendico.io/tech/sxchnge/issues/66),
|
||||||
|
branch `wallet-66`, [PR #68](https://git.sendico.io/tech/sxchnge/pulls/68).
|
||||||
|
Merge and deployment remain separate.
|
||||||
|
|
||||||
## Journey measurement plan
|
## Journey measurement plan
|
||||||
|
|
||||||
Reuse the typed analytics abstraction and maintain a separate journey per active
|
Reuse the typed analytics abstraction and maintain a separate journey per active
|
||||||
|
|||||||
@@ -167,47 +167,3 @@ This is a display correction within the existing KYC journey, so no additional
|
|||||||
analytics events or financial data collection are introduced. Tests cover mapping
|
analytics events or financial data collection are introduced. Tests cover mapping
|
||||||
without inferring remaining, unused/exhausted/over-cap/zero-cap ratios and EN/RU
|
without inferring remaining, unused/exhausted/over-cap/zero-cap ratios and EN/RU
|
||||||
usage display at 320px with 1.6 text scaling.
|
usage display at 320px with 1.6 text scaling.
|
||||||
|
|
||||||
## Residence country selection — task #64
|
|
||||||
|
|
||||||
Task [#64](https://git.sendico.io/tech/sxchnge/issues/64), branch `kyc-64`.
|
|
||||||
Delivery: [PR #65](https://git.sendico.io/tech/sxchnge/pulls/65).
|
|
||||||
The profile now shows a country name and opens a searchable country list instead
|
|
||||||
of asking customers to type a two-letter code. Names follow the English/Russian
|
|
||||||
app locale. Search accepts localized or English names and two-letter codes,
|
|
||||||
ignoring case and surrounding whitespace. Selection updates only
|
|
||||||
`IdentityProfile.residenceCountry` with the country code; the existing provider,
|
|
||||||
service, mapper and transport contracts remain unchanged.
|
|
||||||
|
|
||||||
The `country_picker` dependency supplies bundled country data, code lookup and
|
|
||||||
translations through `CountryService` and `CountryLocalizations`. Flutter Material
|
|
||||||
controls provide the search interface, explicit no-results recovery, minimum
|
|
||||||
touch targets, keyboard selection, a selected-state checkmark, Back and Escape.
|
|
||||||
The package's built-in list omits explicit no-results feedback and uses shorter
|
|
||||||
row targets, so its data/localizations are reused with standard Material controls.
|
|
||||||
There is no remote lookup, copied country table or extra application provider.
|
|
||||||
Cancelling preserves the current profile, prefilled codes display names, busy
|
|
||||||
state disables opening the selector, and the search controller is disposed with
|
|
||||||
its dialog. The list is a data catalogue; backend eligibility remains authoritative.
|
|
||||||
|
|
||||||
This change stays within the existing KYC preparation/submission journey and its
|
|
||||||
measurement definitions above. No selector events, queries, names or country
|
|
||||||
codes are added to telemetry. Existing acceptance/failure/retry/abandonment
|
|
||||||
signals and documented server-side review measurement gaps still apply.
|
|
||||||
|
|
||||||
Focused widget checks cover name/code search, code-only updates, reselection,
|
|
||||||
cancel, no-results recovery, clearing search, saved values, locale changes,
|
|
||||||
Russian names, disabled state, keyboard activation/selection/Escape and labeled
|
|
||||||
touch targets. A long country name fits at 320px with 1.6 text scale. Existing
|
|
||||||
EN/RU verification journeys now select a country and assert the profile code
|
|
||||||
before continuing through document submission. Native screen-reader and device
|
|
||||||
keyboard testing remain release checks; widget semantics checks do not establish
|
|
||||||
those device outcomes.
|
|
||||||
|
|
||||||
Validation: five changed Dart files passed the format check; `flutter analyze`
|
|
||||||
in `frontend/app` reported no issues; `make test-frontend` passed all 222 tests;
|
|
||||||
and `flutter build web` passed, including its Wasm compatibility dry run. Browser
|
|
||||||
smoke testing on the local demo opened the selector, searched for Poland and
|
|
||||||
confirmed that the profile displays Poland after selection. Focused and full
|
|
||||||
journey tests verify the stored `PL` code. Generated localization/build outputs
|
|
||||||
remain ignored and uncommitted.
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
# Identity photo preview correction
|
|
||||||
|
|
||||||
Task [#69](https://git.sendico.io/tech/sxchnge/issues/69), branch `kyc-69`.
|
|
||||||
Delivery: [PR #71](https://git.sendico.io/tech/sxchnge/pulls/71).
|
|
||||||
This frontend change builds on the [identity verification journey](kyc.md)
|
|
||||||
and is independent of the birthday controls in task #67.
|
|
||||||
|
|
||||||
## Cause and correction
|
|
||||||
|
|
||||||
A synthetic valid PNG reproduced this Flutter 3.47.7 browser error:
|
|
||||||
|
|
||||||
```text
|
|
||||||
TypeError: Instance of '_UnmodifiableUint8ListView': type
|
|
||||||
'_UnmodifiableUint8ListView' is not a subtype of type 'NativeUint8List'
|
|
||||||
```
|
|
||||||
|
|
||||||
The stack reached `Uint8ListToJSUint8Array.toJS` from CanvasKit's browser
|
|
||||||
image decoder through `MemoryImage` and `ResizeImage`. File selection had
|
|
||||||
successfully decoded the original typed bytes. The `Photo` constructor then
|
|
||||||
copied them into an unmodifiable view, which was passed directly into the
|
|
||||||
preview's web decoder. Native decoding accepted that view, hiding the bug in
|
|
||||||
native-only tests. The generic image error builder presented the failure as a
|
|
||||||
damaged document even though the selected bytes were valid.
|
|
||||||
|
|
||||||
`PhotoPreview` now creates a native `Uint8List` copy for `MemoryImage` once per
|
|
||||||
selected photo. The shared domain model stays immutable, and validation,
|
|
||||||
providers, services and transport contracts remain unchanged. The preview still
|
|
||||||
requests a decode width of at most 1000 pixels and evicts its decoded cache entry
|
|
||||||
on replacement or disposal. The extra encoded-byte copy belongs to the preview
|
|
||||||
and is released with its provider/cache references; no secure-erasure guarantee
|
|
||||||
is made.
|
|
||||||
|
|
||||||
An actual preview failure now says that the preview could not be displayed and
|
|
||||||
suggests selecting the photo again. The English/Russian fallback keeps at least
|
|
||||||
the preview's usual height, can grow for long text, and has a separate live-region
|
|
||||||
semantic node. Existing replacement/removal controls stay available and selected
|
|
||||||
input is retained. This is distinct from validation's corrupt-file message.
|
|
||||||
|
|
||||||
## UX and measurement review
|
|
||||||
|
|
||||||
The outcome remains selecting readable ID and selfie photos, checking both on
|
|
||||||
review, and submitting for confirmed service acceptance. Existing KYC journey
|
|
||||||
attempts, retries, failure, submission and abandonment signals are reused. No
|
|
||||||
control-level events, image bytes, filenames, form values or raw exceptions are
|
|
||||||
added to telemetry. A selection success measures validation; it does not establish
|
|
||||||
that pixels were painted. Preview-only rendering failures are not separately
|
|
||||||
counted by existing telemetry. Server review/approval measurement and native
|
|
||||||
screen-reader QA retain the limitations documented in the original journey.
|
|
||||||
|
|
||||||
Regression tests use synthetic JPEG/PNG content only. They start and await real
|
|
||||||
image decoding outside the widget test's fake async zone, inspect the actual
|
|
||||||
rendered images, and surface stream errors so an error fallback cannot conceal a
|
|
||||||
failure. Checks cover portrait/landscape decoding, model immutability, bounded
|
|
||||||
decode width, stable provider reuse, replacement/removal cache eviction, both
|
|
||||||
review slots, returning to review, localized fallback/replacement, a 320px view
|
|
||||||
at 1.6 text scale, and error announcements isolated from surrounding instructions.
|
|
||||||
The `image` package is already a KYC runtime dependency; its direct app test
|
|
||||||
dependency is used only to create synthetic fixtures in memory.
|
|
||||||
|
|
||||||
## Validation and delivery
|
|
||||||
|
|
||||||
The original browser regression failed before the fix while its native equivalent
|
|
||||||
passed. The complete task diff was reviewed against frontend architecture, UX,
|
|
||||||
measurement, lifecycle and privacy requirements. Final validation passed:
|
|
||||||
|
|
||||||
- In `frontend/app`, `dart format --output=none --set-exit-if-changed
|
|
||||||
lib/kyc/preview.dart test/preview_test.dart`: two files, no changes.
|
|
||||||
- In `frontend/app`, `flutter analyze --no-pub`: no issues.
|
|
||||||
- In `frontend/app`, `flutter test --platform chrome test/preview_test.dart
|
|
||||||
--reporter expanded --no-pub --verbose`: all six regression tests passed.
|
|
||||||
- At the repository root, `make test-frontend`: all 228 tests passed across
|
|
||||||
the shared packages, theme example and app, including the six native preview
|
|
||||||
regressions and existing KYC journey/analytics tests.
|
|
||||||
- In `frontend/app`, `flutter build web --no-pub`: release build and Wasm
|
|
||||||
compatibility dry run succeeded.
|
|
||||||
|
|
||||||
Browser regression coverage uses Chrome; Safari and native assistive-technology
|
|
||||||
testing remain release checks. Generated localization and build code stays
|
|
||||||
ignored; the tracked app lockfile changes only `image` from transitive to direct
|
|
||||||
test dependency. The separate birthday worktree was preserved.
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
import 'package:country_picker/country_picker.dart';
|
|
||||||
|
|
||||||
import '../generated/i18n/app_localizations.dart';
|
|
||||||
|
|
||||||
class CountryField extends StatelessWidget {
|
|
||||||
const CountryField({
|
|
||||||
super.key,
|
|
||||||
required this.value,
|
|
||||||
required this.onChanged,
|
|
||||||
this.enabled = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String value;
|
|
||||||
final ValueChanged<String> onChanged;
|
|
||||||
final bool enabled;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final l = AppLocalizations.of(context)!;
|
|
||||||
final country = CountryService().findByCode(value);
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
Text(l.kycCountry, style: Theme.of(context).textTheme.labelLarge),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Semantics(
|
|
||||||
label: l.kycCountry,
|
|
||||||
child: OutlinedButton(
|
|
||||||
onPressed: !enabled
|
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
final code = await showDialog<String>(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => _CountrySearch(selected: value),
|
|
||||||
);
|
|
||||||
if (context.mounted && code != null) onChanged(code);
|
|
||||||
},
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(14),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
country == null
|
|
||||||
? l.kycCountrySelect
|
|
||||||
: _name(context, country),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
const Icon(Icons.expand_more),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _name(BuildContext context, Country country) =>
|
|
||||||
country.getTranslatedName(context) ?? country.name;
|
|
||||||
|
|
||||||
class _CountrySearch extends StatefulWidget {
|
|
||||||
const _CountrySearch({required this.selected});
|
|
||||||
|
|
||||||
final String selected;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_CountrySearch> createState() => _CountrySearchState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CountrySearchState extends State<_CountrySearch> {
|
|
||||||
final _query = TextEditingController();
|
|
||||||
final _countries = {
|
|
||||||
for (final country in CountryService().getAll())
|
|
||||||
country.countryCode: country,
|
|
||||||
}.values.toList();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_query.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final l = AppLocalizations.of(context)!;
|
|
||||||
return Focus(
|
|
||||||
autofocus: true,
|
|
||||||
onKeyEvent: (_, event) {
|
|
||||||
if (event is KeyDownEvent &&
|
|
||||||
event.logicalKey == LogicalKeyboardKey.escape) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
return KeyEventResult.handled;
|
|
||||||
}
|
|
||||||
return KeyEventResult.ignored;
|
|
||||||
},
|
|
||||||
child: Dialog.fullscreen(
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
leading: BackButton(onPressed: () => Navigator.of(context).pop()),
|
|
||||||
title: TextField(
|
|
||||||
key: const ValueKey('country-search'),
|
|
||||||
controller: _query,
|
|
||||||
autofocus: true,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: l.kycCountrySearch,
|
|
||||||
prefixIcon: const Icon(Icons.search),
|
|
||||||
),
|
|
||||||
onChanged: (_) => setState(() {}),
|
|
||||||
),
|
|
||||||
toolbarHeight: 96,
|
|
||||||
actions: [
|
|
||||||
if (_query.text.isNotEmpty)
|
|
||||||
IconButton(
|
|
||||||
tooltip: l.kycCountryClearSearch,
|
|
||||||
icon: const Icon(Icons.clear),
|
|
||||||
onPressed: () => setState(_query.clear),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: _list(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _list(BuildContext context) {
|
|
||||||
final search = _query.text.trim().toLowerCase();
|
|
||||||
final countries = _countries.where((country) {
|
|
||||||
return _name(context, country).toLowerCase().contains(search) ||
|
|
||||||
country.name.toLowerCase().contains(search) ||
|
|
||||||
country.countryCode.toLowerCase() == search;
|
|
||||||
}).toList()..sort((a, b) => _name(context, a).compareTo(_name(context, b)));
|
|
||||||
if (countries.isEmpty) {
|
|
||||||
return Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: Text(AppLocalizations.of(context)!.kycCountryEmpty),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ListView.builder(
|
|
||||||
itemCount: countries.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final country = countries[index];
|
|
||||||
final isSelected = country.countryCode == widget.selected;
|
|
||||||
return ListTile(
|
|
||||||
title: Text(_name(context, country)),
|
|
||||||
selected: isSelected,
|
|
||||||
trailing: isSelected ? const Icon(Icons.check) : null,
|
|
||||||
onTap: () => Navigator.of(context).pop(country.countryCode),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
||||||
@@ -17,12 +15,8 @@ class PhotoPreview extends StatefulWidget {
|
|||||||
|
|
||||||
class _PhotoPreviewState extends State<PhotoPreview> {
|
class _PhotoPreviewState extends State<PhotoPreview> {
|
||||||
late ImageProvider _image = _provider();
|
late ImageProvider _image = _provider();
|
||||||
ImageProvider _provider() => ResizeImage.resizeIfNeeded(
|
ImageProvider _provider() =>
|
||||||
1000,
|
ResizeImage.resizeIfNeeded(1000, null, MemoryImage(widget.photo.bytes));
|
||||||
null,
|
|
||||||
// Web decoders require a native typed array, not the model's read-only view.
|
|
||||||
MemoryImage(Uint8List.fromList(widget.photo.bytes)),
|
|
||||||
);
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant PhotoPreview oldWidget) {
|
void didUpdateWidget(covariant PhotoPreview oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
@@ -44,15 +38,7 @@ class _PhotoPreviewState extends State<PhotoPreview> {
|
|||||||
height: 220,
|
height: 220,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
semanticLabel: widget.label,
|
semanticLabel: widget.label,
|
||||||
errorBuilder: (_, _, _) => ConstrainedBox(
|
errorBuilder: (_, _, _) =>
|
||||||
constraints: const BoxConstraints(minHeight: 220),
|
Text(AppLocalizations.of(context)!.kycErrorUnreadable),
|
||||||
child: Center(
|
|
||||||
child: Semantics(
|
|
||||||
container: true,
|
|
||||||
liveRegion: true,
|
|
||||||
child: Text(AppLocalizations.of(context)!.kycErrorPreview),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
||||||
|
|
||||||
import 'country.dart';
|
|
||||||
|
|
||||||
import '../generated/i18n/app_localizations.dart';
|
import '../generated/i18n/app_localizations.dart';
|
||||||
|
|
||||||
class ProfileForm extends StatelessWidget {
|
class ProfileForm extends StatelessWidget {
|
||||||
@@ -50,11 +48,17 @@ class ProfileForm extends StatelessWidget {
|
|||||||
onChanged: (value) => update(birth: value.trim()),
|
onChanged: (value) => update(birth: value.trim()),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
CountryField(
|
TextFormField(
|
||||||
key: const ValueKey('kyc-country'),
|
key: const ValueKey('kyc-country'),
|
||||||
value: p.profile.residenceCountry,
|
initialValue: p.profile.residenceCountry,
|
||||||
enabled: !p.busy,
|
enabled: !p.busy,
|
||||||
onChanged: (value) => update(country: value),
|
maxLength: 2,
|
||||||
|
textCapitalization: TextCapitalization.characters,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: l.kycCountry,
|
||||||
|
helperText: l.kycCountryHelp,
|
||||||
|
),
|
||||||
|
onChanged: (value) => update(country: value.trim().toUpperCase()),
|
||||||
),
|
),
|
||||||
if (!p.profile.isComplete) Text(l.kycProfileRequired),
|
if (!p.profile.isComplete) Text(l.kycProfileRequired),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -128,7 +128,6 @@
|
|||||||
"kycErrorFormat": "Choose a JPEG or PNG image. Other formats are not supported.",
|
"kycErrorFormat": "Choose a JPEG or PNG image. Other formats are not supported.",
|
||||||
"kycErrorLarge": "This image is too large. Choose one under 10 MB and 40 megapixels.",
|
"kycErrorLarge": "This image is too large. Choose one under 10 MB and 40 megapixels.",
|
||||||
"kycErrorUnreadable": "This image is damaged or cannot be read. Choose another photo.",
|
"kycErrorUnreadable": "This image is damaged or cannot be read. Choose another photo.",
|
||||||
"kycErrorPreview": "The photo preview could not be displayed. Try choosing the photo again.",
|
|
||||||
"kycErrorSmall": "The photo is too small. Use an image at least 600 pixels wide and high.",
|
"kycErrorSmall": "The photo is too small. Use an image at least 600 pixels wide and high.",
|
||||||
"kycErrorIncomplete": "Choose both photos and confirm they belong to you before submitting.",
|
"kycErrorIncomplete": "Choose both photos and confirm they belong to you before submitting.",
|
||||||
"kycErrorSession": "Your session has expired. Return to login, then check your verification status.",
|
"kycErrorSession": "Your session has expired. Return to login, then check your verification status.",
|
||||||
@@ -161,7 +160,7 @@
|
|||||||
"wRecent": "Recent activity",
|
"wRecent": "Recent activity",
|
||||||
"wSeeAll": "See all",
|
"wSeeAll": "See all",
|
||||||
"wEmptyActivity": "Your next move starts here. Your transactions will appear below.",
|
"wEmptyActivity": "Your next move starts here. Your transactions will appear below.",
|
||||||
"wEmptyAccounts": "Your accounts are not ready yet. Try refreshing.",
|
"wEmptyAccounts": "No currency accounts have been set up for you yet. Contact support to request account setup.",
|
||||||
"wRefresh": "Refresh",
|
"wRefresh": "Refresh",
|
||||||
"wSource": "From account",
|
"wSource": "From account",
|
||||||
"wDestination": "To account",
|
"wDestination": "To account",
|
||||||
@@ -272,11 +271,8 @@
|
|||||||
"kycBirth": "Date of birth",
|
"kycBirth": "Date of birth",
|
||||||
"kycBirthHelp": "YYYY-MM-DD, for example 1990-04-23",
|
"kycBirthHelp": "YYYY-MM-DD, for example 1990-04-23",
|
||||||
"kycCountry": "Country of residence",
|
"kycCountry": "Country of residence",
|
||||||
"kycCountrySelect": "Select a country",
|
"kycCountryHelp": "Two-letter country code, for example PL or DE",
|
||||||
"kycCountrySearch": "Search countries",
|
"kycProfileRequired": "Enter your full name, a valid date of birth and a two-letter country code to continue.",
|
||||||
"kycCountryEmpty": "No countries found. Try another name or country code.",
|
|
||||||
"kycCountryClearSearch": "Clear search",
|
|
||||||
"kycProfileRequired": "Enter your full name, a valid date of birth and select your country of residence to continue.",
|
|
||||||
"kycContinue": "Continue to my account",
|
"kycContinue": "Continue to my account",
|
||||||
"kycOperationMinimum": "Per operation minimum",
|
"kycOperationMinimum": "Per operation minimum",
|
||||||
"kycOperationMaximum": "Per operation maximum",
|
"kycOperationMaximum": "Per operation maximum",
|
||||||
|
|||||||
@@ -128,7 +128,6 @@
|
|||||||
"kycErrorFormat": "Выберите изображение JPEG или PNG. Другие форматы не поддерживаются.",
|
"kycErrorFormat": "Выберите изображение JPEG или PNG. Другие форматы не поддерживаются.",
|
||||||
"kycErrorLarge": "Изображение слишком большое. Выберите файл до 10 МБ и 40 мегапикселей.",
|
"kycErrorLarge": "Изображение слишком большое. Выберите файл до 10 МБ и 40 мегапикселей.",
|
||||||
"kycErrorUnreadable": "Изображение повреждено или не читается. Выберите другое фото.",
|
"kycErrorUnreadable": "Изображение повреждено или не читается. Выберите другое фото.",
|
||||||
"kycErrorPreview": "Не удалось показать фото. Попробуйте выбрать его ещё раз.",
|
|
||||||
"kycErrorSmall": "Фото слишком маленькое. Ширина и высота должны быть не менее 600 пикселей.",
|
"kycErrorSmall": "Фото слишком маленькое. Ширина и высота должны быть не менее 600 пикселей.",
|
||||||
"kycErrorIncomplete": "Выберите оба фото и подтвердите, что на них вы и ваш документ.",
|
"kycErrorIncomplete": "Выберите оба фото и подтвердите, что на них вы и ваш документ.",
|
||||||
"kycErrorSession": "Сессия истекла. Войдите снова и проверьте статус верификации.",
|
"kycErrorSession": "Сессия истекла. Войдите снова и проверьте статус верификации.",
|
||||||
@@ -161,7 +160,7 @@
|
|||||||
"wRecent": "Последние операции",
|
"wRecent": "Последние операции",
|
||||||
"wSeeAll": "Смотреть все",
|
"wSeeAll": "Смотреть все",
|
||||||
"wEmptyActivity": "Ваш следующий шаг начинается здесь. Здесь появятся ваши операции.",
|
"wEmptyActivity": "Ваш следующий шаг начинается здесь. Здесь появятся ваши операции.",
|
||||||
"wEmptyAccounts": "Ваши счета ещё не готовы. Попробуйте обновить страницу.",
|
"wEmptyAccounts": "У вас ещё нет валютных счетов. Обратитесь в поддержку за помощью с их открытием.",
|
||||||
"wRefresh": "Обновить",
|
"wRefresh": "Обновить",
|
||||||
"wSource": "Со счёта",
|
"wSource": "Со счёта",
|
||||||
"wDestination": "На счёт",
|
"wDestination": "На счёт",
|
||||||
@@ -272,11 +271,8 @@
|
|||||||
"kycBirth": "Дата рождения",
|
"kycBirth": "Дата рождения",
|
||||||
"kycBirthHelp": "ГГГГ-ММ-ДД, например 1990-04-23",
|
"kycBirthHelp": "ГГГГ-ММ-ДД, например 1990-04-23",
|
||||||
"kycCountry": "Страна проживания",
|
"kycCountry": "Страна проживания",
|
||||||
"kycCountrySelect": "Выберите страну",
|
"kycCountryHelp": "Код страны из двух букв, например PL или DE",
|
||||||
"kycCountrySearch": "Поиск страны",
|
"kycProfileRequired": "Укажите полное имя, корректную дату рождения и код страны из двух букв.",
|
||||||
"kycCountryEmpty": "Страны не найдены. Попробуйте другое название или код страны.",
|
|
||||||
"kycCountryClearSearch": "Очистить поиск",
|
|
||||||
"kycProfileRequired": "Укажите полное имя, корректную дату рождения и выберите страну проживания.",
|
|
||||||
"kycContinue": "Перейти в личный кабинет",
|
"kycContinue": "Перейти в личный кабинет",
|
||||||
"kycOperationMinimum": "Минимум на операцию",
|
"kycOperationMinimum": "Минимум на операцию",
|
||||||
"kycOperationMaximum": "Максимум на операцию",
|
"kycOperationMaximum": "Максимум на операцию",
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||||
|
|
||||||
import 'package:country_picker/country_picker.dart';
|
|
||||||
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'package:sxchnge_analytics/sxchnge_analytics.dart';
|
import 'package:sxchnge_analytics/sxchnge_analytics.dart';
|
||||||
@@ -197,10 +195,7 @@ class _SxchngeAppState extends State<SxchngeApp> {
|
|||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: SxchngeTheme.light(),
|
theme: SxchngeTheme.light(),
|
||||||
locale: locale.locale,
|
locale: locale.locale,
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
...AppLocalizations.localizationsDelegates,
|
|
||||||
CountryLocalizations.delegate,
|
|
||||||
],
|
|
||||||
supportedLocales: AppLocalizations.supportedLocales,
|
supportedLocales: AppLocalizations.supportedLocales,
|
||||||
routerConfig: _router,
|
routerConfig: _router,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -49,14 +49,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.19.1"
|
version: "1.19.1"
|
||||||
country_picker:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: country_picker
|
|
||||||
sha256: "8ef721183bd7e0a6017c413693cdc68051daceef5790f5420c3b4378b5c69115"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.28"
|
|
||||||
cross_file:
|
cross_file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -222,7 +214,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.2"
|
version: "4.1.2"
|
||||||
image:
|
image:
|
||||||
dependency: "direct dev"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: image
|
name: image
|
||||||
sha256: "1976370a4df3091bb0f72409c187ad1f9132a818bc6b95ca59c0bae1c75c688e"
|
sha256: "1976370a4df3091bb0f72409c187ad1f9132a818bc6b95ca59c0bae1c75c688e"
|
||||||
@@ -533,14 +525,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.0"
|
||||||
universal_io:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: universal_io
|
|
||||||
sha256: f63cbc48103236abf48e345e07a03ce5757ea86285ed313a6a032596ed9301e2
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.1"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ dependencies:
|
|||||||
shared_preferences: ^2.5.3
|
shared_preferences: ^2.5.3
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
go_router: ^18.0.1
|
go_router: ^18.0.1
|
||||||
country_picker: ^2.0.28
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
image: ^4.9.0
|
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^6.0.0
|
flutter_lints: ^6.0.0
|
||||||
|
|||||||
@@ -1,176 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
import 'package:country_picker/country_picker.dart';
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:sxchnge_theme/sxchnge_theme.dart';
|
|
||||||
|
|
||||||
import 'package:sxchnge_app/kyc/country.dart';
|
|
||||||
|
|
||||||
import 'package:sxchnge_app/generated/i18n/app_localizations.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
final search = find.byKey(const ValueKey('country-search'));
|
|
||||||
final button = find.byType(OutlinedButton);
|
|
||||||
|
|
||||||
Future<void> mount(
|
|
||||||
WidgetTester tester,
|
|
||||||
ValueNotifier<String> value, {
|
|
||||||
Locale locale = const Locale('en'),
|
|
||||||
bool enabled = true,
|
|
||||||
}) async {
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
theme: SxchngeTheme.light(),
|
|
||||||
locale: locale,
|
|
||||||
localizationsDelegates: const [
|
|
||||||
...AppLocalizations.localizationsDelegates,
|
|
||||||
CountryLocalizations.delegate,
|
|
||||||
],
|
|
||||||
supportedLocales: AppLocalizations.supportedLocales,
|
|
||||||
home: Scaffold(
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: ValueListenableBuilder<String>(
|
|
||||||
valueListenable: value,
|
|
||||||
builder: (_, code, _) => CountryField(
|
|
||||||
value: code,
|
|
||||||
enabled: enabled,
|
|
||||||
onChanged: (code) => value.value = code,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> open(WidgetTester tester) async {
|
|
||||||
await tester.tap(button);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
}
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'name search stores code, reselection and cancel preserve value',
|
|
||||||
(tester) async {
|
|
||||||
final value = ValueNotifier('');
|
|
||||||
addTearDown(value.dispose);
|
|
||||||
await mount(tester, value);
|
|
||||||
expect(find.text('Select a country'), findsOneWidget);
|
|
||||||
await open(tester);
|
|
||||||
await tester.enterText(search, 'polAND');
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await tester.tap(find.text('Poland'));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(value.value, 'PL');
|
|
||||||
expect(find.text('Poland'), findsOneWidget);
|
|
||||||
expect(find.text('0/2'), findsNothing);
|
|
||||||
|
|
||||||
await open(tester);
|
|
||||||
await tester.enterText(search, ' de ');
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await tester.tap(find.text('Germany'));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(value.value, 'DE');
|
|
||||||
expect(find.text('Germany'), findsOneWidget);
|
|
||||||
|
|
||||||
await open(tester);
|
|
||||||
await tester.enterText(search, 'poland');
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await tester.tap(find.byType(BackButton));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(value.value, 'DE');
|
|
||||||
expect(find.text('Germany'), findsOneWidget);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
testWidgets('no-results state recovers through clear and Escape cancels', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final value = ValueNotifier('PL');
|
|
||||||
addTearDown(value.dispose);
|
|
||||||
await mount(tester, value);
|
|
||||||
await open(tester);
|
|
||||||
await tester.enterText(search, 'no-such-country');
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.textContaining('No countries found'), findsOneWidget);
|
|
||||||
expect(find.byType(ListTile), findsNothing);
|
|
||||||
expect(value.value, 'PL');
|
|
||||||
await tester.tap(find.byTooltip('Clear search'));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.textContaining('No countries found'), findsNothing);
|
|
||||||
expect(find.byType(ListTile), findsWidgets);
|
|
||||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(search, findsNothing);
|
|
||||||
expect(value.value, 'PL');
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('saved code follows locale and Russian names are searchable', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final value = ValueNotifier('PL');
|
|
||||||
addTearDown(value.dispose);
|
|
||||||
await mount(tester, value);
|
|
||||||
expect(find.text('Poland'), findsOneWidget);
|
|
||||||
await mount(tester, value, locale: const Locale('ru'));
|
|
||||||
expect(find.text('Польша'), findsOneWidget);
|
|
||||||
expect(value.value, 'PL');
|
|
||||||
await open(tester);
|
|
||||||
await tester.enterText(search, 'Германия');
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await tester.tap(find.byType(ListTile));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(value.value, 'DE');
|
|
||||||
expect(find.text('Германия'), findsOneWidget);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('busy field cannot open or change selection', (tester) async {
|
|
||||||
final value = ValueNotifier('PL');
|
|
||||||
addTearDown(value.dispose);
|
|
||||||
await mount(tester, value, enabled: false);
|
|
||||||
expect(tester.widget<OutlinedButton>(button).onPressed, isNull);
|
|
||||||
await tester.tap(button);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(search, findsNothing);
|
|
||||||
expect(value.value, 'PL');
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'keyboard and labeled touch targets work at 320px with large text',
|
|
||||||
(tester) async {
|
|
||||||
tester.view.physicalSize = const Size(320, 900);
|
|
||||||
tester.view.devicePixelRatio = 1;
|
|
||||||
tester.platformDispatcher.textScaleFactorTestValue = 1.6;
|
|
||||||
addTearDown(tester.view.resetPhysicalSize);
|
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
|
||||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
|
||||||
final semantics = tester.ensureSemantics();
|
|
||||||
final value = ValueNotifier('GS');
|
|
||||||
addTearDown(value.dispose);
|
|
||||||
await mount(tester, value);
|
|
||||||
expect(tester, meetsGuideline(labeledTapTargetGuideline));
|
|
||||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
|
||||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
|
||||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(search, findsOneWidget);
|
|
||||||
await tester.enterText(search, 'GS');
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(tester.widget<ListTile>(find.byType(ListTile)).selected, isTrue);
|
|
||||||
expect(tester, meetsGuideline(labeledTapTargetGuideline));
|
|
||||||
expect(tester, meetsGuideline(androidTapTargetGuideline));
|
|
||||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
|
||||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
|
||||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(search, findsNothing);
|
|
||||||
expect(value.value, 'GS');
|
|
||||||
expect(tester.takeException(), isNull);
|
|
||||||
semantics.dispose();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ import 'package:sxchnge_analytics/sxchnge_analytics.dart';
|
|||||||
|
|
||||||
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
||||||
|
|
||||||
import 'package:sxchnge_app/kyc/country.dart';
|
|
||||||
import 'package:sxchnge_app/main.dart';
|
import 'package:sxchnge_app/main.dart';
|
||||||
import 'package:sxchnge_app/providers/locale.dart';
|
import 'package:sxchnge_app/providers/locale.dart';
|
||||||
|
|
||||||
@@ -70,20 +69,7 @@ void main() {
|
|||||||
await tap(t, find.byKey(const ValueKey('kyc-start')));
|
await tap(t, find.byKey(const ValueKey('kyc-start')));
|
||||||
await t.enterText(find.byKey(const ValueKey('kyc-name')), 'Example Person');
|
await t.enterText(find.byKey(const ValueKey('kyc-name')), 'Example Person');
|
||||||
await t.enterText(find.byKey(const ValueKey('kyc-birth')), '1990-04-23');
|
await t.enterText(find.byKey(const ValueKey('kyc-birth')), '1990-04-23');
|
||||||
await tap(
|
await t.enterText(find.byKey(const ValueKey('kyc-country')), 'PL');
|
||||||
t,
|
|
||||||
find.descendant(
|
|
||||||
of: find.byKey(const ValueKey('kyc-country')),
|
|
||||||
matching: find.byType(OutlinedButton),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await t.enterText(find.byKey(const ValueKey('country-search')), 'PL');
|
|
||||||
await t.pumpAndSettle();
|
|
||||||
await tap(t, find.byType(ListTile));
|
|
||||||
expect(
|
|
||||||
t.widget<CountryField>(find.byKey(const ValueKey('kyc-country'))).value,
|
|
||||||
'PL',
|
|
||||||
);
|
|
||||||
await t.pumpAndSettle();
|
await t.pumpAndSettle();
|
||||||
await tap(t, find.byKey(const ValueKey('pick-passport')));
|
await tap(t, find.byKey(const ValueKey('pick-passport')));
|
||||||
await tap(t, find.byKey(const ValueKey('kyc-next')));
|
await tap(t, find.byKey(const ValueKey('kyc-next')));
|
||||||
|
|||||||
@@ -1,229 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:image/image.dart' as images;
|
|
||||||
|
|
||||||
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
|
||||||
|
|
||||||
import 'package:sxchnge_app/kyc/photo.dart';
|
|
||||||
import 'package:sxchnge_app/kyc/preview.dart';
|
|
||||||
|
|
||||||
import 'package:sxchnge_app/generated/i18n/app_localizations.dart';
|
|
||||||
|
|
||||||
Widget host(Widget child, {Locale locale = const Locale('en')}) => MaterialApp(
|
|
||||||
locale: locale,
|
|
||||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
||||||
supportedLocales: AppLocalizations.supportedLocales,
|
|
||||||
home: Scaffold(body: SingleChildScrollView(child: child)),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Start decoding outside FakeAsync as well as waiting outside it, including
|
|
||||||
// browser codec callbacks that otherwise remain pending in the test zone.
|
|
||||||
Future<void> show(WidgetTester tester, Widget widget) async {
|
|
||||||
await tester.runAsync(() => tester.pumpWidget(widget));
|
|
||||||
}
|
|
||||||
|
|
||||||
// pumpAndSettle alone does not wait for image codecs. Listen to the actual
|
|
||||||
// preview streams so a hidden errorBuilder cannot make this regression pass.
|
|
||||||
Future<void> decoded(WidgetTester tester, {bool succeeds = true}) async {
|
|
||||||
final providers = tester
|
|
||||||
.widgetList<Image>(find.byType(Image))
|
|
||||||
.map((image) => image.image)
|
|
||||||
.toList();
|
|
||||||
expect(providers, isNotEmpty);
|
|
||||||
for (final provider in providers) {
|
|
||||||
Object? renderError;
|
|
||||||
StackTrace? renderStack;
|
|
||||||
await tester.runAsync(() async {
|
|
||||||
final stream = provider.resolve(ImageConfiguration.empty);
|
|
||||||
final ready = Completer<void>();
|
|
||||||
final listener = ImageStreamListener(
|
|
||||||
(info, _) {
|
|
||||||
info.dispose();
|
|
||||||
if (!ready.isCompleted) ready.complete();
|
|
||||||
},
|
|
||||||
onError: (Object error, StackTrace? stack) {
|
|
||||||
renderError = error;
|
|
||||||
renderStack = stack;
|
|
||||||
if (!ready.isCompleted) ready.complete();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
stream.addListener(listener);
|
|
||||||
try {
|
|
||||||
await ready.future.timeout(const Duration(seconds: 15));
|
|
||||||
} finally {
|
|
||||||
stream.removeListener(listener);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
expect(
|
|
||||||
renderError,
|
|
||||||
succeeds ? isNull : isNotNull,
|
|
||||||
reason: succeeds ? '$renderError\n$renderStack' : null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(tester.takeException(), isNull);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
late Uint8List png;
|
|
||||||
late Uint8List jpeg;
|
|
||||||
setUpAll(() {
|
|
||||||
// Synthetic, non-sensitive portrait and landscape photos in both formats.
|
|
||||||
png = images.encodePng(images.Image(width: 1200, height: 1600));
|
|
||||||
jpeg = images.encodeJpg(images.Image(width: 1600, height: 1200));
|
|
||||||
});
|
|
||||||
|
|
||||||
for (final format in ['PNG', 'JPEG']) {
|
|
||||||
testWidgets('accepted $format renders from an immutable photo model', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final source = Uint8List.fromList(format == 'PNG' ? png : jpeg);
|
|
||||||
final photo = (await tester.runAsync(
|
|
||||||
() => FilePhotoService.validate(source),
|
|
||||||
))!;
|
|
||||||
final originalFirstByte = photo.bytes.first;
|
|
||||||
source[0] = 0;
|
|
||||||
expect(photo.bytes.first, originalFirstByte);
|
|
||||||
expect(() => photo.bytes[0] = 0, throwsUnsupportedError);
|
|
||||||
await show(
|
|
||||||
tester,
|
|
||||||
host(PhotoPreview(photo: photo, label: 'ID document photo')),
|
|
||||||
);
|
|
||||||
await decoded(tester);
|
|
||||||
final raw = tester.widget<RawImage>(find.byType(RawImage));
|
|
||||||
expect(raw.image, isNotNull);
|
|
||||||
expect(raw.image!.width, lessThanOrEqualTo(1000));
|
|
||||||
expect(
|
|
||||||
tester.widget<Image>(find.byType(Image)).semanticLabel,
|
|
||||||
'ID document photo',
|
|
||||||
);
|
|
||||||
expect(find.textContaining('damaged'), findsNothing);
|
|
||||||
expect(find.textContaining('could not be displayed'), findsNothing);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
testWidgets('replacement and removal evict sensitive preview cache entries', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final first = Photo(png);
|
|
||||||
await show(tester, host(PhotoPreview(photo: first, label: 'ID')));
|
|
||||||
await decoded(tester);
|
|
||||||
final initialProvider = tester.widget<Image>(find.byType(Image)).image;
|
|
||||||
final initialKey = await initialProvider.obtainKey(
|
|
||||||
ImageConfiguration.empty,
|
|
||||||
);
|
|
||||||
final cache = PaintingBinding.instance.imageCache;
|
|
||||||
expect(cache.statusForKey(initialKey).keepAlive, isTrue);
|
|
||||||
await show(tester, host(PhotoPreview(photo: first, label: 'Document')));
|
|
||||||
await decoded(tester);
|
|
||||||
expect(
|
|
||||||
identical(
|
|
||||||
tester.widget<Image>(find.byType(Image)).image,
|
|
||||||
initialProvider,
|
|
||||||
),
|
|
||||||
isTrue,
|
|
||||||
);
|
|
||||||
await show(tester, host(PhotoPreview(photo: Photo(jpeg), label: 'ID')));
|
|
||||||
await decoded(tester);
|
|
||||||
expect(cache.statusForKey(initialKey).untracked, isTrue);
|
|
||||||
final replacement = tester.widget<Image>(find.byType(Image)).image;
|
|
||||||
final replacementKey = await replacement.obtainKey(
|
|
||||||
ImageConfiguration.empty,
|
|
||||||
);
|
|
||||||
expect(cache.statusForKey(replacementKey).keepAlive, isTrue);
|
|
||||||
expect(tester.widget<RawImage>(find.byType(RawImage)).image!.width, 1000);
|
|
||||||
await show(tester, host(const SizedBox()));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(cache.statusForKey(replacementKey).untracked, isTrue);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('ID and selfie both render on review and after returning', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final passport = Photo(png);
|
|
||||||
final selfie = Photo(jpeg);
|
|
||||||
for (var visit = 0; visit < 2; visit++) {
|
|
||||||
await show(
|
|
||||||
tester,
|
|
||||||
host(
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
PhotoPanel(
|
|
||||||
kind: PhotoKind.passport,
|
|
||||||
photo: passport,
|
|
||||||
review: true,
|
|
||||||
),
|
|
||||||
PhotoPanel(kind: PhotoKind.selfie, photo: selfie, review: true),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await decoded(tester);
|
|
||||||
final previews = tester.widgetList<RawImage>(find.byType(RawImage));
|
|
||||||
expect(previews.length, 2);
|
|
||||||
expect(previews.every((image) => image.image != null), isTrue);
|
|
||||||
expect(find.text('Choose a different photo'), findsNothing);
|
|
||||||
await show(tester, host(const SizedBox()));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (final locale in ['en', 'ru']) {
|
|
||||||
testWidgets(
|
|
||||||
'$locale preview failure explains recovery and can be replaced',
|
|
||||||
(tester) async {
|
|
||||||
tester.view.physicalSize = const Size(320, 900);
|
|
||||||
tester.view.devicePixelRatio = 1;
|
|
||||||
tester.platformDispatcher.textScaleFactorTestValue = 1.6;
|
|
||||||
addTearDown(tester.view.resetPhysicalSize);
|
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
|
||||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
|
||||||
var replacements = 0;
|
|
||||||
var removals = 0;
|
|
||||||
await show(
|
|
||||||
tester,
|
|
||||||
host(
|
|
||||||
PhotoPanel(
|
|
||||||
kind: PhotoKind.passport,
|
|
||||||
photo: Photo(Uint8List.fromList([1, 2, 3])),
|
|
||||||
onPick: () => replacements++,
|
|
||||||
onRemove: () => removals++,
|
|
||||||
),
|
|
||||||
locale: Locale(locale),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await decoded(tester, succeeds: false);
|
|
||||||
final l = AppLocalizations.of(tester.element(find.byType(PhotoPanel)))!;
|
|
||||||
expect(find.text(l.kycErrorPreview), findsOneWidget);
|
|
||||||
expect(find.text(l.kycErrorUnreadable), findsNothing);
|
|
||||||
expect(
|
|
||||||
tester.getSemantics(find.text(l.kycErrorPreview)),
|
|
||||||
matchesSemantics(isLiveRegion: true, label: l.kycErrorPreview),
|
|
||||||
);
|
|
||||||
final replace = find.byKey(const ValueKey('pick-passport'));
|
|
||||||
await tester.ensureVisible(replace);
|
|
||||||
await tester.tap(replace);
|
|
||||||
final remove = find.text(l.kycRemove);
|
|
||||||
await tester.ensureVisible(remove);
|
|
||||||
await tester.tap(remove);
|
|
||||||
expect(replacements, 1);
|
|
||||||
expect(removals, 1);
|
|
||||||
await show(
|
|
||||||
tester,
|
|
||||||
host(
|
|
||||||
PhotoPanel(kind: PhotoKind.passport, photo: Photo(jpeg)),
|
|
||||||
locale: Locale(locale),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await decoded(tester);
|
|
||||||
expect(find.text(l.kycErrorPreview), findsNothing);
|
|
||||||
expect(tester.widget<RawImage>(find.byType(RawImage)).image, isNotNull);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user