feat: add tests for project parsing options (#3676)

* feat: add tests for project parsing options

Signed-off-by: kushthedude <kushthedude@gmail.com>

* fix

Signed-off-by: kushthedude <kushthedude@gmail.com>

* wrap up parsing tests

Signed-off-by: kushthedude <kushthedude@gmail.com>

* fix

Signed-off-by: kushthedude <kushthedude@gmail.com>

* change selector

Signed-off-by: kushthedude <kushthedude@gmail.com>

* fix

Signed-off-by: kushthedude <kushthedude@gmail.com>

Co-authored-by: Florian Giroud <6267288+fgiroud@users.noreply.github.com>
This commit is contained in:
Kush Trivedi 2021-03-12 15:10:36 +05:30 committed by GitHub
parent 6c3a4cfa88
commit b455dc577a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 178 additions and 6 deletions

View File

@ -1,5 +1,97 @@
/**
* Navigate to project preview page and check its contents
*/
function navigateToProjectPreview() {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', '01001');
cy.get('table.data-table tr').eq(1).should('to.contain', 'BUTTER,WITH SALT');
cy.get('table.data-table tr').eq(1).should('to.contain', '15.87');
cy.get('table.data-table tr').eq(1).should('to.contain', '717');
}
describe(__filename, function () {
it('Test project naming', function () {
it('Tests Parsing Options related to column seperation', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
cy.get('[type="radio"]').check('tab');
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr')
.eq(1)
.should('to.contain', '01001","BUTTER,WITH SALT","15.87","717');
cy.get('input[bind="columnSeparatorInput"]').type('{backspace};');
cy.get('[type="radio"]').check('custom');
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr')
.eq(1)
.should('to.contain', '01001","BUTTER,WITH SALT","15.87","717');
cy.get('[type="radio"]').check('comma');
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', '01001');
cy.get('table.data-table tr').eq(1).should('to.contain', '15.87');
cy.get('table.data-table tr').eq(1).should('to.contain', '717');
cy.get('table.data-table tr')
.eq(1)
.should('to.contain', 'BUTTER,WITH SALT');
cy.get('input[bind="columnNamesCheckbox"]').check();
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', 'NDB_No');
cy.get('table.data-table tr').eq(1).should('to.contain', 'Shrt_Desc');
cy.get('table.data-table tr').eq(1).should('to.contain', 'Water');
cy.get('table.data-table tr').eq(1).should('to.contain', 'Energ_Kcal');
});
it('Ensures navigation works from project-preview page', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
cy.navigateTo('Language Settings');
cy.get('tbody').should('to.contain', 'Select preferred language');
cy.navigateTo('Import Project');
cy.get('tbody').should(
'to.contain',
'Locate an existing Refine project file (.tar or .tar.gz)'
);
cy.navigateTo('Create Project');
cy.get('.create-project-ui-panel').should(
'to.contain',
'Configure Parsing Options'
);
});
it('Ensures the working of Start-Over Button', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').should(
'to.contain',
'Configure Parsing Options'
);
cy.get('button[bind="startOverButton"]').click();
cy.get('#or-create-question').should(
'to.contain',
'Create a project by importing data. What kinds of data files can I import?'
);
});
it('Test project renaming', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
@ -11,7 +103,7 @@ describe(__filename, function () {
cy.get('#project-name-button').contains('this is a test');
});
it('Test project tagging', function () {
it('Test project tagging by adding various tags', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
@ -19,10 +111,6 @@ describe(__filename, function () {
const uniqueTagName1 = 'tag1_' + Date.now();
const uniqueTagName2 = 'tag2_' + Date.now();
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).type(uniqueProjectName);
// triger the select input
cy.get('#project-tags-container').click();
// Type and Validate the tag, pressing enter
cy.get('#project-tags-container .select2-input').type(uniqueTagName1);
@ -45,4 +133,79 @@ describe(__filename, function () {
.parent()
.contains(uniqueTagName2);
});
it('Tests ignore-first of parsing options', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', '01001');
cy.get('table.data-table tr')
.eq(1)
.should('to.contain', 'BUTTER,WITH SALT');
cy.get('table.data-table tr').eq(1).should('to.contain', '15.87');
cy.get('table.data-table tr').eq(1).should('to.contain', '717');
cy.get('input[bind="ignoreInput"]').type('{backspace}1');
cy.get('input[bind="ignoreCheckbox"]').check();
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', '01002');
cy.get('table.data-table tr')
.eq(1)
.should('to.contain', 'BUTTER,WHIPPED,WITH SALT');
cy.get('table.data-table tr').eq(1).should('to.contain', '15.87');
cy.get('table.data-table tr').eq(1).should('to.contain', '717');
});
it('Tests parse-next of parsing options', function () {
navigateToProjectPreview();
cy.get('input[bind="headerLinesCheckbox"]').uncheck();
cy.waitForImportUpdate();
cy.get('input[bind="headerLinesInput"]').type('{backspace}0');
cy.get('input[bind="headerLinesCheckbox"]').check();
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', 'NDB_No');
cy.get('table.data-table tr').eq(1).should('to.contain', 'Shrt_Desc');
cy.get('table.data-table tr').eq(1).should('to.contain', 'Water');
cy.get('table.data-table tr').eq(1).should('to.contain', 'Energ_Kcal');
});
it('Tests discard-initial of parsing options', function () {
navigateToProjectPreview();
cy.get('input[bind="skipInput"]').type('{backspace}1');
cy.get('input[bind="skipCheckbox"]').check();
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', '01002');
cy.get('table.data-table tr')
.eq(1)
.should('to.contain', 'BUTTER,WHIPPED,WITH SALT');
cy.get('table.data-table tr').eq(1).should('to.contain', '15.87');
cy.get('table.data-table tr').eq(1).should('to.contain', '717');
});
it('Tests load-at-most of parsing options', function () {
navigateToProjectPreview();
cy.get('input[bind="limitInput"]').type('{backspace}1');
cy.get('input[bind="limitCheckbox"]').check();
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '1.');
cy.get('table.data-table tr').eq(1).should('to.contain', '01001');
cy.get('table.data-table tr')
.eq(1)
.should('to.contain', 'BUTTER,WITH SALT');
cy.get('table.data-table tr').eq(1).should('to.contain', '15.87');
cy.get('table.data-table tr').eq(1).should('to.contain', '717');
});
it('Tests attempt to parse into numbers of parsing options', function () {
navigateToProjectPreview();
cy.get('input[bind="guessCellValueTypesCheckbox"]').check();
cy.waitForImportUpdate();
cy.get('table.data-table tr').eq(1).should('to.contain', '15.87');
cy.get('table.data-table tr').eq(1).should('to.contain', '717');
});
});

View File

@ -208,6 +208,15 @@ Cypress.Commands.add('waitForOrOperation', () => {
cy.get('body[ajax_in_progress="false"]');
});
/**
* Wait for OpenRefine parsing options to be updated
*/
Cypress.Commands.add('waitForImportUpdate', () => {
cy.get('#or-import-updating').should('be.visible');
cy.get('#or-import-updating').should('not.be.visible');
cy.wait(500); // eslint-disable-line
});
/**
* Utility method to fill something into the expression input
* Need to wait for OpenRefine to preview the result, hence the cy.wait