Skip to content

Commit

Permalink
bug(*) set proper route on click (#208)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Wyle台z虈ek <tomwylezek@gmail.com>
  • Loading branch information
tomaszwylezek committed Aug 17, 2021
1 parent 514ff2d commit c8ab05f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 7 deletions.
23 changes: 23 additions & 0 deletions src/components/Sidebar/NavItem.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import renderWithVuex from '@/testUtils/renderWithVuex'
import TestComponent from '@/testUtils/TestComponent.vue'
import NavItem from './NavItem.vue'

describe('NavItem.vue', () => {
it('renders snapshot with link to selected mesh', async () => {
const { container } = renderWithVuex(NavItem, {
routes: [
{
path: '/:mesh/default',
name: 'default',
component: TestComponent,
},
],
propsData: {
name: 'Default',
link: 'default',
},
})

expect(container).toMatchSnapshot()
})
})
8 changes: 7 additions & 1 deletion src/components/Sidebar/NavItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
</template>

<script>
import { mapGetters } from 'vuex'
import { datadogLogs } from '@datadog/browser-logs'
import { datadogLogEvents } from '@/datadogEvents'
Expand Down Expand Up @@ -103,8 +104,13 @@ export default {
}
},
computed: {
...mapGetters({
selectedMesh: 'getSelectedMesh',
}),
routerLink() {
const params = !this.subNav && Object.keys(this.$route?.params || {}).length > 0 ? this.$route?.params : undefined
const params = {
mesh: this.selectedMesh,
}
const link = () => {
if (this.link) {
Expand Down
26 changes: 26 additions & 0 deletions src/components/Sidebar/__snapshots__/NavItem.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`NavItem.vue renders snapshot with link to selected mesh 1`] = `
<div>
<div
class="nav-item is-menu-item"
>
<a
class=""
href="#/all/default"
>
<!---->
<div
class="nav-link"
>
Default
</div>
</a>
</div>
</div>
`;
11 changes: 5 additions & 6 deletions src/components/Utils/MeshSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
</template>

<script>
import { mapGetters } from 'vuex'
export default {
name: 'MeshSelector',
props: {
Expand All @@ -44,12 +46,9 @@ export default {
},
},
computed: {
selectedMesh() {
const stored = localStorage.getItem('selectedMesh')
const query = this.$route.params.mesh
return stored || query
},
...mapGetters({
selectedMesh: 'getSelectedMesh',
}),
},
methods: {
changeMesh(event) {
Expand Down

0 comments on commit c8ab05f

Please sign in to comment.