Skip to content

Commit

Permalink
Made 2 contexts and flipped test order
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena committed Apr 7, 2019
1 parent f7c4ba3 commit 215860e
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions client/cypress/integration/dashboard/dashboard_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ describe('Dashboard', () => {
createNewDashboardByAPI('Foo Bar')
.then(({ slug, id }) => {
this.dashboardUrl = `/dashboard/${slug}`;
this.dashboardEditUrl = `/dashboard/${slug}?edit`;
return addTextboxByAPI('Hello World!', id);
})
.then((elTestId) => {
Expand All @@ -646,52 +647,65 @@ describe('Dashboard', () => {

beforeEach(function () {
cy.visit(this.dashboardUrl);
cy.viewport(800, 800);
});

it('shows widgets with full width', () => {
cy.viewport(801, 800);
cy.get('@textboxEl').should(($el) => {
expect($el.width()).to.eq(393);
expect($el.width()).to.eq(785);
});
cy.viewport(800, 800);

cy.viewport(801, 800);
cy.get('@textboxEl').should(($el) => {
expect($el.width()).to.eq(785);
expect($el.width()).to.eq(393);
});
});

it('hides edit option', () => {
cy.viewport(801, 800);
cy.getByTestId('DashboardMoreMenu')
.click()
.should('be.visible')
.within(() => {
cy.get('li')
.contains('Edit')
.as('editButton')
.should('be.visible');
.should('not.be.visible');
});

cy.viewport(800, 800);
cy.get('@editButton').should('not.be.visible');
cy.viewport(801, 800);
cy.get('@editButton').should('be.visible');
});

it('disables edit mode', () => {
cy.viewport(801, 800);
editDashboard();
cy.get('button')
.contains('Apply Changes')
it('disables edit mode', function () {
cy.visit(this.dashboardEditUrl);
cy.contains('button', 'Apply Changes')
.as('saveButton')
.should('not.be.disabled');
.should('be.disabled');

cy.viewport(800, 800);
cy.get('@saveButton').should('be.disabled');
cy.viewport(801, 800);
cy.get('@saveButton').should('not.be.disabled');
});
});

it('hides menu button when width is under 768px', () => {
cy.viewport(768, 800);
cy.getByTestId('DashboardMoreMenu').should('be.visible');
context('viewport width is at 767px', () => {
before(function () {
cy.login();
createNewDashboardByAPI('Foo Bar').then(({ slug }) => {
this.dashboardUrl = `/dashboard/${slug}`;
});
});

beforeEach(function () {
cy.visit(this.dashboardUrl);
cy.viewport(767, 800);
});

it('hides menu button when width is under 768px', () => {
cy.get('.dashboard__control').should('exist');
cy.getByTestId('DashboardMoreMenu').should('not.be.visible');

cy.viewport(768, 800);
cy.getByTestId('DashboardMoreMenu').should('be.visible');
});
});
});

0 comments on commit 215860e

Please sign in to comment.