-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: responsive - disallow editing in small screen (#1419)
When screen width is 480px or less, then editing dashboards is disabled. Instead a message is displayed. The user's changes are preserved, so that if the screen becomes wider than 480px, their changes are again shown. * cypress and unit tests added/updated * NewDashboard and EditDashboard changed from class to fn components
- Loading branch information
1 parent
4d83168
commit 9932951
Showing
14 changed files
with
707 additions
and
146 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Feature: Small screen dashboard | ||
|
||
@nonmutating | ||
Scenario: I view a dashboard | ||
Given I open the "Delivery" dashboard | ||
When I go to small screen | ||
Then the small screen view is shown | ||
When I restore the wide screen | ||
Then the wide screen view is shown | ||
|
||
@nonmutating | ||
Scenario: I am editing an existing dashboard | ||
Given I open the "Delivery" dashboard | ||
When I choose to edit dashboard | ||
And dashboard title is changed | ||
And dashboard items are added | ||
When I go to small screen | ||
Then the small screen edit view is shown | ||
When I restore the wide screen | ||
Then the wide screen edit view is shown | ||
And my changes are still there | ||
|
||
@nonmutating | ||
Scenario: I am creating a new dashboard | ||
Given I choose to create new dashboard | ||
And dashboard title is changed | ||
And dashboard items are added | ||
When I go to small screen | ||
Then the small screen edit view is shown | ||
When I restore the wide screen | ||
Then the wide screen edit view is shown | ||
And my changes are still there |
72 changes: 72 additions & 0 deletions
72
cypress/integration/ui/responsive_dashboard/responsive_dashboard.js
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,72 @@ | ||
import { When, Then } from 'cypress-cucumber-preprocessor/steps' | ||
|
||
const TEST_DASHBOARD_TITLE = 'TEST_DASHBOARD_TITLE' | ||
|
||
When('I go to small screen', () => { | ||
cy.viewport(460, 600) | ||
// to account for debounced window resize | ||
cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting | ||
}) | ||
|
||
When('dashboard title is changed', () => { | ||
cy.get('[data-test="dashboard-title-input"]').type(TEST_DASHBOARD_TITLE) | ||
}) | ||
|
||
Then('the small screen view is shown', () => { | ||
//controlbar - no search dashboard field | ||
cy.get('[data-test="link-new-dashboard"]').should('not.be.visible') | ||
|
||
//titlebar - only the More button and the title | ||
cy.get('button').contains('Edit').should('not.be.visible') | ||
cy.get('button').contains('Share').should('not.be.visible') | ||
cy.get('button').contains('Add filter').should('not.be.visible') | ||
cy.get('button').contains('More').should('be.visible') | ||
}) | ||
|
||
When('I restore the wide screen', () => { | ||
cy.viewport(900, 800) | ||
// to account for debounced window resize | ||
cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting | ||
}) | ||
|
||
Then('the wide screen view is shown', () => { | ||
cy.get('[data-test="link-new-dashboard"]').should('be.visible') | ||
|
||
cy.get('button').contains('Edit').should('be.visible') | ||
cy.get('button').contains('Share').should('be.visible') | ||
cy.get('button').contains('Add filter').should('be.visible') | ||
cy.get('button').contains('More').should('be.visible') | ||
}) | ||
|
||
Then('the small screen edit view is shown', () => { | ||
//no controlbar | ||
cy.contains('Save changes').should('not.exist') | ||
cy.contains('Exit without saving').should('not.exist') | ||
|
||
//notice box and no dashboard | ||
cy.contains('dashboards on small screens is not supported').should( | ||
'be.visible' | ||
) | ||
// no title or item grid | ||
cy.get('[data-test="dashboard-title-input"]').should('not.exist') | ||
cy.get('.react-grid-layout').should('not.exist') | ||
}) | ||
|
||
Then('the wide screen edit view is shown', () => { | ||
//controlbar | ||
cy.get('button').contains('Save changes').should('be.visible') | ||
cy.get('button').contains('Exit without saving').should('be.visible') | ||
|
||
cy.get('[data-test="dashboard-title-input"]').should('be.visible') | ||
cy.get('.react-grid-layout').should('be.visible') | ||
}) | ||
|
||
Then('my changes are still there', () => { | ||
//title or item changes | ||
var re = new RegExp(TEST_DASHBOARD_TITLE, 'g') | ||
cy.get('[data-test="dashboard-title-input"] input').should($input => { | ||
const val = $input.val() | ||
|
||
expect(val).to.match(re) | ||
}) | ||
}) |
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
Oops, something went wrong.