From 0bf3a86339567715d347a2d6adbff0f9a013a13d Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Fri, 24 Aug 2018 11:20:47 +1000 Subject: [PATCH] NUX: Move first tip to the toolbar (#9223) * Revert "NUX: Prevent duplicate DotTips from appearing (#8642)" This reverts commit 09dc71c30ebcbf5b1b4475cab433eaa9b21e1908. * NUX: Move first tip to the toolbar Move the first tip to the toolbar so that post content isn't covered, and adjust DotTip so that it can correctly position itself below the inserter button. * s/id/tipId --- .../components/header/header-toolbar/index.js | 7 +- packages/components/src/popover/index.js | 8 +- .../default-block-appender/index.js | 25 +--- .../default-block-appender/style.scss | 16 ++- .../test/__snapshots__/index.js.snap | 24 +--- .../test/__snapshots__/index.js.snap | 4 +- packages/nux/src/components/dot-tip/README.md | 4 +- packages/nux/src/components/dot-tip/index.js | 112 ++++++++---------- .../nux/src/components/dot-tip/style.scss | 10 +- .../dot-tip/test/__snapshots__/index.js.snap | 1 + .../nux/src/components/dot-tip/test/index.js | 8 +- packages/nux/src/store/actions.js | 37 ------ packages/nux/src/store/reducer.js | 37 +----- packages/nux/src/store/selectors.js | 25 ++-- packages/nux/src/store/test/actions.js | 29 +---- packages/nux/src/store/test/reducer.js | 79 +----------- packages/nux/src/store/test/selectors.js | 47 -------- 17 files changed, 106 insertions(+), 367 deletions(-) diff --git a/edit-post/components/header/header-toolbar/index.js b/edit-post/components/header/header-toolbar/index.js index 825d4acecbd29..79de4d2e1fe2f 100644 --- a/edit-post/components/header/header-toolbar/index.js +++ b/edit-post/components/header/header-toolbar/index.js @@ -4,6 +4,7 @@ import { compose } from '@wordpress/compose'; import { withSelect } from '@wordpress/data'; import { withViewportMatch } from '@wordpress/viewport'; +import { DotTip } from '@wordpress/nux'; /** * WordPress dependencies @@ -29,7 +30,11 @@ function HeaderToolbar( { hasFixedToolbar, isLargeViewport } ) { className="edit-post-header-toolbar" aria-label={ __( 'Editor Toolbar' ) } > - + + + { __( 'Welcome to the wonderful world of blocks! Click the “+” (“Add block”) button to add a new block. There are blocks available for all kind of content: you can insert text, headings, images, lists, and lots more!' ) } + + diff --git a/packages/components/src/popover/index.js b/packages/components/src/popover/index.js index 537b9287d72bf..e5b95836e07cc 100644 --- a/packages/components/src/popover/index.js +++ b/packages/components/src/popover/index.js @@ -143,8 +143,7 @@ class Popover extends Component { window.console.warn( ` component: focusOnMount argument "${ focusOnMount }" not recognized.` ); } - getAnchorRect() { - const anchor = this.anchorNode.current; + getAnchorRect( anchor ) { if ( ! anchor || ! anchor.parentNode ) { return; } @@ -185,7 +184,10 @@ class Popover extends Component { computePopoverPosition( popoverSize ) { const { getAnchorRect = this.getAnchorRect, position = 'top', expandOnMobile } = this.props; const newPopoverPosition = computePopoverPosition( - getAnchorRect(), popoverSize || this.state.popoverSize, position, expandOnMobile + getAnchorRect( this.anchorNode.current ), + popoverSize || this.state.popoverSize, + position, + expandOnMobile ); if ( diff --git a/packages/editor/src/components/default-block-appender/index.js b/packages/editor/src/components/default-block-appender/index.js index c89ba5bf6ab2a..b919a0747313b 100644 --- a/packages/editor/src/components/default-block-appender/index.js +++ b/packages/editor/src/components/default-block-appender/index.js @@ -1,7 +1,6 @@ /** * External dependencies */ -import classnames from 'classnames'; import { get } from 'lodash'; /** @@ -12,7 +11,6 @@ import { compose } from '@wordpress/compose'; import { getDefaultBlockName } from '@wordpress/blocks'; import { decodeEntities } from '@wordpress/html-entities'; import { withSelect, withDispatch } from '@wordpress/data'; -import { DotTip } from '@wordpress/nux'; /** * Internal dependencies @@ -29,7 +27,6 @@ export function DefaultBlockAppender( { placeholder, layout, rootClientId, - hasTip, } ) { if ( isLocked || ! isVisible ) { return null; @@ -51,11 +48,7 @@ export function DefaultBlockAppender( { // See: https://gist.github.com/cvrebert/68659d0333a578d75372 return ( -
+
- - - { __( 'Welcome to the wonderful world of blocks! Click the “+” (“Add block”) button to add a new block. There are blocks available for all kind of content: you can insert text, headings, images, lists, and lots more!' ) } - - +
); } export default compose( withSelect( ( select, ownProps ) => { const { getBlockCount, getBlock, getEditorSettings, getTemplateLock } = select( 'core/editor' ); - const { isTipVisible } = select( 'core/nux' ); const isEmpty = ! getBlockCount( ownProps.rootClientId ); const lastBlock = getBlock( ownProps.lastBlockClientId ); @@ -90,7 +78,6 @@ export default compose( showPrompt: isEmpty, isLocked: !! getTemplateLock( ownProps.rootClientId ), placeholder: bodyPlaceholder, - hasTip: isTipVisible( 'core/editor.inserter' ), }; } ), withDispatch( ( dispatch, ownProps ) => { @@ -99,11 +86,9 @@ export default compose( startTyping, } = dispatch( 'core/editor' ); - const { dismissTip } = dispatch( 'core/nux' ); - return { onAppend() { - const { layout, rootClientId, hasTip } = ownProps; + const { layout, rootClientId } = ownProps; let attributes; if ( layout ) { @@ -112,10 +97,6 @@ export default compose( insertDefaultBlock( attributes, rootClientId ); startTyping(); - - if ( hasTip ) { - dismissTip( 'core/editor.inserter' ); - } }, }; } ), diff --git a/packages/editor/src/components/default-block-appender/style.scss b/packages/editor/src/components/default-block-appender/style.scss index 94bde07520d08..bf4ddf0616947 100644 --- a/packages/editor/src/components/default-block-appender/style.scss +++ b/packages/editor/src/components/default-block-appender/style.scss @@ -40,17 +40,15 @@ } } - &:hover .editor-inserter-with-shortcuts { - opacity: 1; + // Don't show the inserter until mousing over. + .editor-inserter__toggle:not([aria-expanded="true"]) { + opacity: 0; } - - // Show the inserter if mousing over or there is a tip. - &:not(.has-tip) { - .editor-inserter__toggle:not([aria-expanded="true"]) { - opacity: 0; + &:hover { + .editor-inserter-with-shortcuts { + opacity: 1; } - - &:hover .editor-inserter__toggle { + .editor-inserter__toggle { opacity: 1; } } diff --git a/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap b/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap index 2917c9e672656..ee4db832dc9d3 100644 --- a/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap +++ b/packages/editor/src/components/default-block-appender/test/__snapshots__/index.js.snap @@ -25,13 +25,7 @@ exports[`DefaultBlockAppender should append a default block when input focused 1 - - Welcome to the wonderful world of blocks! Click the “+” (“Add block”) button to add a new block. There are blocks available for all kind of content: you can insert text, headings, images, lists, and lots more! - - + />
`; @@ -53,13 +47,7 @@ exports[`DefaultBlockAppender should match snapshot 1`] = ` - - Welcome to the wonderful world of blocks! Click the “+” (“Add block”) button to add a new block. There are blocks available for all kind of content: you can insert text, headings, images, lists, and lots more! - - + /> `; @@ -81,12 +69,6 @@ exports[`DefaultBlockAppender should optionally show without prompt 1`] = ` - - Welcome to the wonderful world of blocks! Click the “+” (“Add block”) button to add a new block. There are blocks available for all kind of content: you can insert text, headings, images, lists, and lots more! - - + /> `; diff --git a/packages/editor/src/components/post-preview-button/test/__snapshots__/index.js.snap b/packages/editor/src/components/post-preview-button/test/__snapshots__/index.js.snap index 231157b4f2e7f..3ede1652d63c1 100644 --- a/packages/editor/src/components/post-preview-button/test/__snapshots__/index.js.snap +++ b/packages/editor/src/components/post-preview-button/test/__snapshots__/index.js.snap @@ -8,10 +8,10 @@ exports[`PostPreviewButton render() should match the snapshot 1`] = ` onClick={[Function]} > Preview - Click “Preview” to load a preview of this page, so you can make sure you’re happy with your blocks. - + `; diff --git a/packages/nux/src/components/dot-tip/README.md b/packages/nux/src/components/dot-tip/README.md index 4fb33bb9ddae3..caf164760ffec 100644 --- a/packages/nux/src/components/dot-tip/README.md +++ b/packages/nux/src/components/dot-tip/README.md @@ -3,8 +3,6 @@ DotTip `DotTip` is a React component that renders a single _tip_ on the screen. The tip will point to the React element that `DotTip` is nested within. Each tip is uniquely identified by a string passed to `id`. -When there are multiple instances of `DotTip` that reference the same tip identifier, only the first instance to have been mounted will be visible. - ## Usage ```jsx @@ -23,7 +21,7 @@ The component accepts the following props: ### id -A string that uniquely identifies the tip. Identifiers should be prefixed with the name of the plugin, followed by a `/`. For example, `acme/add-to-cart`. Changing the identifier after the component has mounted is not supported. +A string that uniquely identifies the tip. Identifiers should be prefixed with the name of the plugin, followed by a `/`. For example, `acme/add-to-cart`. - Type: `string` - Required: Yes diff --git a/packages/nux/src/components/dot-tip/index.js b/packages/nux/src/components/dot-tip/index.js index 80e33285906fb..3c60cef7caec2 100644 --- a/packages/nux/src/components/dot-tip/index.js +++ b/packages/nux/src/components/dot-tip/index.js @@ -1,84 +1,74 @@ /** * WordPress dependencies */ -import { Component } from '@wordpress/element'; -import { compose, withInstanceId } from '@wordpress/compose'; +import { compose } from '@wordpress/compose'; import { Popover, Button, IconButton } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { withSelect, withDispatch } from '@wordpress/data'; -export class DotTip extends Component { - componentDidMount() { - this.props.onRegister(); - } - - componentWillUnmount() { - this.props.onUnregister(); - } - - render() { - const { children, isVisible, hasNextTip, onDismiss, onDisable } = this.props; +function getAnchorRect( anchor ) { + // The default getAnchorRect() excludes an element's top and bottom padding + // from its calculation. We want tips to point to the outer margin of an + // element, so we override getAnchorRect() to include all padding. + return anchor.parentNode.getBoundingClientRect(); +} - if ( ! isVisible ) { - return null; - } +function onClick( event ) { + // Tips are often nested within buttons. We stop propagation so that clicking + // on a tip doesn't result in the button being clicked. + event.stopPropagation(); +} - return ( - { - // Tips are often nested within buttons. We stop propagation so that clicking - // on a tip doesn't result in the button being clicked. - event.stopPropagation(); - } } - > -

{ children }

-

- -

- -
- ); +export function DotTip( { + children, + isVisible, + hasNextTip, + onDismiss, + onDisable, +} ) { + if ( ! isVisible ) { + return null; } + + return ( + +

{ children }

+

+ +

+ +
+ ); } export default compose( - withInstanceId, - withSelect( ( select, { id, instanceId } ) => { + withSelect( ( select, { id } ) => { const { isTipVisible, getAssociatedGuide } = select( 'core/nux' ); const associatedGuide = getAssociatedGuide( id ); return { - isVisible: isTipVisible( id, instanceId ), + isVisible: isTipVisible( id ), hasNextTip: !! ( associatedGuide && associatedGuide.nextTipId ), }; } ), - withDispatch( ( dispatch, { id, instanceId } ) => { - const { - registerTipInstance, - unregisterTipInstance, - dismissTip, - disableTips, - } = dispatch( 'core/nux' ); - + withDispatch( ( dispatch, { id } ) => { + const { dismissTip, disableTips } = dispatch( 'core/nux' ); return { - onRegister() { - registerTipInstance( id, instanceId ); - }, - onUnregister() { - unregisterTipInstance( id, instanceId ); - }, onDismiss() { dismissTip( id ); }, diff --git a/packages/nux/src/components/dot-tip/style.scss b/packages/nux/src/components/dot-tip/style.scss index 4d461e0978dab..73db96374b9fe 100644 --- a/packages/nux/src/components/dot-tip/style.scss +++ b/packages/nux/src/components/dot-tip/style.scss @@ -51,10 +51,16 @@ $dot-scale: 3; // How much the pulse animation should scale up by in size } // Position the dot right next to the edge of the button - &.is-left { + &.is-top { + margin-top: -$dot-size / 2; + } + &.is-bottom { + margin-top: $dot-size / 2; + } + &.is-middle.is-left { margin-left: -$dot-size / 2; } - &.is-right { + &.is-middle.is-right { margin-left: $dot-size / 2; } diff --git a/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap b/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap index 374bbdd0c7d53..eb352b831c04e 100644 --- a/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap +++ b/packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap @@ -5,6 +5,7 @@ exports[`DotTip should render correctly 1`] = ` aria-label="Gutenberg tips" className="nux-dot-tip" focusOnMount="container" + getAnchorRect={[Function]} noArrow={true} onClick={[Function]} position="middle right" diff --git a/packages/nux/src/components/dot-tip/test/index.js b/packages/nux/src/components/dot-tip/test/index.js index 884c9422ecb77..aa69872d5e6e8 100644 --- a/packages/nux/src/components/dot-tip/test/index.js +++ b/packages/nux/src/components/dot-tip/test/index.js @@ -14,7 +14,7 @@ jest.mock( '../../../../../components/src/button' ); describe( 'DotTip', () => { it( 'should not render anything if invisible', () => { const wrapper = shallow( - + It looks like you’re writing a letter. Would you like help? ); @@ -23,7 +23,7 @@ describe( 'DotTip', () => { it( 'should render correctly', () => { const wrapper = shallow( - + It looks like you’re writing a letter. Would you like help? ); @@ -33,7 +33,7 @@ describe( 'DotTip', () => { it( 'should call onDismiss when the dismiss button is clicked', () => { const onDismiss = jest.fn(); const wrapper = shallow( - + It looks like you’re writing a letter. Would you like help? ); @@ -44,7 +44,7 @@ describe( 'DotTip', () => { it( 'should call onDisable when the X button is clicked', () => { const onDisable = jest.fn(); const wrapper = shallow( - + It looks like you’re writing a letter. Would you like help? ); diff --git a/packages/nux/src/store/actions.js b/packages/nux/src/store/actions.js index c29fbfd0ed290..ad8adb79c5530 100644 --- a/packages/nux/src/store/actions.js +++ b/packages/nux/src/store/actions.js @@ -13,43 +13,6 @@ export function triggerGuide( tipIds ) { }; } -/** - * Returns an action object that, when dispatched, associates an instance of the - * DotTip component with a tip. This is usually done when the component mounts. - * Tracking this lets us only show one DotTip at a time per tip. - * - * @param {string} tipId The tip to associate this instance with. - * @param {number} instanceId A number which uniquely identifies the instance. - * - * @return {Object} Action object. - */ -export function registerTipInstance( tipId, instanceId ) { - return { - type: 'REGISTER_TIP_INSTANCE', - tipId, - instanceId, - }; -} - -/** - * Returns an action object that, when dispatched, removes the association - * between a DotTip component instance and a tip. This is usually done when the - * component unmounts. Tracking this lets us only show one DotTip at a time per - * tip. - * - * @param {string} tipId The tip to disassociate this instance with. - * @param {number} instanceId A number which uniquely identifies the instance. - * - * @return {Object} Action object. - */ -export function unregisterTipInstance( tipId, instanceId ) { - return { - type: 'UNREGISTER_TIP_INSTANCE', - tipId, - instanceId, - }; -} - /** * Returns an action object that, when dispatched, dismisses the given tip. A * dismissed tip will not show again. diff --git a/packages/nux/src/store/reducer.js b/packages/nux/src/store/reducer.js index 24096aeaee8a5..5ebf8ea394e70 100644 --- a/packages/nux/src/store/reducer.js +++ b/packages/nux/src/store/reducer.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { uniq, without } from 'lodash'; - /** * WordPress dependencies */ @@ -29,36 +24,6 @@ export function guides( state = [], action ) { return state; } -/** - * Reducer that maps each tip to an array of DotTip component instance IDs that are - * displaying that tip. Tracking this allows us to only show one DotTip at a - * time per tip. - * - * @param {Object} state Current state. - * @param {Object} action Dispatched action. - * - * @return {Object} Updated state. - */ -export function tipInstanceIds( state = {}, action ) { - switch ( action.type ) { - case 'REGISTER_TIP_INSTANCE': { - const existingInstanceIds = state[ action.tipId ] || []; - return { - ...state, - [ action.tipId ]: uniq( [ ...existingInstanceIds, action.instanceId ] ), - }; - } - - case 'UNREGISTER_TIP_INSTANCE': - return { - ...state, - [ action.tipId ]: without( state[ action.tipId ], action.instanceId ), - }; - } - - return state; -} - /** * Reducer that tracks whether or not tips are globally enabled. * @@ -105,4 +70,4 @@ export function dismissedTips( state = {}, action ) { const preferences = combineReducers( { areTipsEnabled, dismissedTips } ); -export default combineReducers( { guides, tipInstanceIds, preferences } ); +export default combineReducers( { guides, preferences } ); diff --git a/packages/nux/src/store/selectors.js b/packages/nux/src/store/selectors.js index 149cd30dfb0a3..71669709d42cb 100644 --- a/packages/nux/src/store/selectors.js +++ b/packages/nux/src/store/selectors.js @@ -41,20 +41,16 @@ export const getAssociatedGuide = createSelector( ); /** - * Determines whether the given tip or DotTip instance should be visible. Checks: + * Determines whether or not the given tip is showing. Tips are hidden if they + * are disabled, have been dismissed, or are not the current tip in any + * guide that they have been added to. * - * - That all tips are enabled. - * - That the given tip has not been dismissed. - * - If the given tip is part of a guide, that the given tip is the current tip in the guide. - * - If instanceId is provided, that this is the first DotTip instance for the given tip. - * - * @param {Object} state Global application state. - * @param {string} tipId The tip to query. - * @param {?number} instanceId A number which uniquely identifies the DotTip instance. + * @param {Object} state Global application state. + * @param {string} tipId The tip to query. * - * @return {boolean} Whether the given tip or Dottip instance should be shown. + * @return {boolean} Whether or not the given tip is showing. */ -export function isTipVisible( state, tipId, instanceId ) { +export function isTipVisible( state, tipId ) { if ( ! state.preferences.areTipsEnabled ) { return false; } @@ -68,13 +64,6 @@ export function isTipVisible( state, tipId, instanceId ) { return false; } - if ( instanceId ) { - const [ firstInstanceId ] = state.tipInstanceIds[ tipId ] || []; - if ( instanceId !== firstInstanceId ) { - return false; - } - } - return true; } diff --git a/packages/nux/src/store/test/actions.js b/packages/nux/src/store/test/actions.js index 7bdf580fe9eb8..4e22afe03c8b8 100644 --- a/packages/nux/src/store/test/actions.js +++ b/packages/nux/src/store/test/actions.js @@ -1,14 +1,7 @@ /** * Internal dependencies */ -import { - triggerGuide, - registerTipInstance, - unregisterTipInstance, - dismissTip, - disableTips, - enableTips, -} from '../actions'; +import { triggerGuide, dismissTip, disableTips, enableTips } from '../actions'; describe( 'actions', () => { describe( 'triggerGuide', () => { @@ -20,26 +13,6 @@ describe( 'actions', () => { } ); } ); - describe( 'registerTipInstance', () => { - it( 'should return a REGISTER_TIP_INSTANCE action', () => { - expect( registerTipInstance( 'test/tip-1', 123 ) ).toEqual( { - type: 'REGISTER_TIP_INSTANCE', - tipId: 'test/tip-1', - instanceId: 123, - } ); - } ); - } ); - - describe( 'unregisterTipInstance', () => { - it( 'should return an UNREGISTER_TIP_INSTANCE action', () => { - expect( unregisterTipInstance( 'test/tip-1', 123 ) ).toEqual( { - type: 'UNREGISTER_TIP_INSTANCE', - tipId: 'test/tip-1', - instanceId: 123, - } ); - } ); - } ); - describe( 'dismissTip', () => { it( 'should return an DISMISS_TIP action', () => { expect( dismissTip( 'test/tip' ) ).toEqual( { diff --git a/packages/nux/src/store/test/reducer.js b/packages/nux/src/store/test/reducer.js index 81197e83b0942..d2982a87d7050 100644 --- a/packages/nux/src/store/test/reducer.js +++ b/packages/nux/src/store/test/reducer.js @@ -1,12 +1,7 @@ -/** - * External dependencies - */ -import deepFreeze from 'deep-freeze'; - /** * Internal dependencies */ -import { guides, tipInstanceIds, areTipsEnabled, dismissedTips } from '../reducer'; +import { guides, areTipsEnabled, dismissedTips } from '../reducer'; describe( 'reducer', () => { describe( 'guides', () => { @@ -15,8 +10,7 @@ describe( 'reducer', () => { } ); it( 'should add a guide when it is triggered', () => { - const original = deepFreeze( [] ); - const state = guides( original, { + const state = guides( [], { type: 'TRIGGER_GUIDE', tipIds: [ 'test/tip-1', 'test/tip-2' ], } ); @@ -26,66 +20,6 @@ describe( 'reducer', () => { } ); } ); - describe( 'tipInstanceIds', () => { - it( 'should start out empty', () => { - expect( tipInstanceIds( undefined, {} ) ).toEqual( {} ); - } ); - - it( 'should register an initial tip instance', () => { - const original = deepFreeze( {} ); - const state = tipInstanceIds( original, { - type: 'REGISTER_TIP_INSTANCE', - tipId: 'test/tip-1', - instanceId: 123, - } ); - expect( state ).toEqual( { - 'test/tip-1': [ 123 ], - } ); - } ); - - it( 'should register an second tip instance', () => { - const original = deepFreeze( { - 'test/tip-1': [ 123 ], - } ); - const state = tipInstanceIds( original, { - type: 'REGISTER_TIP_INSTANCE', - tipId: 'test/tip-1', - instanceId: 456, - } ); - expect( state ).toEqual( { - 'test/tip-1': [ 123, 456 ], - } ); - } ); - - it( 'should not register duplicate tip instances', () => { - const original = deepFreeze( { - 'test/tip-1': [ 123 ], - } ); - const state = tipInstanceIds( original, { - type: 'REGISTER_TIP_INSTANCE', - tipId: 'test/tip-1', - instanceId: 123, - } ); - expect( state ).toEqual( { - 'test/tip-1': [ 123 ], - } ); - } ); - - it( 'should unregister a tip instance', () => { - const original = deepFreeze( { - 'test/tip-1': [ 123, 456 ], - } ); - const state = tipInstanceIds( original, { - type: 'UNREGISTER_TIP_INSTANCE', - tipId: 'test/tip-1', - instanceId: 123, - } ); - expect( state ).toEqual( { - 'test/tip-1': [ 456 ], - } ); - } ); - } ); - describe( 'areTipsEnabled', () => { it( 'should default to true', () => { expect( areTipsEnabled( undefined, {} ) ).toBe( true ); @@ -112,8 +46,7 @@ describe( 'reducer', () => { } ); it( 'should mark tips as dismissed', () => { - const original = deepFreeze( {} ); - const state = dismissedTips( original, { + const state = dismissedTips( {}, { type: 'DISMISS_TIP', id: 'test/tip', } ); @@ -123,10 +56,10 @@ describe( 'reducer', () => { } ); it( 'should reset if tips are enabled', () => { - const original = deepFreeze( { + const initialState = { 'test/tip': true, - } ); - const state = dismissedTips( original, { + }; + const state = dismissedTips( initialState, { type: 'ENABLE_TIPS', } ); expect( state ).toEqual( {} ); diff --git a/packages/nux/src/store/test/selectors.js b/packages/nux/src/store/test/selectors.js index f807957abe46d..ed63a7fa828de 100644 --- a/packages/nux/src/store/test/selectors.js +++ b/packages/nux/src/store/test/selectors.js @@ -11,7 +11,6 @@ describe( 'selectors', () => { [ 'test/tip-a', 'test/tip-b', 'test/tip-c' ], [ 'test/tip-α', 'test/tip-β', 'test/tip-γ' ], ], - tipInstanceIds: {}, preferences: { dismissedTips: { 'test/tip-1': true, @@ -57,7 +56,6 @@ describe( 'selectors', () => { it( 'should return true by default', () => { const state = { guides: [], - tipInstanceIds: {}, preferences: { areTipsEnabled: true, dismissedTips: {}, @@ -69,7 +67,6 @@ describe( 'selectors', () => { it( 'should return false if tips are disabled', () => { const state = { guides: [], - tipInstanceIds: {}, preferences: { areTipsEnabled: false, dismissedTips: {}, @@ -81,7 +78,6 @@ describe( 'selectors', () => { it( 'should return false if the tip is dismissed', () => { const state = { guides: [], - tipInstanceIds: {}, preferences: { areTipsEnabled: true, dismissedTips: { @@ -97,7 +93,6 @@ describe( 'selectors', () => { guides: [ [ 'test/tip-1', 'test/tip-2', 'test/tip-3' ], ], - tipInstanceIds: {}, preferences: { areTipsEnabled: true, dismissedTips: {}, @@ -105,53 +100,12 @@ describe( 'selectors', () => { }; expect( isTipVisible( state, 'test/tip-2' ) ).toBe( false ); } ); - - it( 'should return true if an instanceId that was registered first is provided', () => { - const state = { - guides: [], - tipInstanceIds: { - 'test/tip': [ 123, 456 ], - }, - preferences: { - areTipsEnabled: true, - dismissedTips: {}, - }, - }; - expect( isTipVisible( state, 'test/tip', 123 ) ).toBe( true ); - } ); - - it( 'should return false if an instanceId that was NOT registered is provided', () => { - const state = { - guides: [], - tipInstanceIds: {}, - preferences: { - areTipsEnabled: true, - dismissedTips: {}, - }, - }; - expect( isTipVisible( state, 'test/tip', 123 ) ).toBe( false ); - } ); - - it( 'should return false if an instanceId that was NOT registered first is provided', () => { - const state = { - guides: [], - tipInstanceIds: { - 'test/tip': [ 123, 456 ], - }, - preferences: { - areTipsEnabled: true, - dismissedTips: {}, - }, - }; - expect( isTipVisible( state, 'test/tip', 456 ) ).toBe( false ); - } ); } ); describe( 'areTipsEnabled', () => { it( 'should return true if tips are enabled', () => { const state = { guides: [], - tipInstanceIds: {}, preferences: { areTipsEnabled: true, dismissedTips: {}, @@ -163,7 +117,6 @@ describe( 'selectors', () => { it( 'should return false if tips are disabled', () => { const state = { guides: [], - tipInstanceIds: {}, preferences: { areTipsEnabled: false, dismissedTips: {},