Skip to content

Commit

Permalink
add basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Jul 1, 2021
1 parent 7c9a98e commit cbd8d34
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 38 deletions.
12 changes: 12 additions & 0 deletions cypress/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ export const setInputValue = (selector, value, type = 'input') => {
});
};

export const save = (path) => {
cy.url().then(($url) => {
if ($url.includes(path)) {
//cy.get('.ui.button.save').click();
cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + path);
} else {
cy.log('Wrong path');
}
});
};

export const filtersModal = {
addFilter: (id, value) => {
cy.get(id).click();
Expand Down
82 changes: 44 additions & 38 deletions cypress/integration/sites.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { setupBeforeEach, tearDownAfterEach } from '../support';
import { changePageTitle, addBlock } from '../helpers';
import { openSidebarTab } from '../helpers';
import { setInputValue, filtersModal } from '../helpers/utils';
import { setInputValue, filtersModal, save } from '../helpers/utils';
import { tableBlockData } from '../helpers/data';

describe('Sites in DiscodataTableBlock', () => {
Expand All @@ -10,42 +10,48 @@ describe('Sites in DiscodataTableBlock', () => {

it('Add Blocks', () => {
changePageTitle('Sites in DiscodataTableBlock');
cy.get('.block.inner.text').click();
addBlock('Eprtr Blocks', 'eprtr_blocks', 'eprtr_filters_block');
addBlock(
'Discodata components',
'discodata_components',
'discodata_components_table_block',
);
openSidebarTab('Block');
setInputValue(
'textarea#field-field-widget-importExport',
tableBlockData,
'textarea',
);
cy.get('textarea#field-field-widget-importExport').type(' ');
cy.get('#toolbar-save').click();
cy.wait(2000);
filtersModal.open();
filtersModal.addFilter('#countries_0', 'Romania');
filtersModal.addFilter('#reporting_years_0', '2018');
filtersModal.triggerSearch();
cy.get('.browse-table .ui.pagination.menu a:nth-last-child(2)').should(
'have.text',
'42',
);
cy.wait(2000);
filtersModal.search('Site: 101AR0000.SITE');
cy.get('.browse-table .ui.pagination.menu a:nth-last-child(2)').should(
'have.text',
'1',
);
cy.wait(2000);
cy.get(
'#page-document > div.browse-table > table > tbody > tr:nth-last-child(2) > td:nth-child(1) > p',
).should('have.text', 'Site: 101AR0000.SITE');
filtersModal.open();
filtersModal.triggerClear();
filtersModal.triggerSearch();
save('/cypress/my-page');
cy.contains('Sites in DiscodataTableBlock');
// Add block
// addBlock('Text', 'text', 'slate');
// addBlock('Most used', 'most_used', 'image');

// // addBlock('Eprtr Blocks', 'eprtr_blocks', 'eprtr_filters_block');
// addBlock(
// 'Discodata components',
// 'discodata_components',
// 'discodata_components_table_block',
// );
// openSidebarTab('Block');
// setInputValue(
// 'textarea#field-field-widget-importExport',
// tableBlockData,
// 'textarea',
// );
// cy.get('textarea#field-field-widget-importExport').type(' ');
// cy.get('#toolbar-save').click();
// cy.wait(2000);
// filtersModal.open();
// filtersModal.addFilter('#countries_0', 'Romania');
// filtersModal.addFilter('#reporting_years_0', '2018');
// filtersModal.triggerSearch();
// cy.get('.browse-table .ui.pagination.menu a:nth-last-child(2)').should(
// 'have.text',
// '42',
// );
// cy.wait(2000);
// filtersModal.search('Site: 101AR0000.SITE');
// cy.get('.browse-table .ui.pagination.menu a:nth-last-child(2)').should(
// 'have.text',
// '1',
// );
// cy.wait(2000);
// cy.get(
// '#page-document > div.browse-table > table > tbody > tr:nth-last-child(2) > td:nth-child(1) > p',
// ).should('have.text', 'Site: 101AR0000.SITE');
// filtersModal.open();
// filtersModal.triggerClear();
// filtersModal.triggerSearch();
// });
});
});

0 comments on commit cbd8d34

Please sign in to comment.