Skip to content

Commit

Permalink
Moved api and functional tests into common sub-folder
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts committed Mar 4, 2019
1 parent dbd9e19 commit f9da6e1
Show file tree
Hide file tree
Showing 92 changed files with 1,436 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Jenkinsfile
Expand Up @@ -254,7 +254,7 @@ def apiTest (String stageName, String stageUrl, String envSuffix) {
) {
node("nodejs-${appName}-${envSuffix}-${prNumber}") {
checkout scm
dir('api-tests') {
dir('tests/api-tests') {
sh 'npm install -g newman'
try {
sh """
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,134 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package pages

class OrganizationsPage extends BaseAppPage {
static at = { pageTitle.text() == 'Manage Companies' }
static url = 'registries/organizations/manage'
static content = {
pageTitle { $('main h4') }

addAlert(required:false) { $('#orgAddSuccessAlert') }
updateAlert(required:false) { $('#orgUpdateSuccessAlert') }
deleteAlert(required:false) { $('#orgDeleteSuccessAlert') }

// add company
addNewCompanyButton(wait:2) { $('#orgAddNewButton') }

// Update/Delete company
selectCompanySearchField { $('#orgEditSelectDropdown').$('input', type:'search') }
selectCompanyDropdown(required:false) { $('#orgEditSelectDropdown').$('.dropdown-menu') }

// Update company
companyNameField(required:false) { $('#orgEditNameInput') }
streetAddressField(required:false) { $('#orgEditAddressInput') }
cityField(required:false) { $('#orgEditCityInput') }
provinceDropdown(required:false) { $('#orgEditProvinceInput') }
postalCodeField(required:false) { $('#orgEditPostalInput') }
telephoneNumberField(required:false) { $('#orgEditPhoneInput') }
faxNumberField(required:false) { $('#orgEditFaxInput') }
emailField(required:false) { $('#orgEditEmailInput') }
websiteField(required:false) { $('#orgEditWebsiteInput') }

updateButton(required:false) { $('button', type:'submit', text:'Update') }

// Delete company
deleteButton(required:false) { $('button', type:'button', text:'Delete this company') }
}

// Add company
void clickAddNewCompanyButton() {
addNewCompanyButton.click()
}

Boolean addCompanySuccessAlertDisplayed() {
return waitFor {
addAlert.displayed == true &&
addAlert.text() =~ 'Company added'
}
}

// Update/Delete company
void selectCompany(String regex) {
// Expand the search dropdown
selectCompanySearchField.click()
interact {
waitFor {
// wait for the dropdown to populate and click the element in the list with the matching text
moveToElement(selectCompanyDropdown.$('li', text:~"$regex")).click()
}
}
}

// Update company
void setCompanyName(String name) {
companyNameField.value(name)
}

void setStreetAddress(String address) {
streetAddressField.value(address)
}

void setCity(String city) {
cityField.value(city)
}

void setProvince(String province) {
provinceDropdown.$('option', text:province).click()
}

void setPostalCode(String postalCode) {
postalCodeField.value(postalCode)
}

void setTelephoneNumber(String telephoneNumber) {
telephoneNumberField.value(telephoneNumber)
}

void setFaxNumber(String faxNumber) {
faxNumberField.value(faxNumber)
}

void setEmail(String email) {
emailField.value(email)
}

void setWebsite(String website) {
websiteField.value(website)
}

void clickUpdateButton() {
updateButton.click()
}

Boolean updateCompanySuccessAlertDisplayed() {
return waitFor {
updateAlert.displayed == true &&
updateAlert.text() =~ 'Successfully updated company information'
}
}

// Delete company
void clickDeleteButton() {
waitFor { deleteButton.click() }
}

Boolean deleteCompanySuccessAlertDisplayed(String name) {
return waitFor {
deleteAlert.displayed == true &&
deleteAlert.text() =~ "$name removed"
}
}
}
@@ -0,0 +1,72 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package pages

class RegistryAddPage extends BaseAppPage {
static at = { pageTitle.text() == 'Add new applicant' }
static url = 'registries/people/add'
static content = {
pageTitle { $('main h5') }

surnameField { $('#surnameInput') }
firstnameField { $('#firstnameInput') }
telephoneNumberField { $('#contactTelInput') }
emailField { $('#contactEmailInput') }
wellDrillerORCSFIeld { $('#drillerORCSInput') }
pumpInstallerORCSField { $('#pumpORCSInput') }

registerAsRadioButtons { $('#registrationTypeInput') }

saveButton { $('button', type:'submit', text:'Save') }
}

void setSurname(String surname) {
surnameField.value(surname)
}

void setFirstname(String firstname) {
firstnameField.value(firstname)
}

void setTelephoneNumber(String telephoneNumber) {
telephoneNumberField.value(telephoneNumber)
}

void setEmail(String email) {
emailField.value(email)
}

void setWellDrillerROCS(int orcsNumber) {
wellDrillerORCSFIeld.value(orcsNumber)
}

void setPumpInstallerORCS(int orcsNumber) {
pumpInstallerORCSField.value(orcsNumber)
}

// TODO
void registerAsDriller() {
registerAsRadioButtons.$('input', value:'DRILL').click()
}

// TODO
void registerAsPumpInstaller() {
registerAsRadioButtons.$('input', value:'PUMP').click()
}

void clickSaveButton() {
saveButton.click()
}
}
@@ -0,0 +1,67 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package pages

class RegistryPage extends BaseAppPage {
static at = { pageTitle.text() == 'Register of Well Drillers and Well Pump Installers' }
static url = 'registries'
static content = {
pageTitle { $('main h4') }

bodyContent { $('#main-content .card-body') }

addNewEntryButton(required:false) { $('#addNewEntryButton') }
manageCompaniesButton(required:false) { $('#manageCompaniesButton') }

registrationStatusDropdown(required:false) { $('#manageCompaniesButton') }

wellDrillerRadioButton { $('#activityDriller') }
wellPumpInstallerRadioButton { $('#activityInstaller') }

individualOrCompanyOrRegistrationSearchField { $('#regTypeInput') }

searchButton { $('#personSearchSubmit') }

searchResultsTable(required:false) { $('#registry-table') }
}

void clickAddNewEntryButton() {
waitFor { addNewEntryButton.click() }
}

void clickManageCompaniesButton() {
waitFor { manageCompaniesButton.click() }
}

void clickSearchButton() {
searchButton.click()
}

void clickWellDrillerRadioButton() {
wellDrillerRadioButton.parent().click()
}

void clickWellPumpInstallerRadioButton() {
wellPumpInstallerRadioButton.parent().click()
}

void setIndividualOrCompanyOrRegistrationSearchField(String value) {
individualOrCompanyOrRegistrationSearchField.value(value)
}

int getSearchResultsCount() {
waitFor { searchResultsTable.$('tbody tr').size() }
}
}
@@ -0,0 +1,44 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package pages

/**
* Well Operator profile page.
*/
class RegistryProfilePage extends BaseAppPage {
static at = {
browser.getCurrentUrl() =~ /\/registries\/people\/[a-z0-9\-]+$/ &&
pageTitle.text() == "$firstName $surname"
}
static content = {
pageTitle { $('main h4') }
}

private final String surname
private final String firstName

/**
* Constructor.
*
* Uses the well operator's first and last name to-at check the page, as the title is based on the operator's name.
*
* @param String the well operator surname (required)
* @param String the well operator firstName (required)
*/
RegistryProfilePage(String surname, String firstName) {
this.surname = surname
this.firstName = firstName
}
}

0 comments on commit f9da6e1

Please sign in to comment.