-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Make spec row clickable across entire width #22105
Merged
lmiller1990
merged 5 commits into
develop
from
21783-spec-rows-clickable-across-full-width
Jun 8, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
430ceef
fix: Make spec row clickable across entire width
mike-plummer 7bcd321
Add missing data-cy selector
mike-plummer 64dc697
Merge branch 'develop' into 21783-spec-rows-clickable-across-full-width
mike-plummer 3c94541
Add tests for row expansion behaviors
mike-plummer ad0ac9d
Fix directory row styling issues
mike-plummer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import SpecsListRowItem from './SpecsListRowItem.vue' | ||
|
||
describe('SpecItem', () => { | ||
it('renders a SpecsListRowItem as leaf', () => { | ||
const toggleRowHandler = cy.stub() | ||
|
||
cy.mount(() => ( | ||
<SpecsListRowItem | ||
isLeaf={true} | ||
route={{ path: '/specs/runner', query: { file: '' } }} | ||
onToggleRow={toggleRowHandler} | ||
// @ts-ignore - doesn't know about vSlots | ||
vSlots={{ | ||
file: () => <span>File Name</span>, | ||
'git-info': () => <span>Git Info</span>, | ||
}} | ||
/>)) | ||
|
||
// Clicking directly on file name section should trigger row | ||
cy.get('[data-cy="specs-list-row-file"]').click() | ||
cy.wrap(toggleRowHandler).should('have.callCount', 1) | ||
|
||
// Clicking directory on git info section should trigger row | ||
cy.get('[data-cy="specs-list-row-git-info"]').click() | ||
cy.wrap(toggleRowHandler).should('have.callCount', 2) | ||
|
||
// Clicking elsewhere on row should trigger row | ||
cy.get('[data-cy="spec-item-link"]').click('right') | ||
cy.wrap(toggleRowHandler).should('have.callCount', 3) | ||
}) | ||
|
||
it('renders a SpecsListRowItem as non-leaf', () => { | ||
const toggleRowHandler = cy.stub() | ||
|
||
cy.mount(() => ( | ||
<SpecsListRowItem | ||
isLeaf={false} | ||
onToggleRow={toggleRowHandler} | ||
// @ts-ignore - doesn't know about vSlots | ||
vSlots={{ | ||
file: () => <span>Directory Name</span>, | ||
}} | ||
/>)) | ||
|
||
// Clicking directly on file name section should trigger row | ||
cy.get('[data-cy="specs-list-row-file"]').click() | ||
cy.wrap(toggleRowHandler).should('have.callCount', 1) | ||
|
||
// Clicking elsewhere on row should trigger row | ||
cy.get('[data-cy="spec-item-directory"]').click('right') | ||
cy.wrap(toggleRowHandler).should('have.callCount', 2) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,39 @@ | ||
<template> | ||
<div | ||
class="h-full outline-none border-gray-50 ring-inset grid grid-cols-2 group focus-within:ring-indigo-300 focus-within:ring-1 children:cursor-pointer" | ||
data-cy="specs-list-row" | ||
> | ||
<div> | ||
<slot name="file" /> | ||
</div> | ||
|
||
<div> | ||
<slot name="git-info" /> | ||
</div> | ||
<div data-cy="specs-list-row"> | ||
<component | ||
:is="isLeaf ? 'RouterLink' : 'div'" | ||
class="h-full outline-none border-gray-50 ring-inset grid grid-cols-2 group focus:outline-transparent focus-within:ring-indigo-300 focus-within:ring-1 children:cursor-pointer" | ||
:to="route" | ||
:data-cy="isLeaf ? 'spec-item-link' : 'spec-item-directory'" | ||
@click="emit('toggleRow')" | ||
@click.meta.prevent="handleCtrlClick" | ||
@click.ctrl.prevent="handleCtrlClick" | ||
> | ||
<div data-cy="specs-list-row-file"> | ||
<slot name="file" /> | ||
</div> | ||
|
||
<div data-cy="specs-list-row-git-info"> | ||
<slot name="git-info" /> | ||
</div> | ||
</component> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { RouteLocationRaw } from 'vue-router' | ||
defineProps<{ | ||
isLeaf: boolean | ||
route?: RouteLocationRaw | ||
}>() | ||
const emit = defineEmits<{ | ||
(event: 'toggleRow'): void | ||
}>() | ||
function handleCtrlClick (): void { | ||
// noop intended to reduce the chances of opening tests multiple tabs | ||
// which is not a supported state in Cypress | ||
} | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need both the click handler here and the one that emits the
@toggleRow
event from SpecsListRowItem? Seems like the SpecsListRowItem handler should catch clicks on the RowDirectory at this point.