feat: add tests for create project (#3603)

* feat: add tests for create project

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

* add test for URL and increase timeout

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

* restore timeout

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

* restore timeout

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

* fix

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

* amend urls

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

Co-authored-by: Tom Morris <tfmorris@gmail.com>
This commit is contained in:
Kush Trivedi 2021-02-27 01:42:46 +05:30 committed by GitHub
parent 763ef2fd09
commit 3db9453661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 205 additions and 70 deletions

View File

@ -0,0 +1,6 @@
storm instant amount choice pool married
keep fifty memory behavior courage troops
hello mass industry cannot complete practical
add shop surrounded time highway myself
first task fine steep should great
has shot bet became damage share
1 storm instant amount choice pool married
2 keep fifty memory behavior courage troops
3 hello mass industry cannot complete practical
4 add shop surrounded time highway myself
5 first task fine steep should great
6 has shot bet became damage share

View File

@ -1,5 +1,6 @@
describe(__filename, function () {
it('Test the create project page', function () {
it('Test the create project from this computer based on CSV', function () {
// navigate to the create page
cy.visitOpenRefine();
cy.navigateTo('Create Project');
cy.get('#create-project-ui-source-selection-tabs > div')
@ -8,8 +9,7 @@ describe(__filename, function () {
cy.get('.create-project-ui-source-selection-tab-body.selected').contains(
'Locate one or more files on your computer to upload'
);
// load a file
// add file
const csvFile = {
filePath: 'food.mini.csv',
mimeType: 'application/csv',
@ -26,89 +26,168 @@ describe(__filename, function () {
// then ensure we are on the preview page
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
});
it('Test project naming', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).type('this is a test');
// preview and click next
cy.doCreateProjectThroughUserInterface();
cy.get('#project-name-button').contains('this is a test');
});
it('Test project tagging', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
const uniqueProjectName = Date.now();
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);
cy.get('body').type('{enter}');
cy.get('#project-tags-container .select2-input').type(uniqueTagName2);
cy.get('body').type('{enter}');
cy.get('#or-import-parsopt').click();
cy.doCreateProjectThroughUserInterface();
cy.visitOpenRefine();
cy.navigateTo('Open Project');
cy.get('#projects-list')
.contains(uniqueProjectName)
.parent()
.parent()
.contains(uniqueTagName1);
cy.get('#projects-list')
.contains(uniqueProjectName)
.parent()
.parent()
.contains(uniqueTagName2);
});
it('E2E, Creates a simple project, based on a CSV', function () {
it('Test the create project from this computer based on TSV', function () {
// navigate to the create page
cy.visitOpenRefine();
cy.navigateTo('Create Project');
cy.get('#create-project-ui-source-selection-tabs > div')
.contains('This Computer')
.click();
cy.get('.create-project-ui-source-selection-tab-body.selected').contains(
'Locate one or more files on your computer to upload'
);
// add file
const csvFile = {
filePath: 'food.mini.csv',
mimeType: 'application/csv',
const tsvFile = {
filePath: 'shop.mini.tsv',
mimeType: 'text/tab-separated-values',
};
cy.get(
'.create-project-ui-source-selection-tab-body.selected input[type="file"]'
).attachFile(csvFile);
).attachFile(tsvFile);
cy.get(
'.create-project-ui-source-selection-tab-body.selected button.button-primary'
).click();
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).should('have.value', 'shop mini tsv');
// then ensure we are on the preview page
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
// preview and click next
cy.doCreateProjectThroughUserInterface();
});
it('Test the create project from clipboard based on CSV', function () {
// navigate to the create page
cy.visitOpenRefine();
cy.navigateTo('Create Project');
cy.get('#create-project-ui-source-selection-tabs > div')
.contains('Clipboard')
.click();
cy.get('#or-import-clipboard').should(
'to.contain',
'Paste data from clipboard here:'
);
// add file
const csvFile = `Username; Identifier;First name;Last name
booker12;9012;Rachel;Booker
grey07;2070;Laura;Grey
johnson81;4081;Craig;Johnson
jenkins46;9346;Mary;Jenkins
smith79;5079;Jamie;Smith`;
cy.get('textarea').invoke('val', csvFile);
cy.get(
'.default-importing-wizard-header button[bind="nextButton"]'
).click();
cy.get('#create-project-progress-message').contains('Done.');
'.create-project-ui-source-selection-tab-body.selected button.button-primary'
)
.contains('Next »')
.click();
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).should('have.value', 'Clipboard');
// workaround to ensure project is loaded
// cypress does not support window.location = ...
cy.get('h2').contains('HTTP ERROR 404');
cy.location().should((location) => {
expect(location.href).contains(
Cypress.env('OPENREFINE_URL') + '/__/project?'
);
});
// then ensure we are on the preview page
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
cy.location().then((location) => {
const projectId = location.href.split('=').slice(-1)[0];
cy.visitProject(projectId);
});
// preview and click next
cy.doCreateProjectThroughUserInterface();
});
it('Test the create project from clipboard based on TSV', function () {
// navigate to the create page
cy.visitOpenRefine();
cy.navigateTo('Create Project');
cy.get('#create-project-ui-source-selection-tabs > div')
.contains('Clipboard')
.click();
cy.get('#or-import-clipboard').should(
'to.contain',
'Paste data from clipboard here:'
);
// add file
const tsvFile = `Some parameter Other parameter Last parameter
CONST 123456 12.45`;
cy.get('textarea').invoke('val', tsvFile);
cy.get(
'.create-project-ui-source-selection-tab-body.selected button.button-primary'
)
.contains('Next »')
.click();
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).should('have.value', 'Clipboard');
// then ensure we are on the preview page
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
// preview and click next
cy.doCreateProjectThroughUserInterface();
});
it('Test the create project from Web URL based on CSV', function () {
// navigate to the create page
cy.visitOpenRefine();
cy.navigateTo('Create Project');
cy.get('#create-project-ui-source-selection-tabs > div')
.contains('Web Addresses (URLs)')
.click();
cy.get('#or-import-enterurl').should(
'to.contain',
'Enter one or more web addresses (URLs) pointing to data to download:'
);
// add file
const csvURL =
'https://raw.githubusercontent.com/OpenRefine/OpenRefine/master/main/tests/cypress/cypress/fixtures/food.mini.csv';
cy.get('input[bind="urlInput"]').filter(':visible').type(csvURL);
cy.get(
'.create-project-ui-source-selection-tab-body.selected button.button-primary'
)
.contains('Next »')
.click();
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).should('have.value', 'food mini csv');
// then ensure we are on the preview page
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
// preview and click next
cy.doCreateProjectThroughUserInterface();
});
it('Test the create project from Multiple Web URLs based on CSV', function () {
// navigate to the create page
cy.visitOpenRefine();
cy.navigateTo('Create Project');
cy.get('#create-project-ui-source-selection-tabs > div')
.contains('Web Addresses (URLs)')
.click();
cy.get('#or-import-enterurl').should(
'to.contain',
'Enter one or more web addresses (URLs) pointing to data to download:'
);
// add file
const csvURL =
'https://raw.githubusercontent.com/OpenRefine/OpenRefine/master/main/tests/cypress/cypress/fixtures/food.mini.csv';
cy.get('input[bind="urlInput"]').filter(':visible').type(csvURL);
cy.get('button[bind="addButton"]').contains('Add Another URL').click();
cy.get(
'.create-project-ui-source-selection-tab-body.selected button.button-primary'
)
.contains('Next »')
.click();
cy.get('.create-project-ui-panel', { timeout: 7500 })
.contains('Configure Parsing Options »')
.click();
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).should('have.value', 'food mini csv');
// then ensure we are on the preview page
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
// preview and click next
cy.doCreateProjectThroughUserInterface();
});
});

View File

@ -0,0 +1,48 @@
describe(__filename, function () {
it('Test project naming', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
cy.get(
'.default-importing-wizard-header input[bind="projectNameInput"]'
).type('this is a test');
cy.doCreateProjectThroughUserInterface();
cy.get('#project-name-button').contains('this is a test');
});
it('Test project tagging', function () {
cy.visitOpenRefine();
cy.createProjectThroughUserInterface('food.mini.csv');
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
const uniqueProjectName = Date.now();
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);
cy.get('body').type('{enter}');
cy.get('#project-tags-container .select2-input').type(uniqueTagName2);
cy.get('body').type('{enter}');
cy.get('#or-import-parsopt').click();
cy.doCreateProjectThroughUserInterface();
cy.visitOpenRefine();
cy.navigateTo('Open Project');
cy.get('#projects-list')
.contains(uniqueProjectName)
.parent()
.parent()
.contains(uniqueTagName1);
cy.get('#projects-list')
.contains(uniqueProjectName)
.parent()
.parent()
.contains(uniqueTagName2);
});
});

View File

@ -66,7 +66,9 @@ Cypress.Commands.add('createProjectThroughUserInterface', (fixtureFile) => {
});
Cypress.Commands.add('doCreateProjectThroughUserInterface', () => {
cy.get('.default-importing-wizard-header button[bind="nextButton"]').click();
cy.get('.default-importing-wizard-header button[bind="nextButton"]')
.contains('Create Project »')
.click();
cy.get('#create-project-progress-message').contains('Done.');
// workaround to ensure project is loaded