Skip to content

Commit

Permalink
Merge branch 'develop' into mikep/23064-spec-name-display
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-plummer authored Aug 16, 2022
2 parents ea2af61 + e703ab4 commit f6b4af1
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 55 deletions.
8 changes: 4 additions & 4 deletions packages/app/src/specs/DirectoryItem.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div
:title="props.name"
:title="name"
class="flex text-sm py-4px items-center"
>
<i-cy-chevron-down-small_x16
Expand All @@ -9,8 +9,8 @@
/>
<i-cy-folder_x16 class="h-16px mr-8px w-16px group-hocus:icon-light-indigo-300 group-hocus:icon-dark-indigo-400" />
<HighlightedText
:text="props.name"
:indexes="props.indexes"
:text="name"
:indexes="indexes"
class="text-gray-400 group-focus:text-indigo-300"
highlight-classes="font-bold text-white"
/>
Expand All @@ -20,7 +20,7 @@
<script lang="ts" setup>
import HighlightedText from './HighlightedText.vue'
const props = withDefaults(defineProps<{ name: string, expanded: boolean, indexes: number[] }>(), {
withDefaults(defineProps<{ name: string, expanded: boolean, indexes: number[] }>(), {
name: '',
expanded: false,
indexes: () => [],
Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/specs/InlineSpecList.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ describe('InlineSpecList', () => {

it('should support fuzzy sort', () => {
mountInlineSpecList()
cy.get('input').type('scome', { force: true })
cy.get('input').type('compspec')

cy.get('li').should('have.length', 4)
.should('contain', 'src/components')
.and('contain', 'Spec-A.spec.tsx')

// Don't want the search to be too fuzzy
// sr => src, co => components, se => spec
cy.get('input').clear().type('srcose')
cy.get('li').should('have.length', 0)
})

it('should open CreateSpec modal', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/specs/InlineSpecListTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
:file-name="row.data.data?.fileName || row.data.name"
:extension="row.data.data?.specFileExtension || ''"
:selected="isCurrentSpec(row.data)"
:indexes="row.data?.data?.fileIndexes"
:indexes="row.data.highlightIndexes"
class="pl-22px"
data-cy="spec-file-item"
/>
Expand All @@ -50,7 +50,7 @@
class="children:truncate"
:name="row.data.name"
:expanded="treeSpecList[row.index].expanded.value"
:indexes="getDirIndexes(row.data)"
:indexes="row.data.highlightIndexes"
data-cy="directory-item"
/>
</RouterLink>
Expand All @@ -62,7 +62,7 @@
<script setup lang="ts">
import { useCollapsibleTree } from '@packages/frontend-shared/src/composables/useCollapsibleTree'
import type { UseCollapsibleTreeNode } from '@packages/frontend-shared/src/composables/useCollapsibleTree'
import { buildSpecTree, getDirIndexes } from './spec-utils'
import { buildSpecTree } from './spec-utils'
import type { SpecTreeNode, FuzzyFoundSpec } from './spec-utils'
import SpecFileItem from './SpecFileItem.vue'
import { computed, watch, onMounted } from 'vue'
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/specs/RowDirectory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
class="icon-dark-white icon-light-gray-200"
/>
<div
:title="props.name"
:title="name"
class="text-gray-600 truncate"
>
<HighlightedText
:text="props.name"
:indexes="props.indexes"
:text="name"
:indexes="indexes"
class="font-medium"
highlight-classes="text-gray-1000"
/>
Expand All @@ -34,7 +34,7 @@
import IconFolder from '~icons/cy/folder_x16.svg'
import HighlightedText from './HighlightedText.vue'
const props = withDefaults(defineProps<{ name: string, expanded: boolean, indexes: number[], depth: number }>(), {
withDefaults(defineProps<{ name: string, expanded: boolean, indexes: number[], depth: number }>(), {
name: '',
expanded: false,
indexes: () => [],
Expand Down
12 changes: 9 additions & 3 deletions packages/app/src/specs/SpecFileItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,33 @@
>
<HighlightedText
:text="fileName"
:indexes="indexes.filter((idx) => idx < fileName.length)"
:indexes="split.fileNameIndexes"
class="font-medium pl-8px whitespace-nowrap"
:class="selected ? 'text-white' : 'group-focus:text-indigo-300 text-gray-400 group-hover:text-indigo-300'"
/>
<HighlightedText
:text="extension"
:indexes="indexes.filter((idx) => idx >= fileName.length).map(idx => idx - fileName.length)"
:indexes="split.extensionIndexes"
class="text-gray-700"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import DocumentIconBlank from '~icons/cy/document-blank_x16'
import HighlightedText from './HighlightedText.vue'
import { deriveIndexes } from './spec-utils'
withDefaults(defineProps<{
const props = withDefaults(defineProps<{
fileName: string
extension: string
selected?: boolean
indexes: number[]
}>(), { indexes: () => [], selected: false })
const split = computed(() => {
return deriveIndexes(props.fileName, props.indexes)
})
</script>
12 changes: 9 additions & 3 deletions packages/app/src/specs/SpecItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
>
<HighlightedText
:text="fileName"
:indexes="indexes.filter((idx) => idx < fileName.length)"
:indexes="split.fileNameIndexes"
class="font-medium text-indigo-500 group-hocus:text-indigo-700"
highlight-classes="text-gray-1000"
/>
<HighlightedText
:text="extension"
:indexes="indexes.filter((idx) => idx >= fileName.length).map(idx => idx - fileName.length)"
:indexes="split.extensionIndexes"
class="font-light group-hocus:text-gray-400"
highlight-classes="text-gray-1000"
/>
Expand All @@ -29,11 +29,17 @@
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import HighlightedText from './HighlightedText.vue'
import { deriveIndexes } from './spec-utils'
withDefaults(defineProps<{
const props = withDefaults(defineProps<{
fileName: string
extension: string
indexes?: number[]
}>(), { indexes: () => [] })
const split = computed(() => {
return deriveIndexes(props.fileName, props.indexes)
})
</script>
9 changes: 7 additions & 2 deletions packages/app/src/specs/SpecsList.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('<SpecsList />', { keystrokeDelay: 0 }, () => {
return ctx
},
render: (gqlVal) => {
return <SpecsList gql={gqlVal} onShowCreateSpecModal={showCreateSpecModalSpy} />
return <SpecsList gql={gqlVal} onShowCreateSpecModal={showCreateSpecModalSpy} mostRecentUpdate={null} />
},
})
}
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('<SpecsList />', { keystrokeDelay: 0 }, () => {

cy.get('@specsListInput').type(longestSpec.fileName)
cy.get('[data-cy="spec-list-directory"]').first()
.should('contain', longestSpec.relative.replace(`/${longestSpec.fileName}${longestSpec.specFileExtension}`, ''))
.should('contain', longestSpec.relative.replace(`/${longestSpec.baseName}`, ''))

cy.get('[data-cy="spec-list-file"]').last().within(() => {
cy.contains('a', longestSpec.baseName)
Expand All @@ -92,6 +92,11 @@ describe('<SpecsList />', { keystrokeDelay: 0 }, () => {
cy.get('[data-cy="spec-list-directory"]').first().should('contain', directory)
cy.percySnapshot('matching directory search')

// Support full relative path search
cy.get('@specsListInput').clear().type(longestSpec.relative)
cy.get('[data-cy="spec-list-directory"]').first().should('contain', directory)
cy.get('[data-cy="spec-list-file"]').should('contain', longestSpec.baseName)

// test interactions

const directories: string[] = Array.from(new Set(specs.map((spec) => spec.relative.split('/')[0]))).sort()
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/specs/SpecsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
v-if="row.data.isLeaf"
:file-name="row.data.data?.fileName || row.data.name"
:extension="row.data.data?.specFileExtension || ''"
:indexes="row.data.data?.fileIndexes"
:indexes="row.data.highlightIndexes"
:style="{ paddingLeft: `${((row.data.depth - 2) * 10) + 22}px` }"
>
<span class="ml-2 inline-block">
Expand All @@ -110,7 +110,7 @@
:expanded="treeSpecList[row.index].expanded.value"
:depth="row.data.depth - 2"
:style="{ paddingLeft: `${(row.data.depth - 2) * 10}px` }"
:indexes="getDirIndexes(row.data)"
:indexes="row.data.highlightIndexes"
:aria-controls="getIdIfDirectory(row)"
@click.stop="row.data.toggle"
/>
Expand Down Expand Up @@ -188,7 +188,7 @@ import { gql, useSubscription } from '@urql/vue'
import { computed, ref, toRef, watch } from 'vue'
import { Specs_SpecsListFragment, SpecsList_GitInfoUpdatedDocument, SpecsListFragment } from '../generated/graphql'
import { useI18n } from '@cy/i18n'
import { buildSpecTree, fuzzySortSpecs, getDirIndexes, makeFuzzyFoundSpec, useCachedSpecs } from './spec-utils'
import { buildSpecTree, fuzzySortSpecs, makeFuzzyFoundSpec, useCachedSpecs } from './spec-utils'
import type { FuzzyFoundSpec } from './spec-utils'
import { useCollapsibleTree } from '@packages/frontend-shared/src/composables/useCollapsibleTree'
import RowDirectory from './RowDirectory.vue'
Expand Down
Loading

0 comments on commit f6b4af1

Please sign in to comment.