Skip to content

Commit

Permalink
implemented AdminCanCreateModelAndPolicySpec (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayshukla30 committed May 18, 2018
1 parent f356699 commit 8b267ec
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CreateDataModelPage extends Page implements InputUtils {

void submit() {
submitButton.click()
sleep(2000)
}

void check(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,18 @@ class DataModelPage extends Page implements InputUtils {

void searchPolicy(String value) {
fillInput(dataModelSearchBar, value)
sleep(2000)
policiesDropdown.$('li', 0).click()
waitFor(5) { policiesDropdown.$('li', 0) }
}

void selectCreateNew() {
int size = policiesDropdown.$('li').size()
policiesDropdown.$('li', size - 1).click()
}

void saveModel() {
waitFor { saveButton }
saveButton.click()
sleep(2000)
}

Boolean policyAdded(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import geb.Page

class DataModelPolicyCreatePage extends Page {

static at = { $('.modal-dialog').text().contains('Create Data Policy') }

static content = {
inputName { $('#name', 0) }
inputPolicyText { $('#policyText', 0) }
Expand All @@ -12,6 +14,7 @@ class DataModelPolicyCreatePage extends Page {

void save() {
saveButton.click()
sleep(2000)
}

void setName(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ class DataModelPolicyPage extends Page {
static at = { title.contains("Properties of") }

static content = {
policyTitle { $('h3 span') }
policyText { $('table#properties-props tbody tr') }
}

Boolean policyTextIs(String value) {
String text = policyText.$('td').text()
(value == text)
}

Boolean titleIs(String value) {
String title = policyTitle.text()
(value == title)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ class AdminCanCreateModelAndPolicySpec extends GebSpec {
@Shared
String datamodelDescription = "TESTING_MODEL_DESCRIPTION"
@Shared
String defaultPolicy = "Default Checks"
List<String> policies = []
@Shared
List<String> policies = ["Unique of Kind",]
String newPolicyName = "New Policy"
@Shared
String newPolicyText = "check dataElement property 'name' is 'unique'"
def "login as supervisor"() {
when: 'login as a curator'
Expand All @@ -47,23 +49,23 @@ class AdminCanCreateModelAndPolicySpec extends GebSpec {
at DashboardPage
}
def "create data model"() {
when:
DashboardPage dashboardPage = browser.page DashboardPage
dashboardPage.nav.createDataModel()
then:
at CreateDataModelPage
when:
CreateDataModelPage createDataModelPage = browser.page CreateDataModelPage
createDataModelPage.name = datamodelName
createDataModelPage.modelCatalogueIdInput = UUID.randomUUID().toString()
createDataModelPage.description = datamodelDescription
println(policies = createDataModelPage.selectedPolicyName())
createDataModelPage.submit()
then:
at DataModelPage
}
def "create data model"() {
when:
DashboardPage dashboardPage = browser.page DashboardPage
dashboardPage.nav.createDataModel()
then:
at CreateDataModelPage
when:
CreateDataModelPage createDataModelPage = browser.page CreateDataModelPage
createDataModelPage.name = datamodelName
createDataModelPage.modelCatalogueIdInput = UUID.randomUUID().toString()
createDataModelPage.description = datamodelDescription
println(policies = createDataModelPage.selectedPolicyName())
createDataModelPage.submit()
then:
at DataModelPage
}
def "selected data model policy is shown"() {
Expand All @@ -82,16 +84,28 @@ class AdminCanCreateModelAndPolicySpec extends GebSpec {
when:
dataModelPage = browser.page DataModelPage
dataModelPage.searchPolicy(defaultPolicy)
dataModelPage.searchPolicy(newPolicyName)
dataModelPage.selectCreateNew()
then:
at DataModelPolicyCreatePage
}
def "create new data model policy"() {
when:
DataModelPolicyCreatePage dataModelPolicyCreatePage = browser.page DataModelPolicyCreatePage
dataModelPolicyCreatePage.name = newPolicyName
dataModelPolicyCreatePage.policyText = newPolicyText
dataModelPolicyCreatePage.save()
then:
at DataModelPage
}
def "verify new policy is added"() {
when:
DataModelPage dataModelPage = browser.page DataModelPage
then:
dataModelPage.policyAdded(defaultPolicy)
dataModelPage.policyAdded(newPolicyName)
}
def "save data model"() {
Expand All @@ -105,9 +119,20 @@ class AdminCanCreateModelAndPolicySpec extends GebSpec {
def "select policy"() {
when:
DataModelPage dataModelPage = browser.page DataModelPage
withNewWindow(dataModelPage.selectPolicy(defaultPolicy))
dataModelPage.selectPolicy(newPolicyName)
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
}
then:
at DataModelPolicyPage
}
def "compare the policy text"() {
when:
DataModelPolicyPage dataModelPolicyPage = browser.page DataModelPolicyPage
then:
dataModelPolicyPage.policyTextIs(newPolicyText)
dataModelPolicyPage.titleIs(newPolicyName)
}
}

0 comments on commit 8b267ec

Please sign in to comment.