@meistrari/tela-build 1.75.1 → 1.75.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
canSubmitNegativeFeedback,
|
|
5
5
|
closeMessageFeedback,
|
|
6
6
|
createMessageFeedbackState,
|
|
7
|
+
isBareFeedbackSubmitInFlight,
|
|
7
8
|
openMessageFeedback,
|
|
8
9
|
submitMessageFeedback,
|
|
9
10
|
toggleMessageFeedbackReason,
|
|
@@ -177,6 +178,46 @@ describe('negative feedback validation', () => {
|
|
|
177
178
|
})
|
|
178
179
|
})
|
|
179
180
|
|
|
181
|
+
describe('bare submission loading', () => {
|
|
182
|
+
it('flags a bare submission while it is in flight and clears it after', async () => {
|
|
183
|
+
const state = createMessageFeedbackState()
|
|
184
|
+
|
|
185
|
+
expect(isBareFeedbackSubmitInFlight(state)).toBe(false)
|
|
186
|
+
|
|
187
|
+
let finish: ((result: { ok: true }) => void) | undefined
|
|
188
|
+
const pending = submitMessageFeedback(
|
|
189
|
+
state,
|
|
190
|
+
'positive',
|
|
191
|
+
async () => await new Promise(resolve => finish = resolve),
|
|
192
|
+
'Não foi possível enviar.',
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
expect(isBareFeedbackSubmitInFlight(state)).toBe(true)
|
|
196
|
+
|
|
197
|
+
finish?.({ ok: true })
|
|
198
|
+
await pending
|
|
199
|
+
expect(isBareFeedbackSubmitInFlight(state)).toBe(false)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it('stays false while a popover submission is in flight', async () => {
|
|
203
|
+
const state = createMessageFeedbackState()
|
|
204
|
+
openMessageFeedback(state, 'negative')
|
|
205
|
+
|
|
206
|
+
let finish: ((result: { ok: true }) => void) | undefined
|
|
207
|
+
const pending = submitMessageFeedback(
|
|
208
|
+
state,
|
|
209
|
+
'negative',
|
|
210
|
+
async () => await new Promise(resolve => finish = resolve),
|
|
211
|
+
'Não foi possível enviar.',
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
expect(isBareFeedbackSubmitInFlight(state)).toBe(false)
|
|
215
|
+
|
|
216
|
+
finish?.({ ok: true })
|
|
217
|
+
await pending
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
|
|
180
221
|
describe('message feedback timeout', () => {
|
|
181
222
|
it('gives up on a handler that never settles and offers a retry', async () => {
|
|
182
223
|
const state = createMessageFeedbackState()
|
|
@@ -72,6 +72,13 @@ export function canSubmitNegativeFeedback(
|
|
|
72
72
|
return state.comment.trim().length > 0
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// A bare thumbs-up submits without opening a popover, so a pending submission
|
|
76
|
+
// with no open rating can only be the bare button's — the popover flows keep
|
|
77
|
+
// openRating set until the vote is confirmed.
|
|
78
|
+
export function isBareFeedbackSubmitInFlight(state: MessageFeedbackState): boolean {
|
|
79
|
+
return state.submitting && state.openRating === null
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
export const DEFAULT_SUBMIT_TIMEOUT_MS = 15_000
|
|
76
83
|
|
|
77
84
|
export async function submitMessageFeedback(
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
canSubmitNegativeFeedback,
|
|
5
5
|
closeMessageFeedback,
|
|
6
6
|
createMessageFeedbackState,
|
|
7
|
+
isBareFeedbackSubmitInFlight,
|
|
7
8
|
openMessageFeedback,
|
|
8
9
|
submitMessageFeedback,
|
|
9
10
|
toggleMessageFeedbackReason,
|
|
@@ -94,6 +95,8 @@ const canSubmitNegative = computed(() => canSubmitNegativeFeedback(
|
|
|
94
95
|
negativeReasons.value,
|
|
95
96
|
))
|
|
96
97
|
|
|
98
|
+
const bareSubmitInFlight = computed(() => isBareFeedbackSubmitInFlight(state))
|
|
99
|
+
|
|
97
100
|
async function submitRating(next: FeedbackRating) {
|
|
98
101
|
const submit: FeedbackSubmitHandler = props.submit ?? (async (payload: FeedbackPayload) => {
|
|
99
102
|
emit('submit', payload)
|
|
@@ -120,12 +123,14 @@ function toggleReason(reason: string) {
|
|
|
120
123
|
cursor-pointer
|
|
121
124
|
:disabled="state.submitting"
|
|
122
125
|
:class="currentRating === 'positive' ? 'bg-green-100 text-green-700' : 'text-icon-secondary hover:bg-subtle hover:text-icon'"
|
|
123
|
-
:aria-label="helpfulLabel"
|
|
126
|
+
:aria-label="bareSubmitInFlight ? submittingLabel : helpfulLabel"
|
|
124
127
|
@click="submitRating('positive')"
|
|
125
128
|
>
|
|
129
|
+
<TelaIconSpinner v-if="bareSubmitInFlight" class="animate-spin" />
|
|
126
130
|
<TelaIcon
|
|
131
|
+
v-else
|
|
127
132
|
:name="currentRating === 'positive' ? 'i-ph-thumbs-up-fill' : 'i-ph-thumbs-up'"
|
|
128
|
-
size="
|
|
133
|
+
size="18px"
|
|
129
134
|
/>
|
|
130
135
|
</button>
|
|
131
136
|
<TelaPopover v-else v-model:open="positiveOpen">
|