Skip to content

Commit

Permalink
#801: Corrected tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mulholland committed Jun 20, 2018
1 parent efb6e02 commit aad02e6
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/features/find/find.feature
Expand Up @@ -45,7 +45,7 @@ Feature: Find data
| Find | application menu selection | Find->Find |

@impl
Scenario Outline: Find next is available from invoking Find
Scenario Outline: Find submenu item is available from invoking Find
Given Data Curator is open
When "<name1>" is invoked using the "<type>": "<sequence1>"
Then "<name2>" is invoked using the "application menu selection": "<sequence2>"
Expand Down
23 changes: 16 additions & 7 deletions test/features/support/file/new_steps.js
@@ -1,6 +1,6 @@
import { expect, should, assert } from 'chai'
import { Given, When, Then } from 'cucumber'
import {defaultTabData} from '../page-objects/io.js'
import {defaultTabData, isDataEqualToDefaultData} from '../page-objects/io.js'
import _ from 'lodash'

When(/^Data Curator is open$/, async function () {
Expand All @@ -15,16 +15,25 @@ Given(/^the active table has data: "(.+)"$/, async function (data) {
const parentSelector = '.tab-pane.active .editor.handsontable'
const elementsSelector = '.ht_master table tr:first-of-type td'
let self = this
let actualFirstDataRow
await this.app.client.waitUntil(async function () {
let actualFirstDataRow = await self.app.client.element(parentSelector)
actualFirstDataRow = await self.app.client.element(parentSelector)
.elements(elementsSelector)
.getText()
const difference = _.difference(actualFirstDataRow, ['', '', ''])
if (_.difference(data, defaultTabData).length === 0) {
return difference.length === 0
}
return difference.length !== 0
return _.difference(data[0], actualFirstDataRow).length === 0
}, 5000)
const difference = _.difference(actualFirstDataRow, defaultTabData[0])

if (isDataEqualToDefaultData(data)) {
expect(difference.length).to.equal(0)
} else {
// the first row (as headers will be toggled) matches default data first row
if (difference.length === 0) {
expect(data.length).to.not.equal(defaultTabData.length)
} else {
expect(difference.length).to.not.equal(0)
}
}
})

Then(/^1 window should be displayed/, function () {
Expand Down
2 changes: 1 addition & 1 deletion test/features/support/other/navigation_steps.js
Expand Up @@ -21,6 +21,6 @@ Then(/^the column that the cursor is in should be displayed/, async function ()
return responses
})

When(/^(?:the )?"([\w ]+?)" (?:button |panel ) is (?:clicked|invoked)$/, async function (label) {
When(/^(?:the )?"([\w ]+?)" (?:button|panel) is (?:clicked|invoked)$/, async function (label) {
await applyFnToIdOrClassSelectorFromLabel(this.app, 'click', label, this.pageTimeout)
})
8 changes: 8 additions & 0 deletions test/features/support/page-objects/io.js
Expand Up @@ -18,6 +18,14 @@ export function getFileData(filePath) {

const defaultTabData = [['', '', '']]

export function isDataEqualToDefaultData(data) {
// NB: arrays might contain mix of quotes
const sanitisedDefault = _.compact(_.flatten(defaultTabData))
const sanitisedData = _.compact(_.flatten(JSON.parse(data)))
// TODO: brittle as check only works while default is no data
return sanitisedDefault.length === 0 && sanitisedDefault.length === sanitisedData.length
}

export {
defaultTabData
}
21 changes: 20 additions & 1 deletion test/features/support/tools/menu_steps.js
Expand Up @@ -6,7 +6,7 @@ import {menu} from '../pageObjects.js'

const _ = require('lodash')

Given(/^"Find" is invoked$/, async function () {
Given(/^"(?:Find|Find Replace)" is invoked$/, async function () {
await menu.invokeActions(this.app, {name: 'Find', type: 'application menu selection', sequence: 'Find->Find'})
})

Expand All @@ -18,11 +18,30 @@ Given(/^"Validate Table" is invoked$/, async function () {
await menu.invokeActions(this.app, {name: 'Validate', type: 'toolbar menu button', sequence: 'Validate'})
})

Given(/^"Table Properties" is invoked$/, async function () {
await menu.invokeActions(this.app, {name: 'Table Properties', type: 'toolbar menu button', sequence: 'Table'})
})

Given(/^"Column Properties" is invoked$/, async function () {
await menu.invokeActions(this.app, {name: 'Column Properties', type: 'toolbar menu button', sequence: 'Column'})
})

Given(/^"Provenance Information" is invoked$/, async function () {
await menu.invokeActions(this.app, {name: 'Provenance Information', type: 'toolbar menu button', sequence: 'Provenance'})
})

Given(/^"Data Package Properties" is invoked$/, async function () {
await menu.invokeActions(this.app, {name: 'Data Package Properties', type: 'toolbar menu button', sequence: 'Package'})
})

// When(/^"About" is invoked$/, async function () {
// await menu.invokeActions(this.app, {name: 'About', type: 'application menu selection', sequence: 'Electron->About'})
// })

When('{string} is invoked using the {string}: {string}', async function (name, type, sequence) {
console.log(`sequence`, sequence)
console.log(`type`, type)
console.log(`name`, name)
await menu.invokeActions(this.app, {name: name, type: type, sequence: sequence})
})

Expand Down
4 changes: 2 additions & 2 deletions test/features/support/world.js
Expand Up @@ -19,8 +19,8 @@ function CustomWorld ({attach, parameters}) {
} else {
console.log('WARNING: app already created...')
}
console.log(`at world`)
console.log(this)
// console.log(`at world`)
// console.log(this)
}

function createApp() {
Expand Down
5 changes: 2 additions & 3 deletions test/features/tools/validate-table.feature
Expand Up @@ -58,8 +58,8 @@ Feature: Validate Table
Examples:
| data | error keys | count | rows | cols |
| [["","",""]] | ["No Columns Properties"] | 1 | [] | [] |
| [["h1","h2","h3"],["","",""]] | ["Blank Row"] | 1 | [2] | [] |
# | [["h1","h2","h3"],["","",""],["a","",""],["","",""]] | ["Blank Row"] | 2 | [1,3] | [0,0] |
| [["h1","h2","h3"],["","",""]] | ["Blank Row"] | 1 | [1] | [] |
| [["h1","h2","h3"],["","",""],["a","",""],["","",""]] | ["Blank Row"] | 2 | [1,3] | [0,0] |

Scenario: Pop out validation error messages
Given Data Curator is open
Expand All @@ -70,7 +70,6 @@ Feature: Validate Table
And a count of the number of errors detected should be displayed
And the error message panel should be closed

@dev
Scenario: Sort validation error messages
Given data in a table has been validated
And errors have been detected and displayed error messages in a table in a separate window
Expand Down

0 comments on commit aad02e6

Please sign in to comment.