Press Escape with the keyboard focus in a dialog, a side panel or a drop-down menu (the step puts the focus there first when it is elsewhere, as a keyboard user's focus is), then wait for the component's answer: it closes (hidden), or it stays (a dialog set not to close with Escape) and stops moving. Check what it did with "should be shown" or "should not be shown".
Examples
When I press Escape in the "Newsletter" dialog
When I press Escape in the "Upload in progress" dialog
When I press Escape in the "Cart" side panel
When I press Escape in the "Account" drop-down menu
When we press Escape in the "Help" side panel
Pattern
When(/^(?:I |we )?press Escape in the "([^"]*)" (dialog|side panel|drop-?down menu)$/, …)
Part of @webship-js/uikit-steps (github.com/webship/uikit-steps), a step pack for Webship-js 2.0.x.