forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cypress test - dashboard create/archive (getredash#3565)
- Loading branch information
Showing
6 changed files
with
109 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ FROM cypress/browsers:chrome67 | |
ENV APP /usr/src/app | ||
WORKDIR $APP | ||
|
||
RUN npm install --no-save [email protected] cypress@^3.1.5 @percy/cypress@^0.2.3 [email protected] > /dev/null | ||
COPY package.json $APP/package.json | ||
RUN npm run cypress:install > /dev/null | ||
|
||
COPY cypress $APP/cypress | ||
COPY cypress.json $APP/cypress.json | ||
|
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
32 changes: 17 additions & 15 deletions
32
client/app/components/dashboards/edit-dashboard-dialog.html
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,17 +1,19 @@ | ||
<div class="modal-header"> | ||
<button type="button" class="close" ng-click="$ctrl.dismiss()" ng-disabled="$ctrl.saveInProgress" aria-hidden="true">×</button> | ||
<h4 class="modal-title">New Dashboard</h4> | ||
</div> | ||
<div class="modal-body" ng-if="$ctrl.policy.isCreateDashboardEnabled()"> | ||
<p> | ||
<input type="text" class="form-control" placeholder="Dashboard Name" ng-model="$ctrl.dashboard.name" autofocus ng-keyup="$event.keyCode === 13 && $ctrl.saveDashboard()"> | ||
</p> | ||
</div> | ||
<div class="modal-footer" ng-if="$ctrl.policy.isCreateDashboardEnabled()"> | ||
<button type="button" class="btn btn-default" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.dismiss()">Close</button> | ||
<button type="button" class="btn btn-primary" ng-disabled="$ctrl.saveInProgress || !$ctrl.isFormValid()" ng-click="$ctrl.saveDashboard()">Save</button> | ||
</div> | ||
<div data-test="EditDashboardDialog"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" ng-click="$ctrl.dismiss()" ng-disabled="$ctrl.saveInProgress" aria-hidden="true">×</button> | ||
<h4 class="modal-title">New Dashboard</h4> | ||
</div> | ||
<div class="modal-body" ng-if="$ctrl.policy.isCreateDashboardEnabled()"> | ||
<p> | ||
<input type="text" class="form-control" placeholder="Dashboard Name" ng-model="$ctrl.dashboard.name" autofocus ng-keyup="$event.keyCode === 13 && $ctrl.saveDashboard()"> | ||
</p> | ||
</div> | ||
<div class="modal-footer" ng-if="$ctrl.policy.isCreateDashboardEnabled()"> | ||
<button type="button" class="btn btn-default" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.dismiss()">Close</button> | ||
<button type="button" class="btn btn-primary" ng-disabled="$ctrl.saveInProgress || !$ctrl.isFormValid()" ng-click="$ctrl.saveDashboard()" data-test="DashboardSaveButton">Save</button> | ||
</div> | ||
|
||
<div class="modal-body" ng-if="!$ctrl.policy.isCreateDashboardEnabled()"> | ||
<edit-dashboard-dialog-disabled></edit-dashboard-dialog-disabled> | ||
<div class="modal-body" ng-if="!$ctrl.policy.isCreateDashboardEnabled()"> | ||
<edit-dashboard-dialog-disabled></edit-dashboard-dialog-disabled> | ||
</div> | ||
</div> |
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,59 @@ | ||
function createNewDashboard(dashboardName) { | ||
cy.visit('/dashboards'); | ||
cy.getByTestId('CreateButton').click(); | ||
cy.get('li[role="menuitem"]') | ||
.contains('Dashboard') | ||
.click(); | ||
|
||
cy.server(); | ||
cy.route('POST', 'api/dashboards').as('NewDashboard'); | ||
|
||
cy.getByTestId('EditDashboardDialog').within(() => { | ||
cy.getByTestId('DashboardSaveButton').should('be.disabled'); | ||
cy.get('input').type(dashboardName); | ||
cy.getByTestId('DashboardSaveButton').click(); | ||
}); | ||
|
||
return cy.wait('@NewDashboard').then((xhr) => { | ||
const slug = Cypress._.get(xhr, 'response.body.slug'); | ||
assert.isDefined(slug, 'Dashboard api call returns slug'); | ||
return slug; | ||
}); | ||
} | ||
|
||
function archiveCurrentDashboard() { | ||
cy.getByTestId('DashboardMoreMenu') | ||
.click() | ||
.within(() => { | ||
cy.get('li') | ||
.contains('Archive') | ||
.click(); | ||
}); | ||
|
||
cy.get('.btn-warning') | ||
.contains('Archive') | ||
.click(); | ||
cy.get('.label-tag-archived').should('exist'); | ||
} | ||
|
||
describe('Dashboard', () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
}); | ||
|
||
it('creates a new dashboard and archives it', () => { | ||
createNewDashboard('Foo Bar').then((slug) => { | ||
cy.visit('/dashboards'); | ||
cy.getByTestId('DashboardLayoutContent').within(() => { | ||
cy.getByTestId(slug).should('exist').click(); | ||
}); | ||
|
||
archiveCurrentDashboard(); | ||
|
||
cy.visit('/dashboards'); | ||
cy.getByTestId('DashboardLayoutContent').within(() => { | ||
cy.getByTestId(slug).should('not.exist'); | ||
}); | ||
}); | ||
}); | ||
}); |