Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
FluxDown/test/cloud_plan_snapshot_test.dart at main · zerx-lab/FluxDown · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
zerx-lab
/
FluxDown
Public
Notifications
You must be signed in to change notification settings
Fork
147
Star
2.9k
Code
Issues
319
Pull requests
7
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Files
Expand file tree
main
Breadcrumbs
FluxDown
/
test
/
cloud_plan_snapshot_test.dart
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
111 lines (101 loc) · 3.79 KB
main
Breadcrumbs
FluxDown
/
test
/
cloud_plan_snapshot_test.dart
Copy path
Top
File metadata and controls
Code
Blame
111 lines (101 loc) · 3.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// 套餐目录本地快照契约(账户页 cloud_plans_catalog / web fluxdown.cloud.plansCatalog):
// CloudPlan.toJson 必须与 fromJson 互逆,否则冷启动从快照恢复的徽标会与
// 上次网络拉取渲染的不一致(错样式/丢编号),违背「上次最终显示的 UI」承诺。
import
'dart:convert'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flux_down/src/services/cloud/cloud_models.dart'
;
void
main
() {
test
(
'CloudPlan 快照经 jsonEncode/Decode 往返后徽标与价格字段逐项一致'
, () {
const
wire
=
{
'code'
:
'founder'
,
'name'
:
'创始会员'
,
'description'
:
'限量买断'
,
'badge'
:
'创始会员'
,
'icon'
:
'crown'
,
'color'
:
'#b8860b'
,
'badgeStyle'
:
'medal'
,
'badgeColor'
:
'#d97706'
,
'badgeNumbered'
:
true
,
'badgeNumberDigits'
:
4
,
'priceMinor'
:
19900
,
'currency'
:
'CNY'
,
'highlights'
:
[
'终身有效'
,
'专属徽标'
],
'entitlements'
:
{
'maxSyncDevices'
:
10
,
'originIdEdit'
:
true
},
'sort'
:
5
,
'campaign'
:
{
'name'
:
'首发'
,
'endAt'
:
'2026-09-01T00:00:00Z'
,
'stages'
:
[
{
'label'
:
'早鸟'
,
'priceMinor'
:
14900
,
'quota'
:
100
},
{
'label'
:
'原价'
,
'priceMinor'
:
19900
,
'quota'
:
null
},
],
'soldTotal'
:
42
,
'stageSold'
:
[
42
,
0
],
'currentStageIndex'
:
0
,
'effectivePriceMinor'
:
14900
,
},
};
final
restored
=
CloudPlan
.
fromJson
(
jsonDecode
(
jsonEncode
(
CloudPlan
.
fromJson
(wire).
toJson
()))
as
Map
<
String
,
dynamic
>,
);
expect
(restored.code,
'founder'
);
expect
(restored.badge,
'创始会员'
);
expect
(restored.badgeStyle,
'medal'
);
expect
(restored.badgeColor,
'#d97706'
);
expect
(restored.badgeNumbered, isTrue);
expect
(restored.badgeNumberDigits,
4
);
expect
(restored.icon,
'crown'
);
expect
(restored.color,
'#b8860b'
);
expect
(restored.priceMinor,
19900
);
expect
(restored.effectivePriceMinor,
14900
);
expect
(restored.entitlementsRaw[
'maxSyncDevices'
],
10
);
final
campaign
=
restored.campaign
!
;
expect
(campaign.currentStage
!
.label,
'早鸟'
);
expect
(campaign.currentStage
!
.quota,
100
);
expect
(campaign.stages[
1
].quota, isNull);
expect
(campaign.stageSold, [
42
,
0
]);
});
test
(
'用户资料保留下架当前套餐的徽标展示快照'
, () {
const
currentPlan
=
{
'code'
:
'legacy'
,
'name'
:
'典藏套餐'
,
'description'
:
'已下架但仍归属用户'
,
'badge'
:
'典藏会员'
,
'icon'
:
'crown'
,
'color'
:
'#6d28d9'
,
'badgeStyle'
:
'medal'
,
'badgeColor'
:
'#7c3aed'
,
'badgeNumbered'
:
true
,
'badgeNumberDigits'
:
5
,
};
const
profileWire
=
{
'id'
:
'u1'
,
'email'
:
'u1@example.com'
,
'nickname'
:
'用户'
,
'plan'
:
'legacy'
,
'status'
:
'active'
,
'createdAt'
:
'2026-08-16T00:00:00Z'
,
'entitlements'
:
<
String
,
dynamic
>
{},
'currentPlan'
:
currentPlan,
};
final
profile
=
CloudProfile
.
fromJson
(profileWire);
expect
(profile.currentPlan
?
.code, profile.user.plan);
expect
(profile.currentPlan
?
.name,
'典藏套餐'
);
expect
(profile.currentPlan
?
.badge,
'典藏会员'
);
expect
(profile.currentPlan
?
.badgeStyle,
'medal'
);
expect
(profile.currentPlan
?
.badgeColor,
'#7c3aed'
);
expect
(profile.currentPlan
?
.badgeNumbered, isTrue);
expect
(profile.currentPlan
?
.badgeNumberDigits,
5
);
});
test
(
'无 campaign / 无徽标的免费档快照往返后 badge 保持 null'
, () {
const
wire
=
{
'code'
:
'free'
,
'name'
:
'免费版'
};
final
restored
=
CloudPlan
.
fromJson
(
jsonDecode
(
jsonEncode
(
CloudPlan
.
fromJson
(wire).
toJson
()))
as
Map
<
String
,
dynamic
>,
);
expect
(restored.badge, isNull);
expect
(restored.campaign, isNull);
expect
(restored.badgeStyle,
'outline'
);
});
}
You can’t perform that action at this time.