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:
parent
6c3a4cfa88
commit
b455dc577a
@ -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 () {
|
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.visitOpenRefine();
|
||||||
cy.createProjectThroughUserInterface('food.mini.csv');
|
cy.createProjectThroughUserInterface('food.mini.csv');
|
||||||
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
|
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');
|
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.visitOpenRefine();
|
||||||
cy.createProjectThroughUserInterface('food.mini.csv');
|
cy.createProjectThroughUserInterface('food.mini.csv');
|
||||||
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
|
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
|
||||||
@ -19,10 +111,6 @@ describe(__filename, function () {
|
|||||||
const uniqueTagName1 = 'tag1_' + Date.now();
|
const uniqueTagName1 = 'tag1_' + Date.now();
|
||||||
const uniqueTagName2 = 'tag2_' + 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();
|
cy.get('#project-tags-container').click();
|
||||||
// Type and Validate the tag, pressing enter
|
// Type and Validate the tag, pressing enter
|
||||||
cy.get('#project-tags-container .select2-input').type(uniqueTagName1);
|
cy.get('#project-tags-container .select2-input').type(uniqueTagName1);
|
||||||
@ -45,4 +133,79 @@ describe(__filename, function () {
|
|||||||
.parent()
|
.parent()
|
||||||
.contains(uniqueTagName2);
|
.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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -208,6 +208,15 @@ Cypress.Commands.add('waitForOrOperation', () => {
|
|||||||
cy.get('body[ajax_in_progress="false"]');
|
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
|
* Utility method to fill something into the expression input
|
||||||
* Need to wait for OpenRefine to preview the result, hence the cy.wait
|
* Need to wait for OpenRefine to preview the result, hence the cy.wait
|
||||||
|
Loading…
Reference in New Issue
Block a user