Files
ComfyUI_frontend/src/platform/cloud/onboarding/CloudForgotPasswordView.vue
Christian Byrne 62979e3818 refactor: rename firebaseAuthStore to authStore with shared test fixtures (#10483)
## Summary

Rename `useFirebaseAuthStore` → `useAuthStore` and
`FirebaseAuthStoreError` → `AuthStoreError`. Introduce shared mock
factory (`authStoreMock.ts`) to replace 16 independent bespoke mocks.

## Changes

- **What**: Mechanical rename of store, composable, class, and store ID
(`firebaseAuth` → `auth`). Created
`src/stores/__tests__/authStoreMock.ts` — a shared mock factory with
reactive controls, used by all consuming test files. Migrated all 16
test files from ad-hoc mocks to the shared factory.
- **Files**: 62 files changed (rename propagation + new test infra)

## Review Focus

- Mock factory API design in `authStoreMock.ts` — covers all store
properties with reactive `controls` for per-test customization
- Self-test in `authStoreMock.test.ts` validates computed reactivity

Fixes #8219

## Stack

This is PR 1/5 in a stacked refactoring series:
1. **→ This PR**: Rename + shared test fixtures
2. #10484: Extract auth-routing from workspaceApi
3. #10485: Auth token priority tests
4. #10486: Decompose MembersPanelContent
5. #10487: Consolidate SubscriptionTier type

---------

Co-authored-by: Alexander Brown <drjkl@comfy.org>
2026-03-27 00:31:11 -07:00

129 lines
3.4 KiB
Vue

<template>
<div class="flex h-full items-center justify-center p-8">
<div class="max-w-[100vw] p-2 lg:w-96">
<!-- Header -->
<div class="mb-8 flex flex-col gap-4">
<h1 class="my-0 text-xl/normal font-medium">
{{ t('cloudForgotPassword_title') }}
</h1>
<p class="my-0 text-base text-muted">
{{ t('cloudForgotPassword_instructions') }}
</p>
</div>
<!-- Form -->
<form class="flex flex-col gap-6" @submit.prevent="handleSubmit">
<div class="flex flex-col gap-2">
<label
class="mb-2 text-base font-medium opacity-80"
for="reset-email"
>
{{ t('cloudForgotPassword_emailLabel') }}
</label>
<InputText
id="reset-email"
v-model="email"
type="email"
:placeholder="t('cloudForgotPassword_emailPlaceholder')"
class="h-10"
:invalid="!!errorMessage && !email"
autocomplete="email"
required
/>
<small v-if="errorMessage" class="text-red-500">
{{ errorMessage }}
</small>
</div>
<Message v-if="successMessage" severity="success">
{{ successMessage }}
</Message>
<div class="flex flex-col gap-4">
<Button
type="submit"
:loading="loading"
:disabled="!email || loading"
class="h-10 font-medium text-white"
>
{{ t('cloudForgotPassword_sendResetLink') }}
</Button>
<Button
type="button"
variant="secondary"
class="h-10 bg-charcoal-500"
@click="navigateToLogin"
>
{{ t('cloudForgotPassword_backToLogin') }}
</Button>
</div>
</form>
<!-- Help text -->
<p class="mt-5 text-sm text-gray-600">
{{ t('cloudForgotPassword_didntReceiveEmail') }}
</p>
</div>
</div>
</template>
<script setup lang="ts">
import InputText from 'primevue/inputtext'
import Message from 'primevue/message'
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import Button from '@/components/ui/button/Button.vue'
import { useAuthActions } from '@/composables/auth/useAuthActions'
const { t } = useI18n()
const router = useRouter()
const authActions = useAuthActions()
const email = ref('')
const loading = ref(false)
const errorMessage = ref('')
const successMessage = ref('')
const navigateToLogin = () => {
void router.push({ name: 'cloud-login' })
}
const handleSubmit = async () => {
if (!email.value) {
errorMessage.value = t('cloudForgotPassword_emailRequired')
return
}
loading.value = true
errorMessage.value = ''
successMessage.value = ''
try {
// sendPasswordReset is already wrapped and returns a promise
await authActions.sendPasswordReset(email.value)
successMessage.value = t('cloudForgotPassword_passwordResetSent')
// Optionally redirect to login after a delay
setTimeout(() => {
navigateToLogin()
}, 3000)
} catch (error) {
console.error('Password reset error:', error)
errorMessage.value = t('cloudForgotPassword_passwordResetError')
} finally {
loading.value = false
}
}
</script>
<style scoped>
:deep(.p-inputtext) {
border: none !important;
box-shadow: none !important;
background: #2d2e32 !important;
}
</style>