-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
359 additions
and
5 deletions.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
cypress/e2e/bulk-edit/query/bulk-edit-query-search-date-time-string.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import permissions from '../../../support/dictionary/permissions'; | ||
import BulkEditSearchPane from '../../../support/fragments/bulk-edit/bulk-edit-search-pane'; | ||
import TopMenu from '../../../support/fragments/topMenu'; | ||
import Users from '../../../support/fragments/users/users'; | ||
import QueryModal, { | ||
usersFieldValues, | ||
dateTimeOperators, | ||
stringOperators, | ||
} from '../../../support/fragments/bulk-edit/query-modal'; | ||
import DateTools from '../../../support/utils/dateTools'; | ||
|
||
let user; | ||
|
||
describe('Bulk Edit - Query', () => { | ||
before('create test data', () => { | ||
cy.getAdminToken(); | ||
cy.createTempUser([ | ||
permissions.bulkEditUpdateRecords.gui, | ||
permissions.uiUserEdit.gui, | ||
permissions.bulkEditQueryView.gui, | ||
]).then((userProperties) => { | ||
user = userProperties; | ||
cy.getUsers({ limit: 1, query: `username=${user.username}` }).then((users) => { | ||
cy.updateUser({ | ||
...users[0], | ||
expirationDate: DateTools.getTomorrowDay(), | ||
}); | ||
}); | ||
cy.login(user.username, user.password, { | ||
path: TopMenu.bulkEditPath, | ||
waiter: BulkEditSearchPane.waitLoading, | ||
}); | ||
}); | ||
}); | ||
|
||
after('delete test data', () => { | ||
cy.getAdminToken(); | ||
Users.deleteViaApi(user.userId); | ||
}); | ||
|
||
it( | ||
'C436782 Query builder - Search users with expiration date in specified date range and first name, last name containing specific letters ("Date-time" and "String" property types) (firebird)', | ||
{ tags: ['smoke', 'firebird'] }, | ||
() => { | ||
BulkEditSearchPane.openQuerySearch(); | ||
BulkEditSearchPane.checkUsersRadio(); | ||
BulkEditSearchPane.clickBuildQueryButton(); | ||
QueryModal.verify(); | ||
QueryModal.verifyFieldsSortedAlphabetically(); | ||
QueryModal.selectField(usersFieldValues.expirationDate); | ||
QueryModal.verifySelectedField(usersFieldValues.expirationDate); | ||
QueryModal.verifyQueryAreaContent('(user_expiration_date )'); | ||
QueryModal.verifyOperatorColumn(); | ||
QueryModal.selectOperator('>='); | ||
QueryModal.verifyOperatorsList(dateTimeOperators); | ||
QueryModal.verifyQueryAreaContent('(user_expiration_date >= )'); | ||
QueryModal.verifyValueColumn(); | ||
const todayDate = DateTools.getCurrentDate(); | ||
const todayDateWithDashes = DateTools.getCurrentDateForFiscalYear(); | ||
QueryModal.pickDate(todayDate); | ||
QueryModal.testQueryDisabled(false); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.addNewRow(); | ||
QueryModal.verifyBooleanColumn(); | ||
QueryModal.verifyEmptyField(1); | ||
QueryModal.verifyEmptyOperator(1); | ||
QueryModal.verifyEmptyValue(1); | ||
QueryModal.verifyPlusAndTrashButtonsDisabled(1, false, false); | ||
QueryModal.verifyPlusAndTrashButtonsDisabled(0, false, true); | ||
QueryModal.verifyQueryAreaContent( | ||
`(user_expiration_date >= "${todayDateWithDashes}") AND ( )`, | ||
); | ||
QueryModal.testQueryDisabled(); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.typeInAndSelectField(usersFieldValues.expirationDate, 1); | ||
QueryModal.selectOperator('<=', 1); | ||
QueryModal.verifyValueColumn(); | ||
const nextWeekDate = DateTools.get2DaysAfterTomorrowDateForFiscalYearOnUIEdit(); | ||
const nextWeekDateWithDashes = DateTools.getSomeDaysAfterTomorrowDateForFiscalYear(3); | ||
QueryModal.pickDate(nextWeekDate, 1); | ||
QueryModal.verifyQueryAreaContent( | ||
`(user_expiration_date >= "${todayDateWithDashes}") AND (user_expiration_date <= "${nextWeekDateWithDashes}")`, | ||
); | ||
QueryModal.testQueryDisabled(false); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.addNewRow(1); | ||
QueryModal.verifyBooleanColumn(2); | ||
QueryModal.verifyEmptyField(2); | ||
QueryModal.verifyEmptyOperator(2); | ||
QueryModal.verifyEmptyValue(2); | ||
QueryModal.verifyPlusAndTrashButtonsDisabled(0, false, true); | ||
QueryModal.testQueryDisabled(); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.selectField(usersFieldValues.lastName, 2); | ||
QueryModal.verifySelectedField(usersFieldValues.lastName, 2); | ||
QueryModal.verifyQueryAreaContent( | ||
`(user_expiration_date >= "${todayDateWithDashes}") AND (user_expiration_date <= "${nextWeekDateWithDashes}") AND (user_last_name )`, | ||
); | ||
QueryModal.testQueryDisabled(); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.selectOperator('starts with', 2); | ||
QueryModal.verifyOperatorsList(stringOperators, 2); | ||
QueryModal.verifyQueryAreaContent( | ||
`(user_expiration_date >= "${todayDateWithDashes}") AND (user_expiration_date <= "${nextWeekDateWithDashes}") AND (user_last_name starts with )`, | ||
); | ||
QueryModal.fillInValueTextfield('cypressTestUser', 2); | ||
QueryModal.verifyQueryAreaContent( | ||
`(user_expiration_date >= "${todayDateWithDashes}") AND (user_expiration_date <= "${nextWeekDateWithDashes}") AND (user_last_name starts with "cypressTestUser")`, | ||
); | ||
QueryModal.testQueryDisabled(false); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.addNewRow(2); | ||
QueryModal.verifyBooleanColumn(3); | ||
QueryModal.verifyEmptyField(3); | ||
QueryModal.verifyEmptyOperator(3); | ||
QueryModal.verifyEmptyValue(3); | ||
QueryModal.verifyPlusAndTrashButtonsDisabled(0, false, true); | ||
QueryModal.testQueryDisabled(); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.selectField(usersFieldValues.firstName, 3); | ||
QueryModal.verifySelectedField(usersFieldValues.firstName, 3); | ||
QueryModal.testQueryDisabled(); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.selectOperator('contains', 3); | ||
QueryModal.fillInValueTextfield('testPermFirst', 3); | ||
QueryModal.verifyQueryAreaContent( | ||
`(user_expiration_date >= "${todayDateWithDashes}") AND (user_expiration_date <= "${nextWeekDateWithDashes}") AND (user_last_name starts with "cypressTestUser") AND (user_first_name contains "testPermFirst")`, | ||
); | ||
QueryModal.testQueryDisabled(false); | ||
QueryModal.runQueryDisabled(); | ||
QueryModal.clickTestQuery(); | ||
QueryModal.verifyPreviewOfRecordsMatched(); | ||
QueryModal.clickRunQuery(); | ||
QueryModal.verifyClosed(); | ||
BulkEditSearchPane.verifySpecificTabHighlighted('Query'); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
import { | ||
Button, | ||
HTML, | ||
Keyboard, | ||
Modal, | ||
MultiColumnList, | ||
RepeatableFieldItem, | ||
Select, | ||
Selection, | ||
Spinner, | ||
TextField, | ||
including, | ||
} from '../../../../interactors'; | ||
|
||
const buildQueryModal = Modal('Build query'); | ||
const testQueryButton = Button('Test query'); | ||
const cancelButton = Button('Cancel'); | ||
const runQueryButton = Button('Run query'); | ||
const xButton = Button({ icon: 'times' }); | ||
const plusButton = Button({ icon: 'plus-sign' }); | ||
const trashButton = Button({ icon: 'trash' }); | ||
|
||
const booleanValues = ['AND']; | ||
export const usersFieldValues = { | ||
expirationDate: 'User expiration date', | ||
firstName: 'User first name', | ||
lastName: 'User last name', | ||
}; | ||
export const dateTimeOperators = [ | ||
'Select operator', | ||
'==', | ||
'!=', | ||
'>', | ||
'<', | ||
'>=', | ||
'<=', | ||
'is null/empty', | ||
]; | ||
export const stringOperators = [ | ||
'Select operator', | ||
'==', | ||
'!=', | ||
'contains', | ||
'starts with', | ||
'is null/empty', | ||
]; | ||
|
||
export default { | ||
verify(firstline = true) { | ||
cy.expect([ | ||
buildQueryModal.exists(), | ||
testQueryButton.has({ disabled: true }), | ||
cancelButton.has({ disabled: false }), | ||
runQueryButton.has({ disabled: true }), | ||
xButton.has({ disabled: false }), | ||
]); | ||
this.verifyModalContent(firstline); | ||
}, | ||
|
||
verifyModalContent(firstline) { | ||
cy.get('[class^="headline"]').contains('Query'); | ||
cy.get('[class^="queryArea"]').should('exist'); | ||
cy.get('[class^="col-sm-4"][class*="headerCell"]').should('have.text', 'Field'); | ||
cy.get('[class^="col-sm-1"][class*="headerCell"]').should('have.text', 'Actions'); | ||
this.verifyEmptyField(); | ||
cy.get('[class^="col-sm-1-"] [icon="plus-sign"]:not([disabled])'); | ||
cy.get(`[class^="col-sm-1-"] [icon="trash"]${firstline ? '[disabled]' : ':not([disabled])'}`); | ||
}, | ||
|
||
verifyEmptyField(row = 0) { | ||
cy.get( | ||
`[data-testid="row-${row}"] [class^="col-sm-4"] [class^="selectionControl"] [class^="singleValue"]`, | ||
).should('have.text', 'Select field'); | ||
}, | ||
|
||
verifyEmptyOperator(row = 0) { | ||
cy.get(`[data-testid="row-${row}"] [class^="col-sm-2"]`).children().should('not.exist'); | ||
}, | ||
|
||
verifyEmptyValue(row = 0) { | ||
cy.get(`[data-testid="row-${row}"] [class^="col-sm-4"]`).eq(1).children().should('not.exist'); | ||
}, | ||
|
||
verifyFieldsSortedAlphabetically() { | ||
cy.get('[class^="col-sm-4"] [role="listbox"] [role="option"]') | ||
.children() | ||
.then((optionsText) => { | ||
const textArray = optionsText.get().map((el) => el.innerText); | ||
const sortedArray = [...textArray].sort((a, b) => a - b); | ||
expect(sortedArray).to.eql(textArray); | ||
}); | ||
}, | ||
|
||
selectField(selection, row = 0) { | ||
cy.do(RepeatableFieldItem({ index: row }).find(Selection()).choose(selection)); | ||
}, | ||
|
||
typeInAndSelectField(string, row = 0) { | ||
cy.do([ | ||
RepeatableFieldItem({ index: row }).find(Selection()).open(), | ||
RepeatableFieldItem({ index: row }).find(Selection()).filterOptions(string), | ||
cy.wait(1000), | ||
Keyboard.enter(), | ||
]); | ||
}, | ||
|
||
verifySelectedField(selection, row = 0) { | ||
cy.get( | ||
`[data-testid="row-${row}"] [class^="col-sm-4"] [class^="selectionControl"] [class^="singleValue"]`, | ||
).should('have.text', selection); | ||
}, | ||
|
||
verifyOperatorColumn() { | ||
cy.get('[class^="col-sm-2"][class*="headerCell"]').should('have.text', 'Operator'); | ||
cy.get( | ||
'[class^="col-sm-2"] [class^="selectControl"] option:contains("Select operator"):disabled', | ||
); | ||
}, | ||
|
||
selectOperator(selection, row = 0) { | ||
cy.do( | ||
RepeatableFieldItem({ index: row }) | ||
.find(Select({ dataTestID: including('operator-option') })) | ||
.choose(selection), | ||
); | ||
}, | ||
|
||
verifyOperatorsList(operators, row = 0) { | ||
cy.get(`[data-testid="row-${row}"] [class^="col-sm-2"] [class^="selectControl"] option`).then( | ||
(options) => { | ||
const textArray = options.get().map((el) => el.label); | ||
expect(textArray).to.eql(operators); | ||
}, | ||
); | ||
}, | ||
|
||
verifyQueryAreaContent(content) { | ||
cy.get('[class^="queryArea"]').should('have.text', content); | ||
}, | ||
|
||
verifyValueColumn() { | ||
cy.get('[class^="col-sm-4"][class*="headerCell"]').contains('Value'); | ||
}, | ||
|
||
pickDate(date, row = 0) { | ||
cy.get(`[data-testid="row-${row}"] [class^="col-sm-4"] [placeholder="MM/DD/YYYY"]`).should( | ||
'exist', | ||
); | ||
cy.get(`[data-testid="row-${row}"] [class^="col-sm-4"] [icon="calendar"]`).should('exist'); | ||
cy.do(RepeatableFieldItem({ index: row }).find(TextField()).fillIn(date)); | ||
}, | ||
|
||
fillInValueTextfield(text, row = 0) { | ||
cy.do(RepeatableFieldItem({ index: row }).find(TextField()).fillIn(text)); | ||
}, | ||
|
||
cancelDisabled(disabled = true) { | ||
cancelButton.has({ disabled }); | ||
}, | ||
|
||
testQueryDisabled(disabled = true) { | ||
cy.expect(testQueryButton.has({ disabled })); | ||
}, | ||
|
||
runQueryDisabled(disabled = true) { | ||
cy.expect(runQueryButton.has({ disabled })); | ||
}, | ||
|
||
addNewRow(row = 0) { | ||
cy.do(RepeatableFieldItem({ index: row }).find(plusButton).click()); | ||
}, | ||
|
||
verifyBooleanColumn(row = 1) { | ||
cy.get('[class^="col-sm-1"][class*="headerCell"]').contains('Boolean'); | ||
cy.get(`[data-testid="row-${row}"] [class^="col-sm-1"] [class^="selectControl"]`) | ||
.find('option') | ||
.should('have.length', 1) | ||
.and('have.text', ...booleanValues); | ||
}, | ||
|
||
verifyPlusAndTrashButtonsDisabled(row = 0, plusDisabled = true, trashDisabled = true) { | ||
cy.expect([ | ||
RepeatableFieldItem({ index: row }).find(plusButton).has({ disabled: plusDisabled }), | ||
RepeatableFieldItem({ index: row }).find(trashButton).has({ disabled: trashDisabled }), | ||
]); | ||
}, | ||
|
||
clickTestQuery() { | ||
cy.do(testQueryButton.click()); | ||
cy.expect([HTML('Test query in progress').exists(), Spinner().exists()]); | ||
this.runQueryDisabled(); | ||
this.cancelDisabled(false); | ||
}, | ||
|
||
verifyPreviewOfRecordsMatched() { | ||
cy.expect([MultiColumnList().exists(), Button('Show columns').exists()]); | ||
this.testQueryDisabled(false); | ||
this.cancelDisabled(false); | ||
this.runQueryDisabled(false); | ||
cy.get('[class^="col-xs-10"]').then(($element) => { | ||
cy.wrap($element) | ||
.invoke('text') | ||
.then((text) => { | ||
const [totalRecords, previewRecords] = text.match(/\d+/g).map(Number); | ||
const previewLabel = `Preview of first ${Math.min(previewRecords, 100)} records.`; | ||
expect(text.startsWith(`Query would return ${totalRecords} records.`)).to.equal(true); | ||
expect(previewLabel).to.equal( | ||
`Preview of first ${Math.min(previewRecords, 100)} records.`, | ||
); | ||
}); | ||
}); | ||
}, | ||
|
||
clickRunQuery() { | ||
cy.do(runQueryButton.click()); | ||
}, | ||
|
||
verifyClosed() { | ||
cy.do(buildQueryModal.absent()); | ||
}, | ||
}; |