|
| 1 | +describe('Test Free - gutenberg (datatable)', function() { |
| 2 | + before(function(){ |
| 3 | + Cypress.config('baseUrl', Cypress.env('host') + 'wp-admin/'); |
| 4 | + |
| 5 | + // login to WP |
| 6 | + cy.visit(Cypress.env('host') + 'wp-login.php'); |
| 7 | + cy.get('#user_login').clear().type( Cypress.env('login') ); |
| 8 | + cy.get('#user_pass').clear().type( Cypress.env('pass') ); |
| 9 | + cy.get('#wp-submit').click(); |
| 10 | + }); |
| 11 | + |
| 12 | + it.skip('temp test', function() { |
| 13 | + }); |
| 14 | + |
| 15 | + it('Create charts charts', function() { |
| 16 | + cy.create_available_charts(1, 'DataTable'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('Verify insertion of charts', function() { |
| 20 | + cy.visit('/post-new.php'); |
| 21 | + |
| 22 | + cy.clear_welcome(); |
| 23 | + |
| 24 | + var charts = Array.from({ length: 1 }, function(_item, index) { |
| 25 | + return index + 1; |
| 26 | + }); |
| 27 | + |
| 28 | + cy.wrap(charts).each((value, i, array) => { |
| 29 | + // insert a visualizer block |
| 30 | + cy.get('div.edit-post-header-toolbar .block-editor-inserter button').click(); |
| 31 | + cy.get('.components-popover__content').then(function ($popup) { |
| 32 | + cy.wrap($popup).find('.block-editor-inserter__search').type('visua'); |
| 33 | + cy.wrap($popup).find('.block-editor-inserter__results ul.block-editor-block-types-list li').should('have.length', 1); |
| 34 | + cy.wrap($popup).find('.block-editor-inserter__results ul.block-editor-block-types-list li button').click(); |
| 35 | + }); |
| 36 | + |
| 37 | + // see the block has the correct elements. |
| 38 | + cy.get('div[data-type="visualizer/chart"]').should('have.length', (i + 2)); |
| 39 | + |
| 40 | + cy.get('div[data-type="visualizer/chart"]:nth-child(' + (i + 1) + ')').then( ($block) => { |
| 41 | + // 2 rows - create and insert |
| 42 | + cy.wrap($block).find('.visualizer-settings__content-option').should('have.length', 2); |
| 43 | + |
| 44 | + // click insert |
| 45 | + cy.wrap($block).find('.visualizer-settings__content-option').last().click({force:true}); |
| 46 | + |
| 47 | + // insert chart |
| 48 | + cy.wrap($block).find('.visualizer-settings .visualizer-settings__charts-single:nth-child(' + (i + 1) + ') .visualizer-settings__charts-controls').click(); |
| 49 | + |
| 50 | + cy.wrap($block).find('.visualizer-settings .visualizer-settings__chart').should('have.length', 1); |
| 51 | + |
| 52 | + // log a line to show which chart we are trying to insert. |
| 53 | + cy.wrap($block).find('.visualizer-settings .visualizer-settings__chart').then( ($chart_block) => { |
| 54 | + cy.log('Processing chart: ' + Cypress.$($chart_block).attr('data-chart-type')); |
| 55 | + }); |
| 56 | + |
| 57 | + // chart and footer divs |
| 58 | + cy.wrap($block).find('.visualizer-settings .visualizer-settings__chart > div').should('have.length', 2); |
| 59 | + |
| 60 | + // 2 buttons, one of them "done" |
| 61 | + cy.wrap($block).find('.visualizer-settings .components-button-group button').should('have.length', 2); |
| 62 | + cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-done').should('have.length', 1); |
| 63 | + |
| 64 | + // click advanced options |
| 65 | + cy.get('.visualizer-advanced-options button.components-button').click({force:true}); |
| 66 | + |
| 67 | + // done button disappears, save button appears |
| 68 | + cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-done').should('have.length', 0); |
| 69 | + cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-save').should('have.length', 1); |
| 70 | + |
| 71 | + // click save button |
| 72 | + cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-save').click({force:true}); |
| 73 | + }); |
| 74 | + }); |
| 75 | + }); |
| 76 | + |
| 77 | +}) |
0 commit comments