Make sure Cypress can know when a story is selected.

This commit is contained in:
Gert Hengeveld 2020-10-08 00:14:40 +02:00
parent 651ae27b8f
commit e9f1ded662
2 changed files with 5 additions and 2 deletions

View File

@ -105,7 +105,7 @@ Cypress.Commands.add('navigateToStory', (kind, name) => {
// assert url changes
cy.url().should('include', `path=/story/${kindId}--${storyId}`);
cy.get(storyLinkId).should('have.class', 'selected');
cy.get(storyLinkId).should('have.attr', 'data-selected', 'true');
// A pause is good when switching stories
// eslint-disable-next-line cypress/no-unnecessary-waiting

View File

@ -83,6 +83,8 @@ const Node = React.memo<NodeProps>(
data-item-id={item.id}
data-parent-id={item.parent}
data-nodetype={item.isComponent ? 'document' : 'story'}
data-selected={isSelected}
data-highlighted={isHighlighted}
data-highlightable={isDisplayed}
depth={isOrphan ? item.depth : item.depth - 1}
isSelected={isSelected}
@ -105,7 +107,7 @@ const Node = React.memo<NodeProps>(
<Action
type="button"
data-action="expand-all"
data-expanded={String(isFullyExpanded)}
data-expanded={isFullyExpanded}
onClick={(event) => {
event.preventDefault();
setFullyExpanded();
@ -126,6 +128,7 @@ const Node = React.memo<NodeProps>(
data-item-id={item.id}
data-parent-id={item.parent}
data-nodetype={item.isComponent ? 'component' : 'group'}
data-highlighted={isHighlighted}
data-highlightable={isDisplayed}
aria-controls={item.children && item.children[0]}
aria-expanded={isExpanded}