This commit is contained in:
akshitasingh 2021-02-06 08:16:30 +05:30
parent d0802fa0ce
commit 86d64bfb15
10 changed files with 802 additions and 796 deletions

View File

@ -1,28 +1,28 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure cells are blanked down', function () { it('Ensure cells are blanked down', function () {
const fixture = [ const fixture = [
['a', 'b', 'c'], ['a', 'b', 'c'],
['0a', 'identical', '0c'], ['0a', 'identical', '0c'],
['1a', 'identical', '1c'], ['1a', 'identical', '1c'],
['2a', '2b', '2c'], ['2a', '2b', '2c'],
['3a', 'also identical', '3c'], ['3a', 'also identical', '3c'],
['4a', 'also identical', '4c'], ['4a', 'also identical', '4c'],
['5a', 'also identical', '5c'], ['5a', 'also identical', '5c'],
] ]
cy.loadAndVisitProject(fixture) cy.loadAndVisitProject(fixture)
// click // click
cy.columnActionClick('b', ['Edit cells', 'Blank down']) cy.columnActionClick('b', ['Edit cells', 'Blank down'])
// ensure notification and cell content // ensure notification and cell content
cy.assertNotificationContainingText('Blank down 3 cells') cy.assertNotificationContainingText('Blank down 3 cells')
cy.assertCellEquals(0, 'b', 'identical') // untouched cy.assertCellEquals(0, 'b', 'identical') // untouched
cy.assertCellEquals(1, 'b', null) // blanked cy.assertCellEquals(1, 'b', null) // blanked
cy.assertCellEquals(2, 'b', '2b') // untouched cy.assertCellEquals(2, 'b', '2b') // untouched
cy.assertCellEquals(3, 'b', 'also identical') // untouched cy.assertCellEquals(3, 'b', 'also identical') // untouched
cy.assertCellEquals(4, 'b', null) // blanked cy.assertCellEquals(4, 'b', null) // blanked
cy.assertCellEquals(5, 'b', null) // blanked cy.assertCellEquals(5, 'b', null) // blanked
}) })
}) })

View File

@ -1,23 +1,23 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure multiple whitespaces are collapsed', function () { it('Ensure multiple whitespaces are collapsed', function () {
const fixture = [ const fixture = [
['NDB_No', 'Shrt_Desc'], ['NDB_No', 'Shrt_Desc'],
['01001', 'THIS IS A TEST'], ['01001', 'THIS IS A TEST'],
['01002', 'THIS IS ANOTHER TEST'], ['01002', 'THIS IS ANOTHER TEST'],
['01003', 'THIS IS a THIRD TEST'], ['01003', 'THIS IS a THIRD TEST'],
] ]
cy.loadAndVisitProject(fixture) cy.loadAndVisitProject(fixture)
cy.columnActionClick('Shrt_Desc', [ cy.columnActionClick('Shrt_Desc', [
'Edit cells', 'Edit cells',
'Common transforms', 'Common transforms',
'Collapse consecutive whitespace', 'Collapse consecutive whitespace',
]) ])
// Check notification and cell content // Check notification and cell content
cy.assertNotificationContainingText('Text transform on 2 cells') cy.assertNotificationContainingText('Text transform on 2 cells')
cy.assertCellEquals(0, 'Shrt_Desc', 'THIS IS A TEST') cy.assertCellEquals(0, 'Shrt_Desc', 'THIS IS A TEST')
cy.assertCellEquals(1, 'Shrt_Desc', 'THIS IS ANOTHER TEST') cy.assertCellEquals(1, 'Shrt_Desc', 'THIS IS ANOTHER TEST')
cy.assertCellEquals(2, 'Shrt_Desc', 'THIS IS a THIRD TEST') cy.assertCellEquals(2, 'Shrt_Desc', 'THIS IS a THIRD TEST')
}) })
}) })

View File

@ -1,17 +1,23 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure multiple whitespaces are collapsed', function () { it('Ensure multiple whitespaces are collapsed', function () {
const fixture = [ const fixture = [
['tests'], ['tests'],
['2021-01-31https://www.google.com'], ['2021-01-31https://www.google.com'],
['https://www.wikidata.org/wiki/Property:P670 https://www.wikidata.org/wiki/Property:P669 are now mapped to https://schema.org/streetAddress via https://www.wikidata.org/wiki/Property:P2235'], [
['vhjhjjj https://github.com/OpenRefine/OpenRefine/issues/2519'], 'https://www.wikidata.org/wiki/Property:P670 https://www.wikidata.org/wiki/Property:P669 are now mapped to https://schema.org/streetAddress via https://www.wikidata.org/wiki/Property:P2235',
] ],
cy.loadAndVisitProject(fixture) ['vhjhjjj https://github.com/OpenRefine/OpenRefine/issues/2519'],
]
cy.loadAndVisitProject(fixture)
cy.getCell(0, 'tests').contains('2021-01-31https://www.google.com')
cy.getCell(0,'tests').contains('2021-01-31https://www.google.com') cy.getCell(1, 'tests')
cy.getCell(1,'tests').children('div').children('a').should('have.attr','href'); .children('div')
cy.getCell(2,'tests').children('div').children('a').should('have.attr','href'); .children('a')
.should('have.attr', 'href')
}) cy.getCell(2, 'tests')
.children('div')
.children('a')
.should('have.attr', 'href')
})
}) })

View File

@ -1,28 +1,28 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure only some cells are converted to dates', function () { it('Ensure only some cells are converted to dates', function () {
const fixture = [ const fixture = [
['NDB_No', 'A Date'], ['NDB_No', 'A Date'],
['01001', '2021-01-01'], ['01001', '2021-01-01'],
['01002', '2021-01-01 05:35:15'], ['01002', '2021-01-01 05:35:15'],
['01003', 'THIS SHOULD NOT BE TOUCHED'], ['01003', 'THIS SHOULD NOT BE TOUCHED'],
] ]
cy.loadAndVisitProject(fixture) cy.loadAndVisitProject(fixture)
// Update grid // Update grid
cy.columnActionClick('A Date', [ cy.columnActionClick('A Date', [
'Edit cells', 'Edit cells',
'Common transforms', 'Common transforms',
'To date', 'To date',
]) ])
// Check notification and cell content // Check notification and cell content
cy.assertNotificationContainingText('Text transform on 2 cells') cy.assertNotificationContainingText('Text transform on 2 cells')
cy.assertCellEquals(0, 'A Date', '2021-01-01T00:00:00Z') cy.assertCellEquals(0, 'A Date', '2021-01-01T00:00:00Z')
cy.assertCellEquals(1, 'A Date', '2021-01-01T05:35:15Z') cy.assertCellEquals(1, 'A Date', '2021-01-01T05:35:15Z')
cy.assertCellEquals(2, 'A Date', 'THIS SHOULD NOT BE TOUCHED') cy.assertCellEquals(2, 'A Date', 'THIS SHOULD NOT BE TOUCHED')
// ensure cells are marked as non-string // ensure cells are marked as non-string
cy.assertCellNotString(0, 'A Date') cy.assertCellNotString(0, 'A Date')
cy.assertCellNotString(1, 'A Date') cy.assertCellNotString(1, 'A Date')
}) })
}) })

View File

@ -1,52 +1,52 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure some cells are converted to numbers, and some remains untouched (int)', function () { it('Ensure some cells are converted to numbers, and some remains untouched (int)', function () {
const fixture = [ const fixture = [
['NDB_No', 'A Number'], ['NDB_No', 'A Number'],
['01001', 'This is not a number'], ['01001', 'This is not a number'],
['01002', '42'], ['01002', '42'],
['01003', '43'], ['01003', '43'],
] ]
cy.loadAndVisitProject(fixture) cy.loadAndVisitProject(fixture)
// click // click
cy.columnActionClick('A Number', [ cy.columnActionClick('A Number', [
'Edit cells', 'Edit cells',
'Common transforms', 'Common transforms',
'To number', 'To number',
]) ])
// Ensure notification and cell content // Ensure notification and cell content
cy.assertNotificationContainingText('Text transform on 2 cells') cy.assertNotificationContainingText('Text transform on 2 cells')
cy.assertCellEquals(0, 'A Number', 'This is not a number') cy.assertCellEquals(0, 'A Number', 'This is not a number')
cy.assertCellEquals(1, 'A Number', '42') cy.assertCellEquals(1, 'A Number', '42')
cy.assertCellEquals(2, 'A Number', '43') cy.assertCellEquals(2, 'A Number', '43')
// Ensure a numeric type is applied to the cell // Ensure a numeric type is applied to the cell
cy.assertCellNotString(1, 'A Number') cy.assertCellNotString(1, 'A Number')
cy.assertCellNotString(2, 'A Number') cy.assertCellNotString(2, 'A Number')
}) })
it('Ensure toNumber works with floats', function () { it('Ensure toNumber works with floats', function () {
const fixture = [ const fixture = [
['NDB_No', 'A Number'], ['NDB_No', 'A Number'],
['01001', '42.2'], ['01001', '42.2'],
['01002', '43.5'], ['01002', '43.5'],
['01002', '43.50000'], ['01002', '43.50000'],
['01002', '43.500001'], ['01002', '43.500001'],
] ]
cy.loadAndVisitProject(fixture) cy.loadAndVisitProject(fixture)
// click // click
cy.columnActionClick('A Number', [ cy.columnActionClick('A Number', [
'Edit cells', 'Edit cells',
'Common transforms', 'Common transforms',
'To number', 'To number',
]) ])
// Ensure cell content // Ensure cell content
cy.assertCellEquals(0, 'A Number', '42.2') cy.assertCellEquals(0, 'A Number', '42.2')
cy.assertCellEquals(1, 'A Number', '43.5') cy.assertCellEquals(1, 'A Number', '43.5')
cy.assertCellEquals(2, 'A Number', '43.5') cy.assertCellEquals(2, 'A Number', '43.5')
cy.assertCellEquals(3, 'A Number', '43.500001') cy.assertCellEquals(3, 'A Number', '43.500001')
}) })
}) })

View File

@ -1,21 +1,21 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure multiple leading/tailing whitespaces are trimmed', function () { it('Ensure multiple leading/tailing whitespaces are trimmed', function () {
const fixture = [ const fixture = [
['NDB_No', 'A column'], ['NDB_No', 'A column'],
['01001', 'TEST'], ['01001', 'TEST'],
] ]
cy.loadAndVisitProject(fixture) cy.loadAndVisitProject(fixture)
cy.editCell(0, 'A column', ' TEST ') cy.editCell(0, 'A column', ' TEST ')
cy.columnActionClick('A column', [ cy.columnActionClick('A column', [
'Edit cells', 'Edit cells',
'Common transforms', 'Common transforms',
'Trim leading and trailing whitespace', 'Trim leading and trailing whitespace',
]) ])
// ensure notification and cell content // ensure notification and cell content
cy.assertNotificationContainingText('Text transform on 1 cells') cy.assertNotificationContainingText('Text transform on 1 cells')
cy.assertCellEquals(0, 'A column', 'TEST') cy.assertCellEquals(0, 'A column', 'TEST')
}) })
}) })

View File

@ -1,22 +1,22 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure escaped html entities are unescaped', function () { it('Ensure escaped html entities are unescaped', function () {
const fixture = [ const fixture = [
['NDB_No', 'A column'], ['NDB_No', 'A column'],
['01001', '<img src="test" />'], ['01001', '<img src="test" />'],
['01001', '&lt;img src=&quot;test&quot; /&gt;'], ['01001', '&lt;img src=&quot;test&quot; /&gt;'],
] ]
cy.loadAndVisitProject(fixture, 'ok') cy.loadAndVisitProject(fixture, 'ok')
cy.columnActionClick('A column', [ cy.columnActionClick('A column', [
'Edit cells', 'Edit cells',
'Common transforms', 'Common transforms',
'Unescape HTML entities', 'Unescape HTML entities',
]) ])
// ensure notification and cell content // ensure notification and cell content
cy.assertNotificationContainingText('Text transform on 1 cells') cy.assertNotificationContainingText('Text transform on 1 cells')
cy.assertCellEquals(0, 'A column', '<img src="test" />') cy.assertCellEquals(0, 'A column', '<img src="test" />')
cy.assertCellEquals(1, 'A column', '<img src="test" />') cy.assertCellEquals(1, 'A column', '<img src="test" />')
}) })
}) })

View File

@ -1,27 +1,27 @@
describe(__filename, function () { describe(__filename, function () {
it('Ensure cells are filled down', function () { it('Ensure cells are filled down', function () {
const fixture = [ const fixture = [
['a', 'b', 'c'], ['a', 'b', 'c'],
['0a', '0b', '0c'], ['0a', '0b', '0c'],
['1a', null, '1c'], ['1a', null, '1c'],
['2a', '2b', '2c'], ['2a', '2b', '2c'],
['3a', null, '3c'], ['3a', null, '3c'],
['4a', null, '4c'], ['4a', null, '4c'],
['5a', '5b', '5c'], ['5a', '5b', '5c'],
] ]
cy.loadAndVisitProject(fixture) cy.loadAndVisitProject(fixture)
// click // click
cy.columnActionClick('b', ['Edit cells', 'Fill down']) cy.columnActionClick('b', ['Edit cells', 'Fill down'])
// ensure notification and cell content // ensure notification and cell content
cy.assertNotificationContainingText('Fill down 3 cells in column b') cy.assertNotificationContainingText('Fill down 3 cells in column b')
cy.assertCellEquals(0, 'b', '0b') // untouched cy.assertCellEquals(0, 'b', '0b') // untouched
cy.assertCellEquals(1, 'b', '0b') // filled cy.assertCellEquals(1, 'b', '0b') // filled
cy.assertCellEquals(2, 'b', '2b') // untouched cy.assertCellEquals(2, 'b', '2b') // untouched
cy.assertCellEquals(3, 'b', '2b') // filled cy.assertCellEquals(3, 'b', '2b') // filled
cy.assertCellEquals(4, 'b', '2b') // filled cy.assertCellEquals(4, 'b', '2b') // filled
cy.assertCellEquals(5, 'b', '5b') // untouched cy.assertCellEquals(5, 'b', '5b') // untouched
}) })
}) })

View File

@ -3,415 +3,415 @@
* It's using "text facet" as it is the most simple facet * It's using "text facet" as it is the most simple facet
*/ */
describe(__filename, function () { describe(__filename, function () {
it('Verify facets panel (left-panel) appears with no facets yet', function () { it('Verify facets panel (left-panel) appears with no facets yet', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.get('#refine-tabs-facets') cy.get('#refine-tabs-facets')
.should('exist') .should('exist')
.contains('Using facets and filters') .contains('Using facets and filters')
}) })
it('Test the display of multiple facets', function () { it('Test the display of multiple facets', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('NDB_No', ['Facet', 'Text facet']) cy.columnActionClick('NDB_No', ['Facet', 'Text facet'])
cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet'])
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.getFacetContainer('NDB_No').should('exist') cy.getFacetContainer('NDB_No').should('exist')
cy.getFacetContainer('Shrt_Desc').should('exist') cy.getFacetContainer('Shrt_Desc').should('exist')
cy.getFacetContainer('Water').should('exist') cy.getFacetContainer('Water').should('exist')
}) })
it('Test the Remove All button', function () { it('Test the Remove All button', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('NDB_No', ['Facet', 'Text facet']) cy.columnActionClick('NDB_No', ['Facet', 'Text facet'])
cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet'])
cy.get('#refine-tabs-facets .facets-container .facet-container').should( cy.get('#refine-tabs-facets .facets-container .facet-container').should(
'have.length', 'have.length',
2 2
) )
cy.get('#refine-tabs-facets a').contains('Remove All').click() cy.get('#refine-tabs-facets a').contains('Remove All').click()
cy.get('#refine-tabs-facets .facets-container .facet-container').should( cy.get('#refine-tabs-facets .facets-container .facet-container').should(
'have.length', 'have.length',
0 0
) )
cy.get('#refine-tabs-facets') cy.get('#refine-tabs-facets')
.should('exist') .should('exist')
.contains('Using facets and filters') .contains('Using facets and filters')
}) })
it('Test the Reset All button', function () { it('Test the Reset All button', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.columnActionClick('Energ_Kcal', ['Facet', 'Text facet']) cy.columnActionClick('Energ_Kcal', ['Facet', 'Text facet'])
cy.get('#refine-tabs-facets .facets-container .facet-container').should( cy.get('#refine-tabs-facets .facets-container .facet-container').should(
'have.length', 'have.length',
2 2
) )
// Click to facet 1, select first value // Click to facet 1, select first value
cy.getFacetContainer('Water') cy.getFacetContainer('Water')
.find('.facet-choice:first-child .facet-choice-label') .find('.facet-choice:first-child .facet-choice-label')
.click() .click()
cy.getFacetContainer('Water') cy.getFacetContainer('Water')
.find('.facet-choice:first-child') .find('.facet-choice:first-child')
.should('have.class', 'facet-choice-selected') .should('have.class', 'facet-choice-selected')
// Click to facet 2, select first value // Click to facet 2, select first value
cy.getFacetContainer('Energ_Kcal') cy.getFacetContainer('Energ_Kcal')
.find('.facet-choice:first-child .facet-choice-label') .find('.facet-choice:first-child .facet-choice-label')
.click() .click()
cy.getFacetContainer('Energ_Kcal') cy.getFacetContainer('Energ_Kcal')
.find('.facet-choice:first-child') .find('.facet-choice:first-child')
.should('have.class', 'facet-choice-selected') .should('have.class', 'facet-choice-selected')
cy.get('#refine-tabs-facets a').contains('Reset All').click() cy.get('#refine-tabs-facets a').contains('Reset All').click()
// all facets selections should be gone // all facets selections should be gone
cy.getFacetContainer('Water') cy.getFacetContainer('Water')
.find('.facet-choice:first-child') .find('.facet-choice:first-child')
.should('not.have.class', 'facet-choice-selected') .should('not.have.class', 'facet-choice-selected')
cy.getFacetContainer('Energ_Kcal') cy.getFacetContainer('Energ_Kcal')
.find('.facet-choice:first-child') .find('.facet-choice:first-child')
.should('not.have.class', 'facet-choice-selected') .should('not.have.class', 'facet-choice-selected')
}) })
it('Create a simple text facet, check various elements in a Facet', function () { it('Create a simple text facet, check various elements in a Facet', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.get('#refine-tabs-facets').should('exist') cy.get('#refine-tabs-facets').should('exist')
cy.getFacetContainer('Water').should('exist') cy.getFacetContainer('Water').should('exist')
cy.getFacetContainer('Water').contains('182 choices') cy.getFacetContainer('Water').contains('182 choices')
cy.getFacetContainer('Water').contains('Sort by') cy.getFacetContainer('Water').contains('Sort by')
cy.getFacetContainer('Water').contains('Cluster') cy.getFacetContainer('Water').contains('Cluster')
}) })
it('Delete a facet', function () { it('Delete a facet', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.getFacetContainer('Water').find('a.facet-title-remove').click() cy.getFacetContainer('Water').find('a.facet-title-remove').click()
cy.getFacetContainer('Water').should('not.exist') cy.getFacetContainer('Water').should('not.exist')
}) })
it('Test editing a facet ("change")', function () { it('Test editing a facet ("change")', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('NDB_No', ['Facet', 'Text facet']) cy.columnActionClick('NDB_No', ['Facet', 'Text facet'])
cy.getFacetContainer('NDB_No') cy.getFacetContainer('NDB_No')
.find('a[bind="changeButton"]') .find('a[bind="changeButton"]')
.contains('change') .contains('change')
cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click() cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click()
cy.get('.dialog-container .dialog-header').contains( cy.get('.dialog-container .dialog-header').contains(
`Edit Facet's Expression` `Edit Facet's Expression`
) )
}) })
it('Test editing a facet / Preview', function () { it('Test editing a facet / Preview', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('NDB_No', ['Facet', 'Text facet']) cy.columnActionClick('NDB_No', ['Facet', 'Text facet'])
// test the tab // test the tab
cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click() cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click()
cy.get('.dialog-container #expression-preview-tabs-preview').should( cy.get('.dialog-container #expression-preview-tabs-preview').should(
'be.visible' 'be.visible'
) )
// test the content // test the content
cy.get('.dialog-container #expression-preview-tabs-preview').contains( cy.get('.dialog-container #expression-preview-tabs-preview').contains(
'row' 'row'
) )
}) })
it('Test editing a facet / History', function () { it('Test editing a facet / History', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('NDB_No', ['Facet', 'Text facet']) cy.columnActionClick('NDB_No', ['Facet', 'Text facet'])
cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click() cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click()
// test the tab // test the tab
cy.get('.dialog-container a[bind="or_dialog_history"]').click() cy.get('.dialog-container a[bind="or_dialog_history"]').click()
cy.get('.dialog-container #expression-preview-tabs-history').should( cy.get('.dialog-container #expression-preview-tabs-history').should(
'be.visible' 'be.visible'
) )
// test the content // test the content
cy.get('.dialog-container #expression-preview-tabs-history').contains( cy.get('.dialog-container #expression-preview-tabs-history').contains(
'Expression' 'Expression'
) )
}) })
it('Test editing a facet / Starred', function () { it('Test editing a facet / Starred', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('NDB_No', ['Facet', 'Text facet']) cy.columnActionClick('NDB_No', ['Facet', 'Text facet'])
cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click() cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click()
// test the tab // test the tab
cy.get('.dialog-container a[bind="or_dialog_starred"]').click() cy.get('.dialog-container a[bind="or_dialog_starred"]').click()
cy.get('.dialog-container #expression-preview-tabs-starred').should( cy.get('.dialog-container #expression-preview-tabs-starred').should(
'be.visible' 'be.visible'
) )
// test the content // test the content
cy.get('.dialog-container #expression-preview-tabs-starred').contains( cy.get('.dialog-container #expression-preview-tabs-starred').contains(
'Expression' 'Expression'
) )
}) })
it('Test editing a facet / Help', function () { it('Test editing a facet / Help', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('NDB_No', ['Facet', 'Text facet']) cy.columnActionClick('NDB_No', ['Facet', 'Text facet'])
cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click() cy.getFacetContainer('NDB_No').find('a[bind="changeButton"]').click()
// test the tab // test the tab
cy.get('.dialog-container a[bind="or_dialog_help"]').click() cy.get('.dialog-container a[bind="or_dialog_help"]').click()
cy.get('.dialog-container #expression-preview-tabs-help').should( cy.get('.dialog-container #expression-preview-tabs-help').should(
'be.visible' 'be.visible'
) )
// test the content // test the content
cy.get('.dialog-container #expression-preview-tabs-help').contains( cy.get('.dialog-container #expression-preview-tabs-help').contains(
'Variables' 'Variables'
) )
}) })
it('Create a facet, Sorts, by count', function () { it('Create a facet, Sorts, by count', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.get('#refine-tabs-facets').should('exist') cy.get('#refine-tabs-facets').should('exist')
// Ensure sort should be by name by default // Ensure sort should be by name by default
cy.getFacetContainer('Water').contains('0.24') cy.getFacetContainer('Water').contains('0.24')
cy.getFacetContainer('Water').find('a[bind="sortByCountLink"]').click() cy.getFacetContainer('Water').find('a[bind="sortByCountLink"]').click()
// Sort should now be by count // Sort should now be by count
cy.getFacetContainer('Water').contains('15.87') cy.getFacetContainer('Water').contains('15.87')
}) })
it('Create a facet, Sorts multiple', function () { it('Create a facet, Sorts multiple', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.get('#refine-tabs-facets').should('exist') cy.get('#refine-tabs-facets').should('exist')
// Sort should be by name by default // Sort should be by name by default
cy.getFacetContainer('Water').contains('0.24') cy.getFacetContainer('Water').contains('0.24')
cy.getFacetContainer('Water').find('a[bind="sortByCountLink"]').click() cy.getFacetContainer('Water').find('a[bind="sortByCountLink"]').click()
// Sort should now be by count // Sort should now be by count
cy.getFacetContainer('Water').contains('15.87') cy.getFacetContainer('Water').contains('15.87')
cy.getFacetContainer('Water').find('a[bind="sortByNameLink"]').click() cy.getFacetContainer('Water').find('a[bind="sortByNameLink"]').click()
cy.getFacetContainer('Water').contains('0.24') cy.getFacetContainer('Water').contains('0.24')
}) })
it('Test include/exlude filters', function () { it('Test include/exlude filters', function () {
// Because the toggle of include/exclude buttons is unstable // Because the toggle of include/exclude buttons is unstable
// we force include/exclude to be visible // we force include/exclude to be visible
// This test focus solely on ensuring that filters are effectively applied to the grid // This test focus solely on ensuring that filters are effectively applied to the grid
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet'])
// force visibility // force visibility
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.invoke('attr', 'style', 'visibility:visible') .invoke('attr', 'style', 'visibility:visible')
// include ALLSPICE,GROUND, and check rows // include ALLSPICE,GROUND, and check rows
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice') .find('.facet-choice')
.contains('ALLSPICE,GROUND') .contains('ALLSPICE,GROUND')
.parent() .parent()
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.click() .click()
cy.getCell(0, 'Shrt_Desc').should('to.contain', 'ALLSPICE,GROUND') cy.getCell(0, 'Shrt_Desc').should('to.contain', 'ALLSPICE,GROUND')
cy.get('#tool-panel').contains('1 matching rows') cy.get('#tool-panel').contains('1 matching rows')
// OR is refreshing facets, need to show the toggle again // OR is refreshing facets, need to show the toggle again
cy.waitForOrOperation() cy.waitForOrOperation()
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.invoke('attr', 'style', 'visibility:visible') .invoke('attr', 'style', 'visibility:visible')
// include CELERY SEED, and check rows // include CELERY SEED, and check rows
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice') .find('.facet-choice')
.contains('ANISE SEED') .contains('ANISE SEED')
.parent() .parent()
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.click() .click()
cy.getCell(1, 'Shrt_Desc').should('to.contain', 'ANISE SEED') cy.getCell(1, 'Shrt_Desc').should('to.contain', 'ANISE SEED')
cy.get('#tool-panel').contains('2 matching rows') cy.get('#tool-panel').contains('2 matching rows')
// OR ir refreshing facets, need to show the toggle again // OR ir refreshing facets, need to show the toggle again
cy.waitForOrOperation() cy.waitForOrOperation()
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.invoke('attr', 'style', 'visibility:visible') .invoke('attr', 'style', 'visibility:visible')
// include a third one, CELERY SEED, and check rows // include a third one, CELERY SEED, and check rows
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice') .find('.facet-choice')
.contains('BUTTER OIL,ANHYDROUS') .contains('BUTTER OIL,ANHYDROUS')
.parent() .parent()
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.click() .click()
cy.getCell(0, 'Shrt_Desc').should('to.contain', 'BUTTER OIL,ANHYDROUS') // this row is added first cy.getCell(0, 'Shrt_Desc').should('to.contain', 'BUTTER OIL,ANHYDROUS') // this row is added first
cy.get('#tool-panel').contains('3 matching rows') cy.get('#tool-panel').contains('3 matching rows')
// OR ir refreshing facets, need to show the toggle again // OR ir refreshing facets, need to show the toggle again
cy.waitForOrOperation() cy.waitForOrOperation()
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.invoke('attr', 'style', 'visibility:visible') .invoke('attr', 'style', 'visibility:visible')
// EXCLUDE ALLSPICE,GROUND // EXCLUDE ALLSPICE,GROUND
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice') .find('.facet-choice')
.contains('ALLSPICE,GROUND') .contains('ALLSPICE,GROUND')
.parent() .parent()
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.click() .click()
cy.get('#tool-panel').contains('2 matching rows') cy.get('#tool-panel').contains('2 matching rows')
}) })
it('Test include/exclude, invert', function () { it('Test include/exclude, invert', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet'])
// do a basic facetting, expect 1 row // do a basic facetting, expect 1 row
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.invoke('attr', 'style', 'visibility:visible') .invoke('attr', 'style', 'visibility:visible')
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice') .find('.facet-choice')
.contains('ALLSPICE,GROUND') .contains('ALLSPICE,GROUND')
.parent() .parent()
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.click() .click()
cy.getCell(0, 'Shrt_Desc').should('to.contain', 'ALLSPICE,GROUND') cy.getCell(0, 'Shrt_Desc').should('to.contain', 'ALLSPICE,GROUND')
cy.get('#tool-panel').contains('1 matching rows') cy.get('#tool-panel').contains('1 matching rows')
// now invert, expect 198 rows // now invert, expect 198 rows
cy.getFacetContainer('Shrt_Desc').find('a[bind="invertButton"]').click() cy.getFacetContainer('Shrt_Desc').find('a[bind="invertButton"]').click()
cy.waitForOrOperation() cy.waitForOrOperation()
cy.get('#tool-panel').contains('198 matching rows') cy.get('#tool-panel').contains('198 matching rows')
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('a[bind="invertButton"]') .find('a[bind="invertButton"]')
.should('have.class', 'facet-mode-inverted') .should('have.class', 'facet-mode-inverted')
// remove invert // remove invert
cy.getFacetContainer('Shrt_Desc').find('a[bind="invertButton"]').click() cy.getFacetContainer('Shrt_Desc').find('a[bind="invertButton"]').click()
cy.waitForOrOperation() cy.waitForOrOperation()
cy.get('#tool-panel').contains('1 matching rows') cy.get('#tool-panel').contains('1 matching rows')
}) })
it('Test facet reset', function () { it('Test facet reset', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet'])
// do a basic facetting, expect 1 row // do a basic facetting, expect 1 row
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.invoke('attr', 'style', 'visibility:visible') .invoke('attr', 'style', 'visibility:visible')
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice') .find('.facet-choice')
.contains('ALLSPICE,GROUND') .contains('ALLSPICE,GROUND')
.parent() .parent()
.find('.facet-choice-toggle') .find('.facet-choice-toggle')
.click() .click()
cy.get('#tool-panel').contains('1 matching rows') cy.get('#tool-panel').contains('1 matching rows')
// now reset, expect 199 // now reset, expect 199
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('a[bind="resetButton"]') .find('a[bind="resetButton"]')
.contains('reset') .contains('reset')
.click() .click()
cy.get('#tool-panel').contains('199 rows') cy.get('#tool-panel').contains('199 rows')
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('a[bind="resetButton"]') .find('a[bind="resetButton"]')
.should('not.be.visible') .should('not.be.visible')
}) })
/** /**
* This test ensure the refresh button behavior when editing a facet * This test ensure the refresh button behavior when editing a facet
* The grid is updated with a duplicate on "BUTTER,WITH SALT" * The grid is updated with a duplicate on "BUTTER,WITH SALT"
* Then we ensure the number of occurences is respected * Then we ensure the number of occurences is respected
*/ */
it('Test refresh reset', function () { it('Test refresh reset', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet'])
cy.get('.facet-choice').should('have.length', 2) cy.get('.facet-choice').should('have.length', 2)
cy.get('.facet-choice:nth-child(1)').contains( cy.get('.facet-choice:nth-child(1)').contains(
'BUTTER,WHIPPED,WITH SALT' 'BUTTER,WHIPPED,WITH SALT'
) )
cy.get('.facet-choice:nth-child(2)').contains('BUTTER,WITH SALT') cy.get('.facet-choice:nth-child(2)').contains('BUTTER,WITH SALT')
cy.editCell(1, 'Shrt_Desc', 'BUTTER,WITH SALT') cy.editCell(1, 'Shrt_Desc', 'BUTTER,WITH SALT')
cy.get('#refine-tabs-facets .browsing-panel-controls-refresh') cy.get('#refine-tabs-facets .browsing-panel-controls-refresh')
.contains('Refresh') .contains('Refresh')
.click() .click()
cy.get('.facet-choice').should('have.length', 1) cy.get('.facet-choice').should('have.length', 1)
cy.get('.facet-choice:first-child').contains('BUTTER,WITH SALT') cy.get('.facet-choice:first-child').contains('BUTTER,WITH SALT')
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-choice-count') .find('.facet-choice-count')
.contains(2) .contains(2)
}) })
it('Test facet by choice count', function () { it('Test facet by choice count', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Text facet'])
cy.getFacetContainer('Shrt_Desc') cy.getFacetContainer('Shrt_Desc')
.find('.facet-body-controls') .find('.facet-body-controls')
.contains('Facet by choice counts') .contains('Facet by choice counts')
.click() .click()
cy.get(`#refine-tabs-facets .facets-container .facet-container#facet-1`) cy.get(`#refine-tabs-facets .facets-container .facet-container#facet-1`)
.should('exist') .should('exist')
.contains('Shrt_Desc') .contains('Shrt_Desc')
}) })
it('Test the mass edit from a Facet', function () { it('Test the mass edit from a Facet', function () {
cy.loadAndVisitProject('food.small') cy.loadAndVisitProject('food.small')
cy.columnActionClick('Water', ['Facet', 'Text facet']) cy.columnActionClick('Water', ['Facet', 'Text facet'])
cy.getFacetContainer('Water').within(() => { cy.getFacetContainer('Water').within(() => {
cy.get('.facet-choice') cy.get('.facet-choice')
.contains('15.87') .contains('15.87')
.parent() .parent()
.trigger('mouseover') .trigger('mouseover')
.find('a.facet-choice-edit') .find('a.facet-choice-edit')
.contains('edit') .contains('edit')
.should('be.visible') .should('be.visible')
.click() .click()
}) })
// mass edit all cells that have Water = 15.87 // mass edit all cells that have Water = 15.87
cy.get('.data-table-cell-editor textarea').type(50) cy.get('.data-table-cell-editor textarea').type(50)
cy.get('.data-table-cell-editor button').contains('Apply').click() cy.get('.data-table-cell-editor button').contains('Apply').click()
// ensure rows has been modified // ensure rows has been modified
cy.getCell(0, 'Water').should('to.contain', 50) cy.getCell(0, 'Water').should('to.contain', 50)
cy.getCell(1, 'Water').should('to.contain', 50) cy.getCell(1, 'Water').should('to.contain', 50)
// ensure modification is made only to the rows that had 15.87, not the others // ensure modification is made only to the rows that had 15.87, not the others
cy.getCell(2, 'Water').should('to.contain', 0.24) cy.getCell(2, 'Water').should('to.contain', 0.24)
}) })
// // This test is unstable, mouseover behavior is unpredictable // // This test is unstable, mouseover behavior is unpredictable
// // This might be because the element is detached from the DOM in the middle // // This might be because the element is detached from the DOM in the middle
// // it('Test include/exlude toggle', function () { // // it('Test include/exlude toggle', function () {
// // cy.loadAndVisitProject('food.small'); // // cy.loadAndVisitProject('food.small');
// // cy.columnActionClick('NDB_No', ['Facet', 'Text facet']); // // cy.columnActionClick('NDB_No', ['Facet', 'Text facet']);
// // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"]').trigger('mouseover'); // // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"]').trigger('mouseover');
// // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').contains('include').should('be.visible'); // // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').contains('include').should('be.visible');
// // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').click(); // // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').click();
// // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').contains('exclude'); // // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').contains('exclude');
// // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').click(); // // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').click();
// // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').contains('include'); // // cy.getFacetContainer('NDB_No').find('.facet-choice[choiceindex="0"] a.facet-choice-toggle').contains('include');
// // }); // // });
// it('Test collapsing facet panels', function () { // it('Test collapsing facet panels', function () {
// The following test does not work // The following test does not work
// Because the facet panels uses soem weird CSS with overflow:hidden, Cypress can not detect it // Because the facet panels uses soem weird CSS with overflow:hidden, Cypress can not detect it
// //// # cy.loadAndVisitProject('food.small'); // //// # cy.loadAndVisitProject('food.small');
// //// # cy.columnActionClick('NDB_No', ['Facet', 'Text facet']); // //// # cy.columnActionClick('NDB_No', ['Facet', 'Text facet']);
// //// # ensure facet inner panel is visible // //// # ensure facet inner panel is visible
// //// # cy.get('#refine-tabs-facets .facets-container li:nth-child(1) .facet-body-inner').should('be.visible'); // //// # cy.get('#refine-tabs-facets .facets-container li:nth-child(1) .facet-body-inner').should('be.visible');
// //// #collapse the panel // //// #collapse the panel
// //// # cy.get('#refine-tabs-facets .facets-container li:nth-child(1) a[bind="minimizeButton"]').click(); // //// # cy.get('#refine-tabs-facets .facets-container li:nth-child(1) a[bind="minimizeButton"]').click();
// //// // ////
}) })

View File

@ -2,7 +2,7 @@
* Utility method to load an expression panel, used by almost all the tests * Utility method to load an expression panel, used by almost all the tests
*/ */
function loadExpressionPanel() { function loadExpressionPanel() {
cy.columnActionClick('Shrt_Desc', ['Facet', 'Custom text facet']) cy.columnActionClick('Shrt_Desc', ['Facet', 'Custom text facet'])
} }
/** /**
@ -10,304 +10,304 @@ function loadExpressionPanel() {
* 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
*/ */
function typeExpression(expression) { function typeExpression(expression) {
cy.get('textarea.expression-preview-code').type(expression) cy.get('textarea.expression-preview-code').type(expression)
cy.wait(250) cy.wait(250)
} }
/** /**
* Generate a unique GREL expression to be used for testing * Generate a unique GREL expression to be used for testing
*/ */
function generateUniqueExpression() { function generateUniqueExpression() {
return `value+${Date.now()}` return `value+${Date.now()}`
} }
describe(__filename, function () { describe(__filename, function () {
it('Test the layout of the expression panel', function () { it('Test the layout of the expression panel', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('.dialog-container').within(() => { cy.get('.dialog-container').within(() => {
cy.get('td[bind="or_dialog_expr"]').contains('Expression') cy.get('td[bind="or_dialog_expr"]').contains('Expression')
cy.get( cy.get(
'select[bind="expressionPreviewLanguageSelect"] option' 'select[bind="expressionPreviewLanguageSelect"] option'
).should('have.length', 3) ).should('have.length', 3)
cy.get('textarea.expression-preview-code').should('exist') cy.get('textarea.expression-preview-code').should('exist')
cy.get('.dialog-footer button:nth-child(1)').should( cy.get('.dialog-footer button:nth-child(1)').should(
'to.contain', 'to.contain',
'OK' 'OK'
) )
cy.get('.dialog-footer button:nth-child(2)').should( cy.get('.dialog-footer button:nth-child(2)').should(
'to.contain', 'to.contain',
'Cancel' 'Cancel'
) )
}) })
}) })
it('Test a valid Grel expression', function () { it('Test a valid Grel expression', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
typeExpression('value.toLowercase()') typeExpression('value.toLowercase()')
cy.get('.expression-preview-parsing-status').contains( cy.get('.expression-preview-parsing-status').contains(
'No syntax error.' 'No syntax error.'
) )
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(2) td:last-child' '.expression-preview-table-wrapper tr:nth-child(2) td:last-child'
).should('to.contain', 'butter,with salt') ).should('to.contain', 'butter,with salt')
}) })
it('Test a valid Python expression', function () { it('Test a valid Python expression', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('select[bind="expressionPreviewLanguageSelect"]').select( cy.get('select[bind="expressionPreviewLanguageSelect"]').select(
'jython' 'jython'
) )
typeExpression('return value.lower()') typeExpression('return value.lower()')
cy.get('.expression-preview-parsing-status').contains( cy.get('.expression-preview-parsing-status').contains(
'No syntax error.' 'No syntax error.'
) )
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(2) td:last-child' '.expression-preview-table-wrapper tr:nth-child(2) td:last-child'
).should('to.contain', 'butter,with salt') ).should('to.contain', 'butter,with salt')
}) })
it('Test a valid Clojure expression', function () { it('Test a valid Clojure expression', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('select[bind="expressionPreviewLanguageSelect"]').select( cy.get('select[bind="expressionPreviewLanguageSelect"]').select(
'clojure' 'clojure'
) )
typeExpression('(.. value (toLowerCase) )') typeExpression('(.. value (toLowerCase) )')
cy.get('.expression-preview-parsing-status').contains( cy.get('.expression-preview-parsing-status').contains(
'No syntax error.' 'No syntax error.'
) )
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(2) td:last-child' '.expression-preview-table-wrapper tr:nth-child(2) td:last-child'
).should('to.contain', 'butter,with salt') ).should('to.contain', 'butter,with salt')
}) })
it('Test a Grel syntax error', function () { it('Test a Grel syntax error', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
typeExpression('()') typeExpression('()')
cy.get('.expression-preview-parsing-status').contains('Parsing error') cy.get('.expression-preview-parsing-status').contains('Parsing error')
}) })
it('Test a Python syntax error', function () { it('Test a Python syntax error', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('select[bind="expressionPreviewLanguageSelect"]').select( cy.get('select[bind="expressionPreviewLanguageSelect"]').select(
'jython' 'jython'
) )
typeExpression('(;)') typeExpression('(;)')
cy.get('.expression-preview-parsing-status').contains('Internal error') cy.get('.expression-preview-parsing-status').contains('Internal error')
}) })
it('Test a Clojure syntax error', function () { it('Test a Clojure syntax error', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('select[bind="expressionPreviewLanguageSelect"]').select( cy.get('select[bind="expressionPreviewLanguageSelect"]').select(
'clojure' 'clojure'
) )
typeExpression('(;)') typeExpression('(;)')
cy.get('.expression-preview-parsing-status').contains( cy.get('.expression-preview-parsing-status').contains(
'Syntax error reading source' 'Syntax error reading source'
) )
}) })
it('Test a Grel language error', function () { it('Test a Grel language error', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
typeExpression('value.thisGrelFunctionDoesNotExists()') typeExpression('value.thisGrelFunctionDoesNotExists()')
cy.get('.expression-preview-parsing-status').contains( cy.get('.expression-preview-parsing-status').contains(
'Unknown function thisGrelFunctionDoesNotExists' 'Unknown function thisGrelFunctionDoesNotExists'
) )
}) })
it('Test a Python language error', function () { it('Test a Python language error', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('select[bind="expressionPreviewLanguageSelect"]').select( cy.get('select[bind="expressionPreviewLanguageSelect"]').select(
'jython' 'jython'
) )
typeExpression('return value.thisPythonFunctionDoesNotExists()') typeExpression('return value.thisPythonFunctionDoesNotExists()')
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(2) td:last-child' '.expression-preview-table-wrapper tr:nth-child(2) td:last-child'
).should('to.contain', 'Error: Traceback') ).should('to.contain', 'Error: Traceback')
}) })
it('Test a Clojure language error', function () { it('Test a Clojure language error', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('select[bind="expressionPreviewLanguageSelect"]').select( cy.get('select[bind="expressionPreviewLanguageSelect"]').select(
'clojure' 'clojure'
) )
typeExpression('(.. value (thisClojureFunctionDoesNotExists) )') typeExpression('(.. value (thisClojureFunctionDoesNotExists) )')
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(2) td:last-child' '.expression-preview-table-wrapper tr:nth-child(2) td:last-child'
).should('to.contain', 'Error: No matching method') ).should('to.contain', 'Error: No matching method')
}) })
it('Test switching from one langage to another', function () { it('Test switching from one langage to another', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
typeExpression('(.. value (toLowerCase) )') typeExpression('(.. value (toLowerCase) )')
// error is expected, this is clojure language // error is expected, this is clojure language
cy.get('.expression-preview-parsing-status').should( cy.get('.expression-preview-parsing-status').should(
'to.contain', 'to.contain',
'Parsing error' 'Parsing error'
) )
// switching to clojure // switching to clojure
cy.get('select[bind="expressionPreviewLanguageSelect"]').select( cy.get('select[bind="expressionPreviewLanguageSelect"]').select(
'clojure' 'clojure'
) )
cy.get('.expression-preview-parsing-status').should( cy.get('.expression-preview-parsing-status').should(
'not.to.contain', 'not.to.contain',
'Parsing error' 'Parsing error'
) )
}) })
it('Test the preview (GREL)', function () { it('Test the preview (GREL)', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
typeExpression('value.toLowercase()') typeExpression('value.toLowercase()')
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(1) td:last-child' '.expression-preview-table-wrapper tr:nth-child(1) td:last-child'
).should('to.contain', 'value.toLowercase()') ).should('to.contain', 'value.toLowercase()')
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(2) td:last-child' '.expression-preview-table-wrapper tr:nth-child(2) td:last-child'
).should('to.contain', 'butter,with salt') ).should('to.contain', 'butter,with salt')
cy.get( cy.get(
'.expression-preview-table-wrapper tr:nth-child(3) td:last-child' '.expression-preview-table-wrapper tr:nth-child(3) td:last-child'
).should('to.contain', 'butter,whipped,with salt') ).should('to.contain', 'butter,whipped,with salt')
}) })
it('Test the help tab', function () { it('Test the help tab', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('#expression-preview-tabs li').contains('Help').click() cy.get('#expression-preview-tabs li').contains('Help').click()
cy.get('#expression-preview-tabs-help').should('be.visible') cy.get('#expression-preview-tabs-help').should('be.visible')
cy.get('#expression-preview-tabs-help').should( cy.get('#expression-preview-tabs-help').should(
'to.contain', 'to.contain',
`The current cell. It has a few fields: 'value', 'recon' and 'errorMessage'.` `The current cell. It has a few fields: 'value', 'recon' and 'errorMessage'.`
) )
}) })
it('Test the history behavior, ensure expressions are stored', function () { it('Test the history behavior, ensure expressions are stored', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
// Because history is shared across projects, we need to use an expression that is unique // Because history is shared across projects, we need to use an expression that is unique
// Use a first unique expression // Use a first unique expression
const uniqueExpression = generateUniqueExpression() const uniqueExpression = generateUniqueExpression()
loadExpressionPanel() loadExpressionPanel()
typeExpression(uniqueExpression) typeExpression(uniqueExpression)
cy.get('.dialog-footer button').contains('OK').click() cy.get('.dialog-footer button').contains('OK').click()
// ensure the function has been added to the facet // ensure the function has been added to the facet
cy.get('#refine-tabs-facets').contains( cy.get('#refine-tabs-facets').contains(
uniqueExpression.replace('()', '') uniqueExpression.replace('()', '')
) )
// Reload and review history // Reload and review history
// Ensure the previously used expression is listed // Ensure the previously used expression is listed
loadExpressionPanel() loadExpressionPanel()
cy.get('#expression-preview-tabs li').contains('History').click() cy.get('#expression-preview-tabs li').contains('History').click()
cy.get('#expression-preview-tabs-history') cy.get('#expression-preview-tabs-history')
.should('be.visible') .should('be.visible')
.should('to.contain', uniqueExpression) .should('to.contain', uniqueExpression)
}) })
it('Test the reuse of expressions from the history', function () { it('Test the reuse of expressions from the history', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
// Because history is shared across projects, we need to build and use an expression that is unique // Because history is shared across projects, we need to build and use an expression that is unique
const uniqueExpression = generateUniqueExpression() const uniqueExpression = generateUniqueExpression()
loadExpressionPanel() loadExpressionPanel()
typeExpression(uniqueExpression) typeExpression(uniqueExpression)
cy.get('.dialog-footer button').contains('OK').click() cy.get('.dialog-footer button').contains('OK').click()
cy.get('#refine-tabs-facets').contains( cy.get('#refine-tabs-facets').contains(
uniqueExpression.replace('()', '') uniqueExpression.replace('()', '')
) )
// Reload and review history // Reload and review history
// Ensure the previously used expression is there // Ensure the previously used expression is there
// Use it // Use it
loadExpressionPanel() loadExpressionPanel()
cy.get('#expression-preview-tabs li').contains('History').click() cy.get('#expression-preview-tabs li').contains('History').click()
cy.get('#expression-preview-tabs-history tr td') cy.get('#expression-preview-tabs-history tr td')
.contains(uniqueExpression) .contains(uniqueExpression)
.parent() .parent()
.find('a') .find('a')
.contains('Reuse') .contains('Reuse')
.click() .click()
// Expression must be populated in the textarea, after clicking on 'reuse' // Expression must be populated in the textarea, after clicking on 'reuse'
cy.get('textarea.expression-preview-code').should( cy.get('textarea.expression-preview-code').should(
'have.value', 'have.value',
uniqueExpression uniqueExpression
) )
}) })
it('Test the history, star', function () { it('Test the history, star', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
// Cleanup step // Cleanup step
// Because starred expression are shared across projects, see #3499 // Because starred expression are shared across projects, see #3499
// We need to un-star all previously starred expressions // We need to un-star all previously starred expressions
loadExpressionPanel() loadExpressionPanel()
cy.get('#expression-preview-tabs li').contains('Starred').click() cy.get('#expression-preview-tabs li').contains('Starred').click()
cy.get( cy.get(
'#expression-preview-tabs-starred .expression-preview-table-wrapper table' '#expression-preview-tabs-starred .expression-preview-table-wrapper table'
).then(($table) => { ).then(($table) => {
if ($table.find('tr').length > 1) { if ($table.find('tr').length > 1) {
cy.get( cy.get(
'#expression-preview-tabs-starred .expression-preview-table-wrapper table a' '#expression-preview-tabs-starred .expression-preview-table-wrapper table a'
) )
.contains('Remove') .contains('Remove')
.each(($btn) => { .each(($btn) => {
cy.wrap($btn).click() cy.wrap($btn).click()
cy.get('.dialog-container:last-child button') cy.get('.dialog-container:last-child button')
.contains('OK') .contains('OK')
.click() .click()
}) })
} }
}) })
cy.get('.dialog-footer button').contains('Cancel').click() cy.get('.dialog-footer button').contains('Cancel').click()
// End cleanup // End cleanup
// Load an expression // Load an expression
loadExpressionPanel() loadExpressionPanel()
const uniqueExpression = generateUniqueExpression() const uniqueExpression = generateUniqueExpression()
typeExpression(uniqueExpression) typeExpression(uniqueExpression)
cy.get('.dialog-footer button').contains('OK').click() cy.get('.dialog-footer button').contains('OK').click()
// Star the expression // Star the expression
loadExpressionPanel() loadExpressionPanel()
cy.get('#expression-preview-tabs li').contains('History').click() cy.get('#expression-preview-tabs li').contains('History').click()
cy.get('.expression-preview-table-wrapper tr td') cy.get('.expression-preview-table-wrapper tr td')
.contains(uniqueExpression) .contains(uniqueExpression)
.parent() .parent()
.find('a.data-table-star-off') .find('a.data-table-star-off')
.click() .click()
// List starred expressions, en ensure the expression is listed // List starred expressions, en ensure the expression is listed
cy.get('#expression-preview-tabs li').contains('Starred').click() cy.get('#expression-preview-tabs li').contains('Starred').click()
cy.get( cy.get(
'#expression-preview-tabs-starred .expression-preview-table-wrapper table' '#expression-preview-tabs-starred .expression-preview-table-wrapper table'
).contains(uniqueExpression) ).contains(uniqueExpression)
}) })
it('Simple test to ensure the expression panel can be closed with OK', function () { it('Simple test to ensure the expression panel can be closed with OK', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('.dialog-footer button').contains('OK').click() cy.get('.dialog-footer button').contains('OK').click()
cy.get('.dialog-container').should('not.to.exist') cy.get('.dialog-container').should('not.to.exist')
}) })
it('Simple test to ensure the expression panel can be closed with Cancel', function () { it('Simple test to ensure the expression panel can be closed with Cancel', function () {
cy.loadAndVisitProject('food.mini') cy.loadAndVisitProject('food.mini')
loadExpressionPanel() loadExpressionPanel()
cy.get('.dialog-footer button').contains('Cancel').click() cy.get('.dialog-footer button').contains('Cancel').click()
cy.get('.dialog-container').should('not.to.exist') cy.get('.dialog-container').should('not.to.exist')
}) })
}) })