-
Notifications
You must be signed in to change notification settings - Fork 492
style: redesign user popover with improved layout and integration with design system #7303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
58ae59e
feat: redesign user popover with improved layout and Figma design
christian-byrne 6f65064
fix: update CurrentUserPopover tests for new div-based menu structure
christian-byrne 9d7cd9f
refactor: replace custom CSS with Tailwind hover utilities and semant…
christian-byrne 4db95ca
refactor: clean up test comments and improve null handling
christian-byrne b167150
fix test
christian-byrne 19f4d2a
change to use test ids
christian-byrne 2f09fae
Update src/components/topbar/CurrentUserPopover.test.ts
christian-byrne a345315
Update src/components/topbar/CurrentUserPopover.test.ts
christian-byrne 355fa06
dont use unnecessary var in tw class
christian-byrne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| import type { VueWrapper } from '@vue/test-utils' | ||
| import { mount } from '@vue/test-utils' | ||
| import Button from 'primevue/button' | ||
| import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { h } from 'vue' | ||
| import { createI18n } from 'vue-i18n' | ||
|
|
||
| import { formatCreditsFromCents } from '@/base/credits/comfyCredits' | ||
| import enMessages from '@/locales/en/main.json' with { type: 'json' } | ||
|
|
||
| import CurrentUserPopover from './CurrentUserPopover.vue' | ||
|
|
@@ -74,7 +74,9 @@ vi.mock('@/stores/firebaseAuthStore', () => ({ | |
| useFirebaseAuthStore: vi.fn(() => ({ | ||
| getAuthHeader: vi | ||
| .fn() | ||
| .mockResolvedValue({ Authorization: 'Bearer mock-token' }) | ||
| .mockResolvedValue({ Authorization: 'Bearer mock-token' }), | ||
| balance: { amount_micros: 100_000 }, // 100,000 cents = ~211,000 credits | ||
| isFetchingBalance: false | ||
| })) | ||
| })) | ||
|
|
||
|
|
@@ -107,6 +109,39 @@ vi.mock('@/components/common/UserCredit.vue', () => ({ | |
| } | ||
| })) | ||
|
|
||
| // Mock formatCreditsFromCents | ||
| vi.mock('@/base/credits/comfyCredits', () => ({ | ||
| formatCreditsFromCents: vi.fn(({ cents }) => (cents / 100).toString()) | ||
| })) | ||
|
|
||
| // Mock useExternalLink | ||
| vi.mock('@/composables/useExternalLink', () => ({ | ||
| useExternalLink: vi.fn(() => ({ | ||
| buildDocsUrl: vi.fn((path) => `https://docs.comfy.org${path}`) | ||
| })) | ||
| })) | ||
|
|
||
| // Mock useFeatureFlags | ||
| vi.mock('@/composables/useFeatureFlags', () => ({ | ||
| useFeatureFlags: vi.fn(() => ({ | ||
| flags: { | ||
| subscriptionTiersEnabled: true | ||
| } | ||
| })) | ||
| })) | ||
|
|
||
| // Mock useTelemetry | ||
| vi.mock('@/platform/telemetry', () => ({ | ||
| useTelemetry: vi.fn(() => ({ | ||
| trackAddApiCreditButtonClicked: vi.fn() | ||
| })) | ||
| })) | ||
christian-byrne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Mock isCloud | ||
| vi.mock('@/platform/distribution/types', () => ({ | ||
| isCloud: true | ||
| })) | ||
|
|
||
| vi.mock('@/platform/cloud/subscription/components/SubscribeButton.vue', () => ({ | ||
| default: { | ||
| name: 'SubscribeButtonMock', | ||
|
|
@@ -145,27 +180,37 @@ describe('CurrentUserPopover', () => { | |
| expect(wrapper.text()).toContain('[email protected]') | ||
| }) | ||
|
|
||
| it('renders logout button with correct props', () => { | ||
| it('calls formatCreditsFromCents with correct parameters and displays formatted credits', () => { | ||
| const wrapper = mountComponent() | ||
|
|
||
| // Find all buttons and get the logout button (last button) | ||
| const buttons = wrapper.findAllComponents(Button) | ||
| const logoutButton = buttons[4] | ||
| expect(formatCreditsFromCents).toHaveBeenCalledWith({ | ||
| cents: 100_000, | ||
| locale: 'en', | ||
| numberOptions: { | ||
| minimumFractionDigits: 0, | ||
| maximumFractionDigits: 2 | ||
| } | ||
| }) | ||
|
|
||
| // Check that logout button has correct props | ||
| expect(logoutButton.props('label')).toBe('Log Out') | ||
| expect(logoutButton.props('icon')).toBe('pi pi-sign-out') | ||
| // Verify the formatted credit string (1000) is rendered in the DOM | ||
| expect(wrapper.text()).toContain('1000') | ||
| }) | ||
|
|
||
| it('opens user settings and emits close event when settings button is clicked', async () => { | ||
| it('renders logout menu item with correct text', () => { | ||
| const wrapper = mountComponent() | ||
|
|
||
| // Find all buttons and get the settings button (third button) | ||
| const buttons = wrapper.findAllComponents(Button) | ||
| const settingsButton = buttons[2] | ||
| const logoutItem = wrapper.find('[data-testid="logout-menu-item"]') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be nice if we could find by a label or name.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory a label or name would cause more drift and bad signal |
||
| expect(logoutItem.exists()).toBe(true) | ||
| expect(wrapper.text()).toContain('Log Out') | ||
| }) | ||
christian-byrne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| it('opens user settings and emits close event when settings item is clicked', async () => { | ||
| const wrapper = mountComponent() | ||
|
|
||
| // Click the settings button | ||
| await settingsButton.trigger('click') | ||
| const settingsItem = wrapper.find('[data-testid="user-settings-menu-item"]') | ||
| expect(settingsItem.exists()).toBe(true) | ||
|
|
||
| await settingsItem.trigger('click') | ||
|
|
||
| // Verify showSettingsDialog was called with 'user' | ||
| expect(mockShowSettingsDialog).toHaveBeenCalledWith('user') | ||
|
|
@@ -175,15 +220,13 @@ describe('CurrentUserPopover', () => { | |
| expect(wrapper.emitted('close')!.length).toBe(1) | ||
| }) | ||
|
|
||
| it('calls logout function and emits close event when logout button is clicked', async () => { | ||
| it('calls logout function and emits close event when logout item is clicked', async () => { | ||
| const wrapper = mountComponent() | ||
|
|
||
| // Find all buttons and get the logout button (last button) | ||
| const buttons = wrapper.findAllComponents(Button) | ||
| const logoutButton = buttons[4] | ||
| const logoutItem = wrapper.find('[data-testid="logout-menu-item"]') | ||
| expect(logoutItem.exists()).toBe(true) | ||
|
|
||
| // Click the logout button | ||
| await logoutButton.trigger('click') | ||
| await logoutItem.trigger('click') | ||
|
|
||
| // Verify handleSignOut was called | ||
| expect(mockHandleSignOut).toHaveBeenCalled() | ||
|
|
@@ -193,15 +236,15 @@ describe('CurrentUserPopover', () => { | |
| expect(wrapper.emitted('close')!.length).toBe(1) | ||
| }) | ||
|
|
||
| it('opens API pricing docs and emits close event when API pricing button is clicked', async () => { | ||
| it('opens API pricing docs and emits close event when partner nodes item is clicked', async () => { | ||
| const wrapper = mountComponent() | ||
|
|
||
| // Find all buttons and get the Partner Nodes info button (first one) | ||
| const buttons = wrapper.findAllComponents(Button) | ||
| const partnerNodesButton = buttons[0] | ||
| const partnerNodesItem = wrapper.find( | ||
| '[data-testid="partner-nodes-menu-item"]' | ||
| ) | ||
| expect(partnerNodesItem.exists()).toBe(true) | ||
|
|
||
| // Click the Partner Nodes button | ||
| await partnerNodesButton.trigger('click') | ||
| await partnerNodesItem.trigger('click') | ||
|
|
||
| // Verify window.open was called with the correct URL | ||
| expect(window.open).toHaveBeenCalledWith( | ||
|
|
@@ -217,11 +260,9 @@ describe('CurrentUserPopover', () => { | |
| it('opens top-up dialog and emits close event when top-up button is clicked', async () => { | ||
| const wrapper = mountComponent() | ||
|
|
||
| // Find all buttons and get the top-up button (second one) | ||
| const buttons = wrapper.findAllComponents(Button) | ||
| const topUpButton = buttons[1] | ||
| const topUpButton = wrapper.find('[data-testid="add-credits-button"]') | ||
| expect(topUpButton.exists()).toBe(true) | ||
|
|
||
| // Click the top-up button | ||
| await topUpButton.trigger('click') | ||
|
|
||
| // Verify showTopUpCreditsDialog was called | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.