fix(chat): remove manual finish button — sale auto-closes when the customer decides
The realistic sales simulation must not offer a "Finish practice / จบการฝึก" button, because the chat is meant to auto-close on buy/walk/try (as originally decided inffb7cdd). The finish button and its chatFinish handler were reintroduced in3c22d88and are now removed; the composer holds only Send and the debrief renders automatically once the session finishes. Regression test asserts no finish/summary button is rendered.
This commit is contained in:
@@ -55,6 +55,22 @@ describe('Chat resume state', () => {
|
||||
expect(wrapper.text()).not.toContain('เลือกสถานการณ์')
|
||||
})
|
||||
|
||||
it('does not render a manual finish/summary button — chat closes only on auto-close', async () => {
|
||||
const { default: Chat } = await import('./Chat.vue')
|
||||
const wrapper = mount(Chat, {
|
||||
global: { stubs: { 'router-link': RouterLinkStub } },
|
||||
})
|
||||
await flushPromises()
|
||||
|
||||
// The sale simulation must auto-close (buy/walk/try); no "จบการฝึก"/"Finish practice"
|
||||
// button should interrupt the realistic conversation.
|
||||
expect(wrapper.find('.composer').exists()).toBe(true)
|
||||
expect(wrapper.text()).not.toContain('Finish practice')
|
||||
expect(wrapper.text()).not.toContain('จบการฝึก')
|
||||
// Only the send control; no ghost finish button.
|
||||
expect(wrapper.find('button.ghost').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('starts a hidden-group admin chat in preview mode', async () => {
|
||||
mocks.api.chatResume.mockRejectedValue(new Error('no active session'))
|
||||
mocks.api.mySessions.mockResolvedValue({ sessions: [] })
|
||||
|
||||
@@ -72,9 +72,6 @@
|
||||
<div v-if="phase === 'chat'" class="composer">
|
||||
<input v-model="text" @keyup.enter="send" :disabled="sending" :placeholder="i18n.t('send')" />
|
||||
<button class="primary" @click="send" :disabled="sending || !text.trim()"><Send :size="16" :stroke-width="1.8" /> {{ i18n.t('send') }}</button>
|
||||
<button class="ghost" @click="finish" :disabled="sending">
|
||||
{{ i18n.locale === 'en' ? 'Finish practice' : 'จบการฝึก' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Debrief -->
|
||||
@@ -161,22 +158,6 @@ async function begin() {
|
||||
}
|
||||
}
|
||||
|
||||
async function finish() {
|
||||
if (sending.value) return
|
||||
sending.value = true
|
||||
try {
|
||||
const res = await api.chatFinish(gid, pid)
|
||||
debrief.value = res.debrief || null
|
||||
messages.value = res.session?.messages || messages.value
|
||||
phase.value = 'done'
|
||||
scrollDown()
|
||||
} catch (e) {
|
||||
alert(i18n.t('chatActionFailed'))
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
persona.value = (await api.getPersona(gid, pid)).persona
|
||||
if (auth.isAdmin) {
|
||||
|
||||
Reference in New Issue
Block a user