The upstream project name is gone from code, assets, docs and build
output: brand strings, domains (replypier.site and its app/api/docs/help
subdomains), env prefixes, image and network names, the widget's public
JS API (window.ReplyPier, replypierId/BaseUrl/Config/Token), CSS tokens
(--rp-*), file and directory names, and the WordPress plugin package.
- widget loader is now webclient/replypier.min.js; both bundles rebuilt
from source (backend/assets/widget.{js,css}, frontend/public/webclient)
- NOTICE, llms.txt, CONTRIBUTING, HELP_CENTER_INFRA and config.dev.js
rewritten rather than string-swapped; the demo config no longer ships
the previous vendor's Firebase/Razorpay/Google keys
- new migration replypier_ai_model_001 adds REPLYPIER to the managed
AIModelType and rewrites pre-rename rows
- local compose project, database, role and volume renamed; LOCAL_DEPLOY
documents carrying the old local data over
90 lines
3.4 KiB
TypeScript
90 lines
3.4 KiB
TypeScript
/*
|
|
Copyright 2024-2026 ReplyPier
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import { describe, it, expect, vi } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
import BottomNav from '@/components/layout/BottomNav.vue'
|
|
|
|
// Nav visibility comes from the real permission checks reading the cached
|
|
// user, so give this spec a user who holds everything.
|
|
vi.mock('@/services/user', async () => {
|
|
const { userWithPermissions } = await import('../../fixtures/permissions')
|
|
const user = userWithPermissions([
|
|
'manage_agents', 'manage_users', 'view_all_chats', 'manage_all_chats', 'view_people',
|
|
'manage_knowledge', 'view_analytics', 'view_tickets', 'manage_organization',
|
|
'manage_ai_config', 'manage_subscription',
|
|
])
|
|
return { userService: { getCurrentUser: () => user } }
|
|
})
|
|
|
|
vi.mock('@/composables/useEnterpriseFeatures', () => ({
|
|
useEnterpriseFeatures: () => ({ hasEnterpriseModule: false }),
|
|
}))
|
|
|
|
const routes = ['/conversations', '/people', '/ai-agents', '/analytics', '/knowledge'].map(
|
|
(path) => ({ path, component: { template: '<div />' } })
|
|
)
|
|
routes.push({ path: '/', component: { template: '<div />' } })
|
|
|
|
const makeRouter = () => createRouter({ history: createWebHistory(), routes })
|
|
|
|
const mountNav = async (props = {}, path = '/conversations') => {
|
|
const router = makeRouter()
|
|
await router.push(path)
|
|
await router.isReady()
|
|
return mount(BottomNav, { props, global: { plugins: [router] } })
|
|
}
|
|
|
|
describe('BottomNav', () => {
|
|
it('renders the four primary items plus More', async () => {
|
|
const wrapper = await mountNav()
|
|
const labels = wrapper.findAll('.bottom-nav-label').map((n) => n.text())
|
|
expect(labels).toEqual(['会话', '联系人', 'AI 客服', '数据分析', '更多'])
|
|
})
|
|
|
|
it('marks the current route active', async () => {
|
|
const wrapper = await mountNav({}, '/analytics')
|
|
const active = wrapper.findAll('.bottom-nav-item.active')
|
|
expect(active).toHaveLength(1)
|
|
expect(active[0].text()).toContain('数据分析')
|
|
})
|
|
|
|
it('marks More active when on an overflow route', async () => {
|
|
const wrapper = await mountNav({}, '/knowledge')
|
|
const active = wrapper.findAll('.bottom-nav-item.active')
|
|
expect(active).toHaveLength(1)
|
|
expect(active[0].text()).toContain('更多')
|
|
})
|
|
|
|
it('shows an unread badge on More and caps it at 99+', async () => {
|
|
const wrapper = await mountNav({ unreadCount: 3 })
|
|
expect(wrapper.find('.bottom-nav-badge').text()).toBe('3')
|
|
|
|
await wrapper.setProps({ unreadCount: 120 })
|
|
expect(wrapper.find('.bottom-nav-badge').text()).toBe('99+')
|
|
|
|
await wrapper.setProps({ unreadCount: 0 })
|
|
expect(wrapper.find('.bottom-nav-badge').exists()).toBe(false)
|
|
})
|
|
|
|
it('emits more when the More button is tapped', async () => {
|
|
const wrapper = await mountNav()
|
|
await wrapper.find('button.bottom-nav-item').trigger('click')
|
|
expect(wrapper.emitted('more')).toHaveLength(1)
|
|
})
|
|
})
|