Skip to content

Commit

Permalink
Merge pull request #42 from SalesforceFoundation/feature/robot_gauper…
Browse files Browse the repository at this point in the history
…mission

Robot - Permission Testing GAU Expenditure
  • Loading branch information
gaganpsandhu authored Mar 29, 2021
2 parents 430dcc7 + 19afb44 commit b26ff32
Show file tree
Hide file tree
Showing 12 changed files with 374 additions and 12 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"jsclick",
"rtype",
"outfundsnpsp",
"gauexp",
// Storytelling data
"Englewood",
"Takagawa",
Expand Down
17 changes: 17 additions & 0 deletions cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ tasks:
options:
path: robot/OutboundFundsNPSP/resources/layouts

create_perms_testing_user:
description: Creates a test user for testing permissions.
class_path: cumulusci.tasks.sfdx.SFDXOrgTask
options:
command: "force:user:create -a permtest --definitionfile robot/OutboundFundsNPSP/resources/qa_org/users/perms_test_user.json"

deploy_qa_config:
description: Deploys additional fields used for QA purposes only
class_path: cumulusci.tasks.salesforce.Deploy
group: Salesforce Metadata
options:
path: robot/OutboundFundsNPSP/resources/unpackaged/qa

flows:
config_dev:
steps:
Expand All @@ -73,6 +86,10 @@ flows:
task: load_storytelling_data
4:
task: robot_deploy_layouts
5:
task: deploy_qa_config
6:
task: create_perms_testing_user

config_managed:
steps:
Expand Down
130 changes: 129 additions & 1 deletion robot/OutboundFundsNPSP/doc/Keywords.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ <h2 title="robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.py">
<th>Documentation</th>
</tr>

<tr class="kwrow" id="OutboundFundsNPSP.py.Add Date">
<td class="kwname">Add Date</td>
<td class="kwargs">
<i>title</i>,

<i>date</i>
</td>
<td class="kwdoc">
<p>
Clicks on the 'Date' field in Form and picks a
date in the argument
</p>
</td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Check If Element Exists"
Expand Down Expand Up @@ -306,6 +321,28 @@ <h2 title="robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.py">
<td class="kwdoc"></td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Get Outboundfundsnpsp Lex Locators"
>
<td class="kwname">Get Outboundfundsnpsp Lex Locators</td>
<td class="kwargs">
<i>path</i>,

<i>*args</i>,

<i>**kwargs</i>
</td>
<td class="kwdoc">
<p>
Returns a rendered locator string from the
outboundfundsnpsp_lex_locators dictionary. This
can be useful if you want to use an element in a
different way than the built in keywords allow.
</p>
</td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Get Outfundsnpsp Namespace Prefix"
Expand All @@ -315,6 +352,17 @@ <h2 title="robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.py">
<td class="kwdoc"></td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Get Outfundsnpspext Namespace Prefix"
>
<td class="kwname">
Get Outfundsnpspext Namespace Prefix
</td>
<td class="kwargs"></td>
<td class="kwdoc"></td>
</tr>

<tr class="kwrow" id="OutboundFundsNPSP.py.New Random String">
<td class="kwname">New Random String</td>
<td class="kwargs">
Expand All @@ -325,6 +373,39 @@ <h2 title="robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.py">
</td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Page Should Not Contain Locator"
>
<td class="kwname">Page Should Not Contain Locator</td>
<td class="kwargs">
<i>path</i>,

<i>*args</i>,

<i>**kwargs</i>
</td>
<td class="kwdoc">
<p>
Waits for the locator specified to be not present
on the page
</p>
</td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Populate Field With Id"
>
<td class="kwname">Populate Field With Id</td>
<td class="kwargs">
<i>id</i>,

<i>value</i>
</td>
<td class="kwdoc"></td>
</tr>

<tr class="kwrow" id="OutboundFundsNPSP.py.Random Email">
<td class="kwname">Random Email</td>
<td class="kwargs">
Expand All @@ -351,6 +432,21 @@ <h2 title="robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.py">
<td class="kwdoc"><p>Click Save Disbursement</p></td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Select Value From Picklist"
>
<td class="kwname">Select Value From Picklist</td>
<td class="kwargs">
<i>dropdown</i>,

<i>value</i>
</td>
<td class="kwdoc">
<p>Select given value in the dropdown field</p>
</td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Selenium Execute With Retry"
Expand Down Expand Up @@ -396,6 +492,38 @@ <h2 title="robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.py">
</td>
</tr>

<tr
class="kwrow"
id="OutboundFundsNPSP.py.Verify Button Status"
>
<td class="kwname">Verify Button Status</td>
<td class="kwargs">
<i>**kwargs</i>
</td>
<td class="kwdoc">
<p>
Verify the link is disabled/enabled, pass the name
of the link and the expected status of the link as
either enabled or disabled Eg: |Verify Link Status
| Update this Payment=enabled ... Update this
Opportunity=disabled |
</p>
</td>
</tr>

<tr class="kwrow" id="OutboundFundsNPSP.py.Verify Row Count">
<td class="kwname">Verify Row Count</td>
<td class="kwargs">
<i>value</i>
</td>
<td class="kwdoc">
<p>
verifies if actual row count matches with expected
value
</p>
</td>
</tr>

<tr class="kwrow" id="OutboundFundsNPSP.py.Wait For Aura">
<td class="kwname">Wait For Aura</td>
<td class="kwargs"></td>
Expand Down Expand Up @@ -910,7 +1038,7 @@ <h2 title="robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.robot">
</div>
</div>
<div class="footer">
Generated on Tuesday March 16, 09:40 AM - cumulusci v3.30.0
Generated on Wednesday March 24, 02:04 PM - cumulusci v3.28.0
</div>
</body>
</html>
69 changes: 69 additions & 0 deletions robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ def _init_locators(self):
locators = locators_by_api_version[self.latest_api_version]
outboundfundsnpsp_lex_locators.update(locators)

def get_outboundfundsnpsp_lex_locators(self, path, *args, **kwargs):
""" Returns a rendered locator string from the outboundfundsnpsp_lex_locators
dictionary. This can be useful if you want to use an element in
a different way than the built in keywords allow.
"""
locator = outboundfundsnpsp_lex_locators
for key in path.split("."):
locator = locator[key]
main_loc = locator.format(*args, **kwargs)
return main_loc

def get_namespace_prefix(self, name):
parts = name.split("__")
if parts[-1] == "c":
Expand All @@ -71,6 +82,13 @@ def get_outfundsnpsp_namespace_prefix(self):
]
return self.get_namespace_prefix(fundingprogram_object["name"])

def get_outfundsnpspext_namespace_prefix(self):
if not hasattr(self.cumulusci, "_describe_result"):
self.cumulusci._describe_result = self.cumulusci.sf.describe()
objects = self.cumulusci._describe_result["sobjects"]
gauexp_object = [o for o in objects if o["label"] == "GAU Expenditure"][0]
return self.get_namespace_prefix(gauexp_object["name"])

def get_npsp_namespace_prefix(self):
if not hasattr(self.cumulusci, "_describe_result"):
self.cumulusci._describe_result = self.cumulusci.sf.describe()
Expand Down Expand Up @@ -201,6 +219,15 @@ def save_disbursement(self):
self.selenium.set_focus_to_element(locator)
self.selenium.get_webelement(locator).click()

def verify_row_count(self, value):
"""verifies if actual row count matches with expected value"""
locator = outboundfundsnpsp_lex_locators["related"]["count"]
actual_value = self.selenium.get_webelements(locator)
count = len(actual_value)
assert int(value) == count, "Expected value to be {} but found {}".format(
value, count
)

@capture_screenshot_on_error
def select_value_from_picklist(self, dropdown, value):
"""Select given value in the dropdown field"""
Expand All @@ -217,6 +244,7 @@ def select_value_from_picklist(self, dropdown, value):
].format(value)
self.salesforce._jsclick(value_loc)

@capture_screenshot_on_error
def add_date(self, title, date):
""" Clicks on the 'Date' field in Form and picks a date in the argument """
locator = outboundfundsnpsp_lex_locators["new_record"]["date_field"].format(
Expand All @@ -225,3 +253,44 @@ def add_date(self, title, date):
self.selenium.set_focus_to_element(locator)
self.selenium.clear_element_text(locator)
self.selenium.get_webelement(locator).send_keys(date)

@capture_screenshot_on_error
def page_should_not_contain_locator(self, path, *args, **kwargs):
"""Waits for the locator specified to be not present on the page"""
main_loc = self.get_outboundfundsnpsp_lex_locators(path, *args, **kwargs)
self.selenium.wait_until_page_does_not_contain_element(main_loc, timeout=60)

def verify_button_status(self, **kwargs):
""" Verify the button is disabled/enabled, pass the name of the buttin
and the expected status of the buttin as either enabled or disabled"""

for key, value in kwargs.items():
locator = outboundfundsnpsp_lex_locators["button-with-text"].format(key)
self.selenium.wait_until_element_is_visible(
locator, error=f"'{key}' is not displayed on the page"
)
if value == "disabled":
actual_value = self.selenium.get_webelement(locator).get_attribute(
value
)
if actual_value is None or actual_value is False:
raise Exception(
f"Expected {key} status to be {value} but found {actual_value}"
)
elif value == "enabled":
actual_value = self.selenium.get_webelement(locator).get_attribute(
"disabled"
)
if not (actual_value is None or actual_value is False):
raise Exception(
f"Expected {key} status to be {value} but found {actual_value}"
)

def populate_field_with_id(self, id, value):
"""Populate field with id on manage expenditure page"""
locator = outboundfundsnpsp_lex_locators["id"].format(id)
if value == "null":
field = self.selenium.get_webelement(locator)
self.salesforce._clear(field)
else:
self.salesforce._populate_field(locator, value)
14 changes: 8 additions & 6 deletions robot/OutboundFundsNPSP/resources/OutboundFundsNPSP.robot
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ API Create GAU Expenditure
[Arguments] ${gau_id} ${disbursement_id} &{fields}
${ns} = Get Outfundsnpsp Namespace Prefix
${ns_npsp} = Get NPSP Namespace Prefix
${gauexpenditure_id} = Salesforce Insert GAU_Expenditure__c
... Amount__c=10000
... General_Accounting_Unit__c=${gau_id}
... Disbursement__c=${disbursement_id}
&{gauexp} = Salesforce Get GAU_Expenditure__c ${gauexpenditure_id}
Store Session Record GAU_Expenditure__c ${gauexpenditure_id}
${ns_npspext} = Get Outfundsnpspext Namespace Prefix
${gauexpenditure_id} = Salesforce Insert ${ns_npspext}GAU_Expenditure__c
... ${ns_npspext}Amount__c=10000
... ${ns_npspext}General_Accounting_Unit__c=${gau_id}
... ${ns_npspext}Disbursement__c=${disbursement_id}
&{gauexp} = Salesforce Get ${ns_npspext}GAU_Expenditure__c
... ${gauexpenditure_id}
Store Session Record ${ns_npspext}GAU_Expenditure__c ${gauexpenditure_id}
[Return] &{gauexp}

Change Object Permissions
Expand Down
2 changes: 2 additions & 0 deletions robot/OutboundFundsNPSP/resources/locators_51.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@
"header": "//h1//div[contains(@class, 'entityNameTitle') and contains(text(),'{}')]",
},
"link": "//a[contains(text(),'{}')]",
"id": "//input[@type='text' and @inputmode='decimal' and @step='0.01']",
"button-with-text": "//button[contains(text(),'{}')]",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"FirstName": "PermsTestingUser",
"LastName": "ForDisbursement",
"Email": "[email protected]",
"Alias": "permtest",
"TimeZoneSidKey": "America/Los_Angeles",
"LocaleSidKey": "en_US",
"EmailEncodingKey": "UTF-8",
"LanguageLocaleKey": "en_US",
"profileName": "Standard User",
"generatePassword": true,
"permsets": ["GAU_Expenditure"]
}
8 changes: 8 additions & 0 deletions robot/OutboundFundsNPSP/resources/unpackaged/qa/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>GAU_Expenditure</members>
<name>PermissionSet</name>
</types>
<version>50.0</version>
</Package>
Loading

0 comments on commit b26ff32

Please sign in to comment.