Skip to content

Commit 66508b0

Browse files
mmilad75ibrkhalil
authored andcommitted
Wallet - Add malli spec to Quo Wallet components (batch 3) (#18783)
* draft * add account_card * add account-origin * add account_overview * add account_permission * add address_text * add confirmation_progress * wrapping up * resolve comments and fix ci issues * fix ci issues * fix transaction_progress tests * fix all tests * fix lint issues * add network-link * add token-input * add wallet-overview * add context-tag * add wallet-activity * add transaction-progress * add transaction-summary * add default value to render-with-theme-provider * draft * add default value to context-tag schema * fix lint issues * resolve comments * add :string type to image type * update ?image-source schema
1 parent 5f37033 commit 66508b0

File tree

28 files changed

+382
-254
lines changed

28 files changed

+382
-254
lines changed

src/quo/components/markdown/list/component_spec.cljs

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
(h/describe "tests for markdown/list component"
77
(h/test "renders component with title"
8-
(h/render [list/view {:title "test title"}])
8+
(h/render-with-theme-provider [list/view {:title "test title"}])
99
(h/is-truthy (h/get-by-text "test title")))
1010

1111
(h/test "renders component with description"
12-
(h/render [list/view
13-
{:title "test title"
14-
:description "test description"}])
12+
(h/render-with-theme-provider [list/view
13+
{:title "test title"
14+
:description "test description"}])
1515
(h/is-truthy (h/get-by-text "test description")))
1616

1717
(h/test "renders component with title and description"
18-
(h/render [list/view
19-
{:title "test title"
20-
:description "test description"}])
18+
(h/render-with-theme-provider [list/view
19+
{:title "test title"
20+
:description "test description"}])
2121
(h/is-truthy (h/get-by-text "test title"))
2222
(h/is-truthy (h/get-by-text "test description")))
2323

@@ -29,11 +29,11 @@
2929
(h/is-truthy (h/get-by-label-text :step-counter)))
3030

3131
(h/test "renders decription with a context tag component and description after the tag"
32-
(h/render [list/view
33-
{:step-number 1
34-
:description "Lorem ipsum "
35-
:tag-name "dolor"
36-
:description-after-tag "text after tag"}])
32+
(h/render-with-theme-provider [list/view
33+
{:step-number 1
34+
:description "Lorem ipsum "
35+
:tag-name "dolor"
36+
:description-after-tag "text after tag"}])
3737
(h/is-truthy (h/get-by-text "Lorem ipsum"))
3838
(h/is-truthy (h/get-by-label-text :user-avatar))
3939
(h/is-truthy (h/get-by-text "dolor"))

src/quo/components/settings/settings_item/component_spec.cljs

+19-19
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,47 @@
1212

1313
(h/describe "Settings list tests"
1414
(h/test "Default render of Setting list component"
15-
(h/render [settings-item/view props])
15+
(h/render-with-theme-provider [settings-item/view props])
1616
(h/is-truthy (h/get-by-label-text :settings-item)))
1717

1818
(h/test "It renders a title"
19-
(h/render [settings-item/view props])
19+
(h/render-with-theme-provider [settings-item/view props])
2020
(h/is-truthy (h/get-by-text "Account")))
2121

2222
(h/test "its gets passed an on press event"
2323
(let [event (h/mock-fn)]
24-
(h/render [settings-item/view
25-
(merge props {:on-press event})])
24+
(h/render-with-theme-provider [settings-item/view
25+
(merge props {:on-press event})])
2626
(h/fire-event :press (h/get-by-text "Account"))
2727
(h/was-called event)))
2828

2929
(h/test "on change event gets fired for toggle"
3030
(let [on-change (h/mock-fn)]
31-
(h/render [settings-item/view
32-
(merge props
33-
{:action :selector
34-
:action-props {:on-change on-change}})])
31+
(h/render-with-theme-provider [settings-item/view
32+
(merge props
33+
{:action :selector
34+
:action-props {:on-change on-change}})])
3535
(h/fire-event :press (h/get-by-label-text :toggle-off))
3636
(h/was-called on-change)))
3737

3838
(h/test "It renders a label"
39-
(h/render [settings-item/view (merge props {:label :color})])
39+
(h/render-with-theme-provider [settings-item/view (merge props {:label :color})])
4040
(h/is-truthy (h/get-by-label-text :label-component)))
4141

4242
(h/test "It renders a status tag component"
43-
(h/render [settings-item/view
44-
(merge props
45-
{:tag :context
46-
:tag-props {:context "Test Tag"
47-
:icon :i/placeholder}})])
43+
(h/render-with-theme-provider [settings-item/view
44+
(merge props
45+
{:tag :context
46+
:tag-props {:context "Test Tag"
47+
:icon :i/placeholder}})])
4848
(h/is-truthy (h/get-by-text "Test Tag")))
4949

5050
(h/test "on press event gets fired for button"
5151
(let [event (h/mock-fn)]
52-
(h/render [settings-item/view
53-
(merge props
54-
{:action :button
55-
:action-props {:button-text "test button"
56-
:on-press event}})])
52+
(h/render-with-theme-provider [settings-item/view
53+
(merge props
54+
{:action :button
55+
:action-props {:button-text "test button"
56+
:on-press event}})])
5757
(h/fire-event :press (h/get-by-text "test button"))
5858
(h/was-called event))))

src/quo/components/switchers/group_messaging_card/component_spec.cljs

+20-20
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,35 @@
8383
(h/is-truthy (h/get-by-label-text :gif)))
8484

8585
(h/test "Status: Read, Type: Audio, Avatar: true"
86-
(h/render [group-messaging-card/view
87-
{:avatar true
88-
:status :read
89-
:type :audio
90-
:title "Title"
91-
:content {:duration "00:32"}}])
86+
(h/render-with-theme-provider [group-messaging-card/view
87+
{:avatar true
88+
:status :read
89+
:type :audio
90+
:title "Title"
91+
:content {:duration "00:32"}}])
9292
(h/is-truthy (h/get-by-text (utils/subtitle :audio nil)))
9393
(h/is-truthy (h/get-by-text "00:32")))
9494

9595
(h/test "Status: Read, Type: Community, Avatar: true"
96-
(h/render [group-messaging-card/view
97-
{:avatar true
98-
:status :read
99-
:type :community
100-
:title "Title"
101-
:content {:community-avatar coinbase-community
102-
:community-name "Coinbase"}}])
96+
(h/render-with-theme-provider [group-messaging-card/view
97+
{:avatar true
98+
:status :read
99+
:type :community
100+
:title "Title"
101+
:content {:community-avatar coinbase-community
102+
:community-name "Coinbase"}}])
103103
(h/is-truthy (h/get-by-text (utils/subtitle :community nil)))
104104
(h/is-truthy (h/get-by-label-text :group-avatar))
105105
(h/is-truthy (h/get-by-text "Coinbase")))
106106

107107
(h/test "Status: Read, Type: Link, Avatar: true"
108-
(h/render [group-messaging-card/view
109-
{:avatar true
110-
:status :read
111-
:type :link
112-
:title "Title"
113-
:content {:icon :placeholder
114-
:text "Rolling St..."}}])
108+
(h/render-with-theme-provider [group-messaging-card/view
109+
{:avatar true
110+
:status :read
111+
:type :link
112+
:title "Title"
113+
:content {:icon :placeholder
114+
:text "Rolling St..."}}])
115115
(h/is-truthy (h/get-by-text (utils/subtitle :link nil)))
116116
(h/is-truthy (h/get-by-label-text :group-avatar))
117117
(h/is-truthy (h/get-by-text "Rolling St..."))))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
(ns quo.components.tags.context-tag.schema
2+
(:require [malli.core :as malli]))
3+
4+
(def ^:private ?context-base
5+
[:map
6+
[:type {:optional true}
7+
[:maybe
8+
[:enum :default :multiuser :group :channel :community :token :network :multinetwork :account
9+
:collectible :address :icon :audio]]]
10+
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
11+
[:theme :schema.common/theme]
12+
[:blur? {:optional true} [:maybe :boolean]]
13+
[:state {:optional true} [:maybe [:enum :selected :default]]]])
14+
15+
(def ^:private ?size
16+
[:map
17+
[:size {:optional true} [:maybe [:enum 24 32]]]])
18+
19+
(def ^:private ?default
20+
[:map
21+
[:profile-picture {:optional true} [:maybe :schema.common/image-source]]
22+
[:full-name {:optional true} [:maybe :string]]])
23+
24+
(def ^:private ?multiuser
25+
[:map
26+
[:users {:optional true}
27+
[:maybe
28+
[:sequential
29+
[:map [:profile-picture {:optional true} [:maybe :schema.common/image-source]]
30+
[:full-name {:optional true} [:maybe :string]]
31+
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]]]]]])
32+
33+
(def ^:private ?group
34+
[:map
35+
[:group-name {:optional true} [:maybe :string]]])
36+
37+
(def ^:private ?channel
38+
[:map
39+
[:community-name {:optional true} [:maybe :string]]
40+
[:channel-name {:optional true} [:maybe :string]]])
41+
42+
(def ^:private ?community
43+
[:map
44+
[:community-name {:optional true} [:maybe :string]]])
45+
46+
(def ^:private ?token
47+
[:map
48+
[:amount {:optional true} [:maybe [:or :string :int]]]
49+
[:token {:optional true} [:maybe :string]]])
50+
51+
(def ^:private ?network
52+
[:map
53+
[:network-logo {:optional true} [:maybe :schema.common/image-source]]
54+
[:network-name {:optional true} [:maybe :string]]])
55+
56+
(def ^:private ?multinetwork
57+
[:map
58+
[:networks {:optional true} [:maybe [:sequential ?network]]]])
59+
60+
(def ^:private ?account
61+
[:map
62+
[:account-name {:optional true} [:maybe :string]]
63+
[:emoji {:optional true} [:maybe :string]]])
64+
65+
(def ^:private ?collectible
66+
[:map
67+
[:collectible {:optional true} [:maybe :schema.common/image-source]]
68+
[:collectible-name {:optional true} [:maybe :string]]
69+
[:collectible-number {:optional true} [:maybe [:or :string :int]]]])
70+
71+
(def ^:private ?address
72+
[:map
73+
[:address {:optional true} [:maybe :string]]])
74+
75+
(def ^:private ?icon
76+
[:map
77+
[:icon {:optional true} [:maybe :keyword]]
78+
[:context {:optional true} [:maybe :string]]])
79+
80+
(def ^:private ?audio
81+
[:map
82+
[:duration {:optional true} [:maybe :string]]])
83+
84+
(def ?schema
85+
[:=>
86+
[:catn
87+
[:props
88+
[:multi {:dispatch :type}
89+
[::malli/default [:merge ?default ?size ?context-base]]
90+
[:default [:merge ?default ?size ?context-base]]
91+
[:multiuser [:merge ?multiuser ?context-base]]
92+
[:group [:merge ?group ?size ?context-base]]
93+
[:channel [:merge ?channel ?size ?context-base]]
94+
[:community [:merge ?community ?size ?context-base]]
95+
[:token [:merge ?token ?size ?context-base]]
96+
[:network [:merge ?network ?context-base]]
97+
[:multinetwork [:merge ?multinetwork ?context-base]]
98+
[:account [:merge ?account ?size ?context-base]]
99+
[:collectible [:merge ?collectible ?size ?context-base]]
100+
[:address [:merge ?address ?size ?context-base]]
101+
[:icon [:merge ?icon ?size ?context-base]]
102+
[:audio [:merge ?audio ?context-base]]]]]
103+
:any])

src/quo/components/tags/context_tag/view.cljs

+5-65
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
[quo.components.icon :as icons]
77
[quo.components.list-items.preview-list.view :as preview-list]
88
[quo.components.markdown.text :as text]
9+
[quo.components.tags.context-tag.schema :as component-schema]
910
[quo.components.tags.context-tag.style :as style]
1011
[quo.components.utilities.token.view :as token]
1112
[quo.foundations.colors :as colors]
1213
[quo.theme :as quo.theme]
13-
[react-native.core :as rn]))
14+
[react-native.core :as rn]
15+
[schema.core :as schema]))
1416

1517
(defn- tag-skeleton
1618
[{:keys [theme size text] :or {size 24}} logo-component]
@@ -157,67 +159,5 @@
157159
nil)])
158160

159161
(def view
160-
"Properties:
161-
type, state, blur? & customization-color
162-
163-
Depending on the `type` selected, different properties are accepted:
164-
- `:default` or `nil`:
165-
- size
166-
- profile-picture
167-
- full-name
168-
169-
- `:multiuser`:
170-
- users (vector of {:profile-picture pic, :full-name \"a name\"})
171-
172-
- `:group`
173-
- size
174-
- group-name
175-
176-
- `:community`
177-
- size
178-
- community-logo (valid rn/image :source value)
179-
- community-name
180-
181-
- `:channel`
182-
- size
183-
- community-logo (valid rn/image :source value)
184-
- community-name
185-
- channel-name
186-
187-
- `:token`
188-
- size
189-
- amount
190-
- token
191-
192-
- `:network`
193-
- size
194-
- network-logo (valid rn/image :source value)
195-
- network-name
196-
197-
- `:multinetworks`
198-
- networks (vector of {:network-logo pic, :network-name \"a name\"})
199-
200-
- `:account`
201-
- size
202-
- account-name
203-
- emoji (string containing an emoji)
204-
205-
- `:collectible`
206-
- size
207-
- collectible (valid rn/image :source value)
208-
- collectible-name
209-
- collectible-number
210-
211-
- `:address`
212-
- size
213-
- address (string)
214-
215-
- `:icon`
216-
- size
217-
- icon
218-
- context (string)
219-
220-
- `:audio`
221-
- duration (string)
222-
"
223-
(quo.theme/with-theme view-internal))
162+
(quo.theme/with-theme
163+
(schema/instrument #'view-internal component-schema/?schema)))

src/quo/components/text_combinations/page_top/component_spec.cljs

+15-15
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@
3737
(h/is-truthy (h/get-by-text "This is a textual description")))
3838

3939
(h/test "Context tag"
40-
(h/render [page-top/view
41-
{:title "Title"
42-
:description :context-tag
43-
:context-tag context-tag-data}])
40+
(h/render-with-theme-provider [page-top/view
41+
{:title "Title"
42+
:description :context-tag
43+
:context-tag context-tag-data}])
4444

4545
(h/is-truthy (h/get-by-text "Title"))
4646
(h/is-truthy (h/get-by-label-text :context-tag)))
4747

4848
(h/test "Summary"
49-
(h/render [page-top/view
50-
{:title "Title"
51-
:description :summary
52-
:summary {:row-1 {:text-1 "Send"
53-
:text-2 "from"
54-
:context-tag-1 context-tag-data
55-
:context-tag-2 context-tag-data}
56-
:row-2 {:text-1 "to"
57-
:text-2 "via"
58-
:context-tag-1 context-tag-data
59-
:context-tag-2 context-tag-data}}}])
49+
(h/render-with-theme-provider [page-top/view
50+
{:title "Title"
51+
:description :summary
52+
:summary {:row-1 {:text-1 "Send"
53+
:text-2 "from"
54+
:context-tag-1 context-tag-data
55+
:context-tag-2 context-tag-data}
56+
:row-2 {:text-1 "to"
57+
:text-2 "via"
58+
:context-tag-1 context-tag-data
59+
:context-tag-2 context-tag-data}}}])
6060

6161
(h/is-truthy (h/get-by-text "Title"))
6262
(h/is-truthy (h/get-by-text "Send"))

0 commit comments

Comments
 (0)