Skip to content

Commit 3b5be30

Browse files
insert N blocks for N charts
1 parent 5cfa786 commit 3b5be30

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

cypress/integration/free-gutenberg.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe('Test Free - gutenberg', function() {
1010
});
1111

1212
it('Create all charts', function() {
13-
//cy.create_available_charts(Cypress.env('chart_types').free);
14-
cy.create_available_charts(1);
13+
cy.create_available_charts(Cypress.env('chart_types').free);
14+
//cy.create_available_charts(1);
1515
});
1616

1717
it('Verify insertion of charts', function() {
@@ -20,37 +20,35 @@ describe('Test Free - gutenberg', function() {
2020
// get rid of that irritating popup
2121
cy.get('.nux-dot-tip__disable').click();
2222

23-
// insert a visualizer block
24-
cy.get('div.edit-post-header-toolbar .block-editor-inserter button').click();
25-
cy.get('.components-popover__content').then(function ($popup) {
26-
cy.wrap($popup).find('.block-editor-inserter__search').type('visua');
27-
cy.wrap($popup).find('.block-editor-inserter__results ul.block-editor-block-types-list li').should('have.length', 1);
28-
cy.wrap($popup).find('.block-editor-inserter__results ul.block-editor-block-types-list li button').click();
29-
});
30-
31-
// see the block has the correct elements.
32-
cy.get('div[data-type="visualizer/chart"]').should('have.length', 1);
33-
cy.get('.visualizer-settings__content-option').should('have.length', 2);
34-
35-
cy.get('.visualizer-settings__content-option').last().click();
36-
cy.wait( Cypress.env('wait') );
37-
38-
3923
var charts = [];
4024
for(var i = 1; i <= parseInt(Cypress.env('chart_types').free); i++){
41-
//charts.push(i);
25+
charts.push(i);
4226
}
43-
charts.push(1);
27+
//charts.push(1);charts.push(2);
4428

4529
cy.wrap(charts).each((num, i, array) => {
46-
cy.get('.visualizer-settings .visualizer-settings__charts-single:nth-child(' + num + ')').find('.visualizer-settings__charts-controls').click();
47-
cy.wait( Cypress.env('wait') );
48-
cy.get('.visualizer-settings .visualizer-settings__chart').should('have.length', 1);
49-
cy.get('.visualizer-settings .visualizer-settings__chart > div').should('have.length', 1);
50-
cy.get('.visualizer-settings .components-button-group button').should('have.length', 2);
51-
// go back to insert another one.
52-
cy.get('.visualizer-settings .components-button-group button').first().click();
53-
cy.wait( Cypress.env('wait') );
30+
// insert a visualizer block
31+
cy.get('div.edit-post-header-toolbar .block-editor-inserter button').click();
32+
cy.get('.components-popover__content').then(function ($popup) {
33+
cy.wrap($popup).find('.block-editor-inserter__search').type('visua');
34+
cy.wrap($popup).find('.block-editor-inserter__results ul.block-editor-block-types-list li').should('have.length', 1);
35+
cy.wrap($popup).find('.block-editor-inserter__results ul.block-editor-block-types-list li button').click();
36+
});
37+
38+
// see the block has the correct elements.
39+
cy.get('div[data-type="visualizer/chart"]').should('have.length', num);
40+
cy.get('div[data-type="visualizer/chart"]:nth-child(' + num + ')').then( ($block) => {
41+
cy.wrap($block).find('.visualizer-settings__content-option').should('have.length', 2);
42+
43+
cy.wrap($block).find('.visualizer-settings__content-option').last().click();
44+
cy.wait( Cypress.env('wait') );
45+
46+
cy.wrap($block).find('.visualizer-settings .visualizer-settings__charts-single:nth-child(' + num + ') .visualizer-settings__charts-controls').click();
47+
cy.wait( Cypress.env('wait') );
48+
cy.wrap($block).find('.visualizer-settings .visualizer-settings__chart').should('have.length', 1);
49+
cy.wrap($block).find('.visualizer-settings .visualizer-settings__chart > div').should('have.length', 1);
50+
cy.wrap($block).find('.visualizer-settings .components-button-group button').should('have.length', 2);
51+
});
5452
});
5553
});
5654

cypress/support/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ import './commands'
2323
Cypress.Cookies.defaults({
2424
whitelist: /wordpress_.*/
2525
})
26+
27+
Cypress.on('uncaught:exception', (err, runnable) => {
28+
// ignore crossorigin errors - happens when a chart is inserted in Gutenberg.
29+
expect(err.message).to.include('crossorigin');
30+
31+
// returning false here prevents Cypress from
32+
// failing the test
33+
return false
34+
})

0 commit comments

Comments
 (0)