Commit 1876d8dd authored by Paul Slaughter's avatar Paul Slaughter

Update frequent_items to upcoming resp styling

- Add `dropdown-item` so that we're not coupled
  to the `.dropdown-menu li > a` styling
- Added `searchClass` prop to the app component
  so that `d-none d-sm-block` only exists for the
  legacy app.
parent 631c7c83
...@@ -30,6 +30,11 @@ export default { ...@@ -30,6 +30,11 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
searchClass: {
type: String,
required: false,
default: '',
},
}, },
computed: { computed: {
...mapVuexModuleState((vm) => vm.vuexModule, [ ...mapVuexModuleState((vm) => vm.vuexModule, [
...@@ -115,7 +120,11 @@ export default { ...@@ -115,7 +120,11 @@ export default {
<template> <template>
<div class="gl-display-flex gl-flex-direction-column gl-flex-align-items-stretch gl-h-full"> <div class="gl-display-flex gl-flex-direction-column gl-flex-align-items-stretch gl-h-full">
<frequent-items-search-input :namespace="namespace" data-testid="frequent-items-search-input" /> <frequent-items-search-input
:namespace="namespace"
:class="searchClass"
data-testid="frequent-items-search-input"
/>
<gl-loading-icon <gl-loading-icon
v-if="isLoadingItems" v-if="isLoadingItems"
:label="translations.loadingMessage" :label="translations.loadingMessage"
......
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
<li class="frequent-items-list-item-container"> <li class="frequent-items-list-item-container">
<a <a
:href="webUrl" :href="webUrl"
class="clearfix" class="clearfix dropdown-item"
@click="track('click_link', { label: `${dropdownType}_dropdown_frequent_items_list_item` })" @click="track('click_link', { label: `${dropdownType}_dropdown_frequent_items_list_item` })"
> >
<div <div
......
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
</script> </script>
<template> <template>
<div class="search-input-container d-none d-sm-block"> <div class="search-input-container">
<gl-search-box-by-type <gl-search-box-by-type
v-model="searchQuery" v-model="searchQuery"
:placeholder="translations.searchInputPlaceholder" :placeholder="translations.searchInputPlaceholder"
......
...@@ -60,6 +60,7 @@ export default function initFrequentItemDropdowns() { ...@@ -60,6 +60,7 @@ export default function initFrequentItemDropdowns() {
namespace, namespace,
currentUserName: this.currentUserName, currentUserName: this.currentUserName,
currentItem: this.currentItem, currentItem: this.currentItem,
searchClass: 'gl-display-none gl-sm-display-block',
}, },
}), }),
], ],
......
...@@ -21,13 +21,14 @@ const TEST_NAMESPACE = 'projects'; ...@@ -21,13 +21,14 @@ const TEST_NAMESPACE = 'projects';
const TEST_VUEX_MODULE = 'frequentProjects'; const TEST_VUEX_MODULE = 'frequentProjects';
const TEST_PROJECT = currentSession[TEST_NAMESPACE].project; const TEST_PROJECT = currentSession[TEST_NAMESPACE].project;
const TEST_STORAGE_KEY = currentSession[TEST_NAMESPACE].storageKey; const TEST_STORAGE_KEY = currentSession[TEST_NAMESPACE].storageKey;
const TEST_SEARCH_CLASS = 'test-search-class';
describe('Frequent Items App Component', () => { describe('Frequent Items App Component', () => {
let wrapper; let wrapper;
let mock; let mock;
let store; let store;
const createComponent = ({ currentItem = null } = {}) => { const createComponent = (props = {}) => {
const session = currentSession[TEST_NAMESPACE]; const session = currentSession[TEST_NAMESPACE];
gon.api_version = session.apiVersion; gon.api_version = session.apiVersion;
...@@ -36,7 +37,8 @@ describe('Frequent Items App Component', () => { ...@@ -36,7 +37,8 @@ describe('Frequent Items App Component', () => {
propsData: { propsData: {
namespace: TEST_NAMESPACE, namespace: TEST_NAMESPACE,
currentUserName: session.username, currentUserName: session.username,
currentItem: currentItem || session.project, currentItem: session.project,
...props,
}, },
provide: { provide: {
vuexModule: TEST_VUEX_MODULE, vuexModule: TEST_VUEX_MODULE,
...@@ -88,7 +90,7 @@ describe('Frequent Items App Component', () => { ...@@ -88,7 +90,7 @@ describe('Frequent Items App Component', () => {
}); });
it('should render search input', () => { it('should render search input', () => {
expect(findSearchInput().exists()).toBe(true); expect(findSearchInput().classes()).toEqual(['search-input-container']);
}); });
it('should render loading animation', async () => { it('should render loading animation', async () => {
...@@ -159,6 +161,16 @@ describe('Frequent Items App Component', () => { ...@@ -159,6 +161,16 @@ describe('Frequent Items App Component', () => {
}); });
}); });
describe('with searchClass', () => {
beforeEach(() => {
createComponent({ searchClass: TEST_SEARCH_CLASS });
});
it('should render search input with searchClass', () => {
expect(findSearchInput().classes()).toEqual(['search-input-container', TEST_SEARCH_CLASS]);
});
});
describe('logging', () => { describe('logging', () => {
it('when created, it should create a project storage entry and adds a project', () => { it('when created, it should create a project storage entry and adds a project', () => {
createComponent(); createComponent();
......
...@@ -16,8 +16,8 @@ const DEFAULT_PROPS = { ...@@ -16,8 +16,8 @@ const DEFAULT_PROPS = {
}; };
const TEST_OTHER_PROPS = { const TEST_OTHER_PROPS = {
namespace: 'projects', namespace: 'projects',
currentUserName: '', currentUserName: 'test-user',
currentItem: {}, currentItem: { id: 'test' },
}; };
describe('~/nav/components/top_nav_container_view.vue', () => { describe('~/nav/components/top_nav_container_view.vue', () => {
...@@ -84,7 +84,7 @@ describe('~/nav/components/top_nav_container_view.vue', () => { ...@@ -84,7 +84,7 @@ describe('~/nav/components/top_nav_container_view.vue', () => {
it('renders frequent items app', () => { it('renders frequent items app', () => {
expect(findFrequentItemsApp()).toEqual({ expect(findFrequentItemsApp()).toEqual({
vuexModule: DEFAULT_PROPS.frequentItemsVuexModule, vuexModule: DEFAULT_PROPS.frequentItemsVuexModule,
props: TEST_OTHER_PROPS, props: expect.objectContaining(TEST_OTHER_PROPS),
attributes: expect.objectContaining(EXTRA_ATTRS), attributes: expect.objectContaining(EXTRA_ATTRS),
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment