Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena committed Apr 14, 2019
1 parent 7ef0ab1 commit 2ebbb4d
Showing 1 changed file with 15 additions and 79 deletions.
94 changes: 15 additions & 79 deletions client/cypress/integration/dashboard/dashboard_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,46 +360,14 @@ describe('Dashboard', () => {
});
});

it('discards drag on cancel', () => {
let start;
cy.get('@textboxEl')
// save initial position, drag textbox 1 col
.then(($el) => {
start = $el.offset();
editDashboard();
return dragBy(cy.get('@textboxEl'), 200);
})
// cancel
.then(() => {
cy.get('.dashboard-header').within(() => {
cy.contains('button', 'Cancel').click();
});
return cy.get('@textboxEl');
})
// verify returned to original position
.then(($el) => {
expect($el.offset()).to.deep.eq(start);
});
});
it('auto saves after drag', () => {
cy.server();
cy.route('POST', 'api/widgets/*').as('WidgetSave');

it('saves drag on apply', () => {
let start;
cy.get('@textboxEl')
// save initial position, drag textbox 1 col
.then(($el) => {
start = $el.offset();
editDashboard();
return dragBy(cy.get('@textboxEl'), 200);
})
// apply
.then(() => {
cy.contains('button', 'Apply Changes').click();
return cy.get('@textboxEl');
})
// verify move
.then(($el) => {
expect($el.offset()).to.not.deep.eq(start);
});
editDashboard();
dragBy(cy.get('@textboxEl'), 330).then(() => {
cy.wait('@WidgetSave');
});
});
});

Expand Down Expand Up @@ -458,46 +426,14 @@ describe('Dashboard', () => {
});
});

it('discards resize on cancel', () => {
let start;
cy.get('@textboxEl')
// save initial position, resize textbox 1 col
.then(($el) => {
start = $el.height();
editDashboard();
return resizeBy(cy.get('@textboxEl'), 0, 200);
})
// cancel
.then(() => {
cy.get('.dashboard-header').within(() => {
cy.contains('button', 'Cancel').click();
});
return cy.get('@textboxEl');
})
// verify returned to original size
.then(($el) => {
expect($el.height()).to.eq(start);
});
});
it('auto saves after resize', () => {
cy.server();
cy.route('POST', 'api/widgets/*').as('WidgetSave');

it('saves resize on apply', () => {
let start;
cy.get('@textboxEl')
// save initial position, resize textbox 1 col
.then(($el) => {
start = $el.height();
editDashboard();
return resizeBy(cy.get('@textboxEl'), 0, 200);
})
// apply
.then(() => {
cy.contains('button', 'Apply Changes').click().should('not.exist');
return cy.get('@textboxEl');
})
// verify size change persists
.then(($el) => {
expect($el.height()).to.not.eq(start);
});
editDashboard();
resizeBy(cy.get('@textboxEl'), 200).then(() => {
cy.wait('@WidgetSave');
});
});
});
});
Expand Down Expand Up @@ -678,7 +614,7 @@ describe('Dashboard', () => {

it('disables edit mode', function () {
cy.visit(this.dashboardEditUrl);
cy.contains('button', 'Apply Changes')
cy.contains('button', 'Done Editing')
.as('saveButton')
.should('be.disabled');

Expand Down

0 comments on commit 2ebbb4d

Please sign in to comment.