mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
- move navigation components to `apps/studio/components/layouts/Navigation` - add [FloatingMobileToolbar](https://github.com/supabase/supabase/pull/43444/changes#diff-3dffe47fd51ca851d612d8728e03b2dc344ec213d4f3a46a824d3fa32a7cc851) as quick access to tools such as search, assistant, inline editor, etc - behind feature flag and feature preview (true by default as it's a bit annoying to have to enable it all the time as previews are stored in local-storage) - fix sidebar panels closing on viewport resizing (regression from previous pr) https://github.com/user-attachments/assets/d6881e3b-5128-4306-bb82-3ca39c755dba <img width="986" height="697" alt="Screenshot 2026-03-12 at 12 40 11" src="https://github.com/user-attachments/assets/da8511e2-7d01-4237-b814-596031c747c5" />
86 lines
2.7 KiB
TypeScript
86 lines
2.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getProjectBranchSelectorState } from './ProjectBranchSelector.utils'
|
|
|
|
describe('getProjectBranchSelectorState', () => {
|
|
it('returns main branch when branching disabled', () => {
|
|
const result = getProjectBranchSelectorState({
|
|
selectedBranch: undefined,
|
|
isBranchingEnabled: false,
|
|
selectedOrganization: undefined,
|
|
})
|
|
expect(result.isMainBranch).toBe(true)
|
|
expect(result.branchDisplayName).toBe('main')
|
|
})
|
|
|
|
it('returns main when branching enabled and selected branch is default', () => {
|
|
const result = getProjectBranchSelectorState({
|
|
selectedBranch: {
|
|
id: '1',
|
|
name: 'main',
|
|
project_ref: 'ref',
|
|
is_default: true,
|
|
created_at: '',
|
|
} as any,
|
|
isBranchingEnabled: true,
|
|
selectedOrganization: undefined,
|
|
})
|
|
expect(result.isMainBranch).toBe(true)
|
|
expect(result.branchDisplayName).toBe('main')
|
|
})
|
|
|
|
it('returns non-main when branching enabled and selected branch is not default', () => {
|
|
const result = getProjectBranchSelectorState({
|
|
selectedBranch: {
|
|
id: '2',
|
|
name: 'feature-x',
|
|
project_ref: 'ref-2',
|
|
is_default: false,
|
|
created_at: '',
|
|
} as any,
|
|
isBranchingEnabled: true,
|
|
selectedOrganization: undefined,
|
|
})
|
|
expect(result.isMainBranch).toBe(false)
|
|
expect(result.branchDisplayName).toBe('feature-x')
|
|
})
|
|
|
|
it('returns main when selected branch undefined and branching enabled', () => {
|
|
const result = getProjectBranchSelectorState({
|
|
selectedBranch: undefined,
|
|
isBranchingEnabled: true,
|
|
selectedOrganization: undefined,
|
|
})
|
|
expect(result.branchDisplayName).toBe('main')
|
|
})
|
|
|
|
it('returns organization href when org has slug', () => {
|
|
const result = getProjectBranchSelectorState({
|
|
selectedBranch: undefined,
|
|
isBranchingEnabled: false,
|
|
selectedOrganization: { slug: 'my-org', name: 'My Org' } as any,
|
|
})
|
|
expect(result.organizationHref).toBe('/org/my-org')
|
|
expect(result.selectedOrgInitial).toBe('M')
|
|
})
|
|
|
|
it('returns organizations fallback when no org slug', () => {
|
|
const result = getProjectBranchSelectorState({
|
|
selectedBranch: undefined,
|
|
isBranchingEnabled: false,
|
|
selectedOrganization: undefined,
|
|
})
|
|
expect(result.organizationHref).toBe('/organizations')
|
|
expect(result.selectedOrgInitial).toBe('O')
|
|
})
|
|
|
|
it('handles org name with leading/trailing spaces for initial', () => {
|
|
const result = getProjectBranchSelectorState({
|
|
selectedBranch: undefined,
|
|
isBranchingEnabled: false,
|
|
selectedOrganization: { slug: 'x', name: ' Acme ' } as any,
|
|
})
|
|
expect(result.selectedOrgInitial).toBe('A')
|
|
})
|
|
})
|