test: refs #7058 chnges requested
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
629b89fe2f
commit
5e2158daf4
|
@ -34,17 +34,13 @@ const pinnedModules = computed(() => {
|
|||
const search = ref(null);
|
||||
|
||||
const filteredItems = computed(() => {
|
||||
return filterItems();
|
||||
});
|
||||
function filterItems() {
|
||||
if (!search.value) return items.value;
|
||||
const normalizedSearch = normalize(search.value);
|
||||
return items.value.filter((item) => {
|
||||
const locale = normalize(t(item.title));
|
||||
return locale.includes(normalizedSearch);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
const filteredPinnedModules = computed(() => {
|
||||
if (!search.value) return pinnedModules.value;
|
||||
const normalizedSearch = search.value
|
||||
|
@ -75,7 +71,7 @@ watch(
|
|||
items.value = [];
|
||||
getRoutes();
|
||||
},
|
||||
{ deep: true }
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
function findMatches(search, item) {
|
||||
|
@ -122,7 +118,7 @@ function getMainRoutes() {
|
|||
|
||||
for (const item of modules) {
|
||||
const moduleDef = routes.find(
|
||||
(route) => toLowerCamel(route.name) === item.module
|
||||
(route) => toLowerCamel(route.name) === item.module,
|
||||
);
|
||||
if (!moduleDef) continue;
|
||||
item.children = [];
|
||||
|
@ -233,9 +229,16 @@ const searchModule = () => {
|
|||
</template>
|
||||
<template v-for="(item, index) in filteredItems" :key="item.name">
|
||||
<template
|
||||
v-if="search ||item.children && !filteredPinnedModules.has(item.name)"
|
||||
v-if="
|
||||
search ||
|
||||
(item.children && !filteredPinnedModules.has(item.name))
|
||||
"
|
||||
>
|
||||
<LeftMenuItem :item="item" group="modules" :class="search && index === 0 ? 'searched' : ''">
|
||||
<LeftMenuItem
|
||||
:item="item"
|
||||
group="modules"
|
||||
:class="search && index === 0 ? 'searched' : ''"
|
||||
>
|
||||
<template #side>
|
||||
<QBtn
|
||||
v-if="item.isPinned === true"
|
||||
|
@ -352,7 +355,7 @@ const searchModule = () => {
|
|||
.header {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
.searched{
|
||||
.searched {
|
||||
background-color: var(--vn-section-hover-color);
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -166,7 +166,7 @@ describe('getRoutes', () => {
|
|||
expect(getMethodB).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call getMethodA when source is main', () => {
|
||||
it('should call getMethodA when source is not exists or undefined', () => {
|
||||
let props = { source: 'methodC' };
|
||||
expect(() => fn(props)).toThrowError('Method not defined');
|
||||
|
||||
|
@ -193,10 +193,16 @@ describe('Leftmenu as main', () => {
|
|||
expect(vm.source).toBe('main');
|
||||
});
|
||||
|
||||
it('should filter items based on search input', async () => {
|
||||
vm.search = 'cust';
|
||||
await vm.$nextTick();
|
||||
expect(vm.filteredItems[0].name).toEqual('customer');
|
||||
expect(vm.filteredItems[0].module).toEqual('customer');
|
||||
});
|
||||
it('should filter items based on search input', async () => {
|
||||
vm.search = 'Rou';
|
||||
await vm.$nextTick();
|
||||
expect(vm.filterItems()).toEqual([]);
|
||||
expect(vm.filteredItems).toEqual([]);
|
||||
});
|
||||
|
||||
it('should return pinned items', () => {
|
||||
|
@ -205,7 +211,7 @@ describe('Leftmenu as main', () => {
|
|||
{ name: 'Item 2', isPinned: true },
|
||||
];
|
||||
expect(vm.pinnedModules).toEqual(
|
||||
new Map([['Item 2', { name: 'Item 2', isPinned: true }]])
|
||||
new Map([['Item 2', { name: 'Item 2', isPinned: true }]]),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue