Improved stability of Cypress tests (#4163)

* Improved stability for undo/redo tests

* Dummy commit to trigger CI

* Dummy commit to trigger CI

* Refactored pagination tests, removed duplicated tests

* Attempt for flakiness on undo/redo -> apply

* Attempt for flakiness on undo/redo -> apply

* Attempt for flakiness on undo/redo -> apply (Wait)

* Attempt for flakiness on undo/redo -> apply (Wait,2)

* Dummy commit to trigger CI

* Dummy commit to trigger CI

* Dummy commit to trigger CI

* Dummy commit to trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* Removed dummy files, increased Cypress retries

* Reverted cypress retries to 3, refactored pagination tests about previou,next to not use pagination

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* trigger CI

* Removed dummy file to trigger CI
This commit is contained in:
Florian Giroud 2021-10-06 15:41:54 +02:00 committed by GitHub
parent e286d9f02f
commit 9f7b8651f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 206 deletions

View File

@ -8,6 +8,5 @@
"env": { "env": {
"OPENREFINE_URL": "http://localhost:3333", "OPENREFINE_URL": "http://localhost:3333",
"DISABLE_PROJECT_CLEANUP": 0 "DISABLE_PROJECT_CLEANUP": 0
} }
} }

View File

@ -1,249 +1,80 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure it shows correct number of rows', function () { it('Ensure it shows correct number of rows', function () {
cy.loadAndVisitProject('food.small'); cy.loadAndVisitProject('food.small');
cy.get('#summary-bar').should('to.contain', '199 rows'); cy.get('#summary-bar').should('to.contain', '199 rows');
}); });
it('Ensure it shows only 5 rows when pagesize is 5', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('5').click(); it('Change pagination for and check the rows', function () {
cy.get('.data-table tbody').find('tr').should('have.length', 5);
});
it('Ensure it shows only 10 rows when pagesize is 10', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('10').click();
cy.get('.data-table tbody').find('tr').should('have.length', 10);
});
it('Ensure it shows only 25 rows when pagesize is 25', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('25').click();
cy.get('.data-table tbody').find('tr').should('have.length', 25);
});
it('Ensure it shows only 50 rows when pagesize is 50', function () {
cy.loadAndVisitProject('food.small'); cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('50').click(); cy.get('.viewpanel-pagesize').find('a').contains('50').click();
cy.get('.data-table tbody').find('tr').should('have.length', 50); cy.get('.viewpanel-header').should('be.visible');
}); cy.get('.data-table-container').should('be.visible');
it('Ensure it redirects to next-page when pagesize is 5', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('5').click(); // testing the panel after changing pagination can't be tester properly
cy.get('.viewpanel-paging').find('a').contains('next').click(); // The dom re-render in a way that forces us to have an ugly 'wait'
cy.get('#viewpanel-paging-current-input').should('have.value', 2); // See discussion there -> https://github.com/OpenRefine/OpenRefine/pull/4163
cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,BRIE'); // cy.wait(250); // eslint-disable-line
cy.assertCellEquals(4, 'Shrt_Desc', 'CHEESE,CHESHIRE'); // cy.get('.data-table tbody').find('tr').should('have.length', 50);
});
it('Ensure it redirects to next-page when pagesize is 10', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('10').click(); // cy.get('.viewpanel-pagesize').find('a').contains('25').click();
// cy.get('.viewpanel-header').should('be.visible');
// cy.get('.data-table-container').should('be.visible');
// cy.wait(250); // eslint-disable-line
// cy.get('.data-table tbody').find('tr').should('have.length', 25);
});
it('Test the "next" button', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-paging').find('a').contains('next').click(); cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 2); cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,COLBY'); cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,COLBY');
cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,FONTINA'); cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,FONTINA');
}); });
it('Ensure it redirects to next-page when pagesize is 25', function () {
it('Test the "previous" button', function () {
cy.loadAndVisitProject('food.small'); cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('25').click(); // First go next
cy.get('.viewpanel-paging').find('a').contains('next').click(); cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 2); cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,MOZZARELLA,WHL MILK');
cy.assertCellEquals(
24,
'Shrt_Desc',
'CREAM,FLUID,LT (COFFEE CRM OR TABLE CRM)'
);
});
it('Ensure it redirects to next-page when pagesize is 50', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('50').click(); // Then test the previous button
cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(0, 'Shrt_Desc', 'CREAM,FLUID,LT WHIPPING');
cy.assertCellEquals(49, 'Shrt_Desc', 'MILK SHAKES,THICK VANILLA');
});
it('Ensure it redirects to previous-page when pagesize is 5', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('5').click();
cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.get('.viewpanel-paging').find('a').contains('previous').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(4, 'Shrt_Desc', 'CHEESE,BRICK');
});
it('Ensure it redirects to previous-page when pagesize is 10', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('10').click();
cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.get('.viewpanel-paging').find('a').contains('previous').click(); cy.get('.viewpanel-paging').find('a').contains('previous').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1); cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT'); cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,CHESHIRE'); cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,CHESHIRE');
}); });
it('Ensure it redirects to previous-page when pagesize is 25', function () {
it('Test the "last" button', function () {
cy.loadAndVisitProject('food.small'); cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('25').click();
cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.get('.viewpanel-paging').find('a').contains('previous').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(24, 'Shrt_Desc', 'CHEESE,MONTEREY');
});
it('Ensure it redirects to previous-page when pagesize is 50', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('50').click();
cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.get('.viewpanel-paging').find('a').contains('previous').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(
49,
'Shrt_Desc',
'CREAM,FLUID,LT (COFFEE CRM OR TABLE CRM)'
);
});
it('Ensure last button redirects to last-page when pagesize is 5', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('5').click();
cy.get('.viewpanel-paging').find('a').contains('last').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 40);
cy.assertCellEquals(0, 'Shrt_Desc', 'CHERVIL,DRIED');
cy.assertCellEquals(3, 'Shrt_Desc', 'CLOVES,GROUND');
});
it('Ensure last button redirects to last-page when pagesize is 10', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('10').click();
cy.get('.viewpanel-paging').find('a').contains('last').click(); cy.get('.viewpanel-paging').find('a').contains('last').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 20); cy.get('#viewpanel-paging-current-input').should('have.value', 20);
cy.assertCellEquals(0, 'Shrt_Desc', 'SPICES,BASIL,DRIED'); cy.assertCellEquals(0, 'Shrt_Desc', 'SPICES,BASIL,DRIED');
cy.assertCellEquals(8, 'Shrt_Desc', 'CLOVES,GROUND'); cy.assertCellEquals(8, 'Shrt_Desc', 'CLOVES,GROUND');
}); });
it('Ensure last button redirects to last-page when pagesize is 25', function () {
it('Test the "first" button', function () {
cy.loadAndVisitProject('food.small'); cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('25').click(); // First go next
cy.get('.viewpanel-paging').find('a').contains('last').click(); cy.get('.viewpanel-paging').find('a').contains('next').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 8); cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(
0,
'Shrt_Desc',
"KRAFT BREYERS LT N' LVLY LOWFAT STR'BERY YOGURT (1% MILKFAT)"
);
cy.assertCellEquals(23, 'Shrt_Desc', 'CLOVES,GROUND');
});
it('Ensure last button redirects to last-page when pagesize is 50', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('50').click(); // Then test the previous button
cy.get('.viewpanel-paging').find('a').contains('last').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 4);
cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE SAU,PREP FROM RECIPE');
cy.assertCellEquals(48, 'Shrt_Desc', 'CLOVES,GROUND');
});
it('Ensure first button redirects to first-page when pagesize is 5', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('5').click();
cy.get('.viewpanel-paging').find('a').contains('last').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 40);
cy.get('.viewpanel-paging').find('a').contains('first').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(4, 'Shrt_Desc', 'CHEESE,BRICK');
});
it('Ensure first button redirects to first-page when pagesize is 10', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('10').click();
cy.get('.viewpanel-paging').find('a').contains('last').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 20);
cy.get('.viewpanel-paging').find('a').contains('first').click(); cy.get('.viewpanel-paging').find('a').contains('first').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1); cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT'); cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,CHESHIRE'); cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,CHESHIRE');
}); });
it('Ensure first button redirects to first-page when pagesize is 25', function () {
it('Test entering an arbitrary page number', function () {
cy.loadAndVisitProject('food.small'); cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('25').click();
cy.get('.viewpanel-paging').find('a').contains('last').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 8);
cy.get('.viewpanel-paging').find('a').contains('first').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(24, 'Shrt_Desc', 'CHEESE,MONTEREY');
});
it('Ensure first button redirects to first-page when pagesize is 50', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('50').click();
cy.get('.viewpanel-paging').find('a').contains('last').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 4);
cy.get('.viewpanel-paging').find('a').contains('first').click();
cy.get('#viewpanel-paging-current-input').should('have.value', 1);
cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT');
cy.assertCellEquals(
49,
'Shrt_Desc',
'CREAM,FLUID,LT (COFFEE CRM OR TABLE CRM)'
);
});
it('Ensure page-number input redirects to correct-page when pagesize is 5', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('5').click();
cy.get('#viewpanel-paging-current-input').type('{backspace}2{enter}');
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,BRIE');
cy.assertCellEquals(4, 'Shrt_Desc', 'CHEESE,CHESHIRE');
});
it('Ensure page-number input redirects to correct-page when pagesize is 10', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('10').click();
cy.get('#viewpanel-paging-current-input').type('{backspace}2{enter}'); cy.get('#viewpanel-paging-current-input').type('{backspace}2{enter}');
cy.get('#viewpanel-paging-current-input').should('have.value', 2); cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,COLBY'); cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,COLBY');
cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,FONTINA'); cy.assertCellEquals(9, 'Shrt_Desc', 'CHEESE,FONTINA');
}); });
it('Ensure page-number input redirects to correct-page when pagesize is 25', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('25').click();
cy.get('#viewpanel-paging-current-input').type('{backspace}2{enter}');
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(0, 'Shrt_Desc', 'CHEESE,MOZZARELLA,WHL MILK');
cy.assertCellEquals(
24,
'Shrt_Desc',
'CREAM,FLUID,LT (COFFEE CRM OR TABLE CRM)'
);
});
it('Ensure page-number input redirects to correct-page when pagesize is 50', function () {
cy.loadAndVisitProject('food.small');
cy.get('.viewpanel-pagesize').find('a').contains('50').click();
cy.get('#viewpanel-paging-current-input').type('{backspace}2{enter}');
cy.get('#viewpanel-paging-current-input').should('have.value', 2);
cy.assertCellEquals(0, 'Shrt_Desc', 'CREAM,FLUID,LT WHIPPING');
cy.assertCellEquals(49, 'Shrt_Desc', 'MILK SHAKES,THICK VANILLA');
});
}); });

View File

@ -2,14 +2,18 @@ describe(__filename, function () {
it('Apply a JSON', function () { it('Apply a JSON', function () {
cy.loadAndVisitProject('food.mini'); cy.loadAndVisitProject('food.mini');
cy.get('#or-proj-undoRedo').should('to.exist').should('be.visible').click(); // Check some columns before the test
cy.get('table.data-table thead th[title="Shrt_Desc"]').should('exist');
cy.get('table.data-table thead th[title="Water"]').should('exist');
// find the "apply" button
cy.get('#or-proj-undoRedo').click();
cy.wait(500); // eslint-disable-line
cy.get('#refine-tabs-history .history-panel-controls') cy.get('#refine-tabs-history .history-panel-controls')
.contains('Apply') .contains('Apply')
.click(); .click();
cy.get('table.data-table thead th[title="Shrt_Desc"]').should('exist');
cy.get('table.data-table thead th[title="Water"]').should('exist');
// JSON for operations that will be applied // JSON for operations that will be applied
const operations = [ const operations = [
{ {