Localize IPFS upload and attach messages
Give IpfsUploadConfigException a reason enum mapped to l10n strings in the attach flow, and show a localized empty-file message and generic upload-failed message instead of raw English exception text.
This commit is contained in:
1 parent
34db64d7af
commit
c111835bd0
24 files changed
+536
-13
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/helpers/ipfs_link_attach_flow.dart';
|
||||
import 'package:meshcore_open/helpers/ipfs_upload_helper.dart';
|
||||
import 'package:meshcore_open/l10n/app_localizations.dart';
|
||||
|
||||
void main() {
|
||||
const url = 'ipfs://cid';
|
||||
@@ -68,4 +70,31 @@ void main() {
|
||||
expect(IpfsUploadHelper.sampleCid.length, 59);
|
||||
});
|
||||
});
|
||||
|
||||
group('ipfsUploadErrorText', () {
|
||||
final l10n = lookupAppLocalizations(const Locale('en'));
|
||||
|
||||
test('gives every config reason its own localized message', () {
|
||||
final texts = {
|
||||
for (final reason in IpfsUploadConfigError.values)
|
||||
reason: ipfsUploadErrorText(l10n, IpfsUploadConfigException(reason)),
|
||||
};
|
||||
expect(
|
||||
texts[IpfsUploadConfigError.emptyEndpoint],
|
||||
l10n.chat_ipfsUploadNotConfigured,
|
||||
);
|
||||
expect(
|
||||
texts[IpfsUploadConfigError.kuboPathInvalid],
|
||||
l10n.chat_ipfsKuboPathInvalid,
|
||||
);
|
||||
expect(texts.values.toSet(), hasLength(texts.length));
|
||||
});
|
||||
|
||||
test('wraps other errors in the generic message without the prefix', () {
|
||||
expect(
|
||||
ipfsUploadErrorText(l10n, Exception('IPFS upload failed (500): x')),
|
||||
l10n.chat_ipfsUploadFailed('IPFS upload failed (500): x'),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user