diff --git a/public/icons/logo.svg b/public/icons/logo.svg new file mode 100644 index 00000000000..34210e0d662 --- /dev/null +++ b/public/icons/logo.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/platform/cloud/onboarding/components/CloudTemplate.test.ts b/src/platform/cloud/onboarding/components/CloudTemplate.test.ts index 35650cc838b..b0ab43c3876 100644 --- a/src/platform/cloud/onboarding/components/CloudTemplate.test.ts +++ b/src/platform/cloud/onboarding/components/CloudTemplate.test.ts @@ -1,9 +1,40 @@ import { render, screen } from '@testing-library/vue' -import { describe, expect, it } from 'vitest' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { createI18n } from 'vue-i18n' import { createMemoryHistory, createRouter } from 'vue-router' import CloudTemplate from './CloudTemplate.vue' +const i18n = createI18n({ + legacy: false, + locale: 'en', + messages: { en: { g: { comfyOrgLogoAlt: 'ComfyOrg Logo' } } } +}) + +/** + * Drives the real `useMediaQuery`, so the breakpoint the component asks for is + * part of what these tests pin rather than something a mock papers over. + */ +function stubViewportWidth(pixels: number) { + vi.stubGlobal( + 'matchMedia', + vi.fn((query: string) => { + const minWidth = /min-width:\s*([\d.]+)(px|rem)/.exec(query) + const threshold = minWidth + ? Number(minWidth[1]) * (minWidth[2] === 'rem' ? 16 : 1) + : 0 + return { + matches: pixels >= threshold, + media: query, + onchange: null, + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn() + } + }) + ) +} + const renderWithMeta = async (meta: Record) => { const router = createRouter({ history: createMemoryHistory(), @@ -13,23 +44,56 @@ const renderWithMeta = async (meta: Record) => { await router.isReady() return render(CloudTemplate, { global: { - plugins: [router], + plugins: [router, i18n], stubs: { CloudHeroCarousel: { template: '
' }, - CloudTemplateFooter: true + CloudTemplateFooter: { template: '
' }, + CloudTermsNotice: { template: '
' } } } }) } +afterEach(() => { + vi.unstubAllGlobals() +}) + describe('CloudTemplate', () => { - it('shows the hero carousel when the route does not hide it', async () => { + it('shows the hero carousel on a wide viewport', async () => { + stubViewportWidth(1280) await renderWithMeta({}) expect(screen.getByTestId('hero')).toBeInTheDocument() }) it('hides the hero carousel when route.meta.hideHero is set', async () => { + stubViewportWidth(1280) await renderWithMeta({ hideHero: true }) expect(screen.queryByTestId('hero')).not.toBeInTheDocument() }) + + it('does not mount the hero carousel on a tablet-width viewport', async () => { + stubViewportWidth(1024) + await renderWithMeta({}) + expect( + screen.queryByTestId('hero'), + 'mounting below `xl` would download the hero video on devices that never display it' + ).not.toBeInTheDocument() + }) + + it('swaps the footer for the terms notice when the route asks for it', async () => { + stubViewportWidth(1280) + await renderWithMeta({ showTermsNotice: true }) + expect(screen.getByTestId('terms')).toBeInTheDocument() + expect( + screen.queryByTestId('footer'), + 'the notice and the generic footer are alternatives, never both' + ).not.toBeInTheDocument() + }) + + it('shows the generic footer by default', async () => { + stubViewportWidth(1280) + await renderWithMeta({}) + expect(screen.getByTestId('footer')).toBeInTheDocument() + expect(screen.queryByTestId('terms')).not.toBeInTheDocument() + }) }) diff --git a/src/platform/cloud/onboarding/components/CloudTemplate.vue b/src/platform/cloud/onboarding/components/CloudTemplate.vue index a05717835a9..b4548066bf7 100644 --- a/src/platform/cloud/onboarding/components/CloudTemplate.vue +++ b/src/platform/cloud/onboarding/components/CloudTemplate.vue @@ -1,37 +1,47 @@ - diff --git a/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue b/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue index 049747903e4..4ca3db216d2 100644 --- a/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue +++ b/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue @@ -1,7 +1,5 @@ + + diff --git a/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts b/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts index 1aaf1349565..89cb3edbec5 100644 --- a/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts +++ b/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts @@ -33,6 +33,17 @@ describe('cloudOnboardingRoutes', () => { expect(consentRoute?.path).toBe('consent') }) + it('forgot-password keeps the footer its terms and help links live in', () => { + const cloudLayout = cloudOnboardingRoutes.find((r) => r.path === '/cloud') + const forgotPassword = cloudLayout?.children?.find( + (c) => c.name === 'cloud-forgot-password' + ) + + expect(forgotPassword).toBeDefined() + expect(forgotPassword?.meta?.hideFooter).toBeFalsy() + expect(forgotPassword?.meta?.showTermsNotice).toBeFalsy() + }) + it('consent route carries no requiresAuth meta', () => { const oauthLayout = cloudOnboardingRoutes.find((r) => r.path === '/oauth') const consentRoute = oauthLayout?.children?.find( diff --git a/src/platform/cloud/onboarding/onboardingCloudRoutes.ts b/src/platform/cloud/onboarding/onboardingCloudRoutes.ts index 2dda8e45c9a..dbee2617a80 100644 --- a/src/platform/cloud/onboarding/onboardingCloudRoutes.ts +++ b/src/platform/cloud/onboarding/onboardingCloudRoutes.ts @@ -54,6 +54,7 @@ export const cloudOnboardingRoutes: RouteRecordRaw[] = [ name: 'cloud-login', component: () => import('@/platform/cloud/onboarding/CloudLoginView.vue'), + meta: { showTermsNotice: true }, beforeEnter: async (to, _from, next) => { if (!to.query.switchAccount) { const { useCurrentUser } = @@ -72,6 +73,7 @@ export const cloudOnboardingRoutes: RouteRecordRaw[] = [ name: 'cloud-signup', component: () => import('@/platform/cloud/onboarding/CloudSignupView.vue'), + meta: { showTermsNotice: true }, beforeEnter: async (to, _from, next) => { if (!to.query.switchAccount) { const { useCurrentUser } =