Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 60 additions & 28 deletions robot/Cumulus/tests/browser/learning_robot.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***

Resource robot/Cumulus/resources/NPSP.robot
Library cumulusci.robotframework.PageObjects
... robot/Cumulus/resources/GAUPageObject.py
Expand All @@ -12,48 +11,81 @@ Suite Teardown Delete Records and Close Browser

*** Keywords ***
Setup Test Data
&{campaign}= API Create Campaign
&{data}= setupdata contact ${contact1_fields}
Set suite Variable &{campaign}
Set suite Variable &{data}

&{campaign}= API Create Campaign
&{data}= setupdata contact ${contact1_fields}
${ns}= Get Npsp Namespace Prefix
Set suite Variable &{campaign}
Set suite Variable &{data}
Set suite Variable ${ns}

*** Variables ***
&{contact1_fields} Email=test@example.com
${amount} 100
${stage_name} Closed Won


*** Test Cases ***
Assign GAU to Campaign and Verify Allocation on Opportunity
Create GAU
${name}= Generate Random String
Go To Page Listing
... General_Accounting_Unit__c
${gau1_name}= Generate Random String
... General_Accounting_Unit__c
Click Object Button New
Populate Modal Form
... General Accounting Unit Name=${gau1_name}
Populate Modal Form
... General Accounting Unit Name=${name}
Click Modal Button Save
Wait Until Modal Is Closed
${gau_header}= Get Main Header
${gau1}= Save Current Record Id For Deletion General_Accounting_Unit__c
Select Tab Related
Click Object Button New
Populate Modal Form Percent=100
... Campaign=&{campaign}[Name]
Click Modal Button Save
${gau_id}= Save Current Record Id For Deletion General_Accounting_Unit__c
[return] ${gau_id}

Create Opportunity With Campaign
[Arguments] ${account_name} ${campaign_name}
Go To Page Listing
... Opportunity
${opportunity_name}= Generate Random String
Click Object Button New
Select Record Type Donation
Populate Modal Form
... Opportunity Name=${opportunity_name}
... Account Name=${data}[contact][LastName] Household
... Account Name=${account_name}
... Amount=${amount}
... Primary Campaign Source=${campaign}[Name]
... Primary Campaign Source=${campaign_name}
Select Value From Dropdown Stage ${stage_name}
Open Date Picker Close Date
Pick Date Today
Click Modal Button Save
Wait Until Modal Is Closed
${opp_id}= Save Current Record Id For Deletion Opportunity
[return] ${opp_id}

API Create Campaign GAU Allocation
[Arguments] ${gau_id} ${campaign_id} &{fields}
${ns}= Get Npsp Namespace Prefix
${all_id}= Salesforce Insert
... ${ns}Allocation__c
... ${ns}General_Accounting_Unit__c=${gau_id}
... ${ns}Campaign__c=${campaign_id}
... &{fields}
&{gau_alloc}= Salesforce Get ${ns}Allocation__c ${all_id}
[return] &{gau_alloc}

Browser Create Campaign GAU Allocation
[Arguments] ${campaign_name}
Select Tab Related
Click Object Button New
Populate Modal Form Percent=100
... Campaign=${campaign_name}
Click Modal Button Save

Verify GAU Allocation is Automatically Created
Select Tab Related
Validate Related Record Count GAU Allocations 1
Validate Related Record Count GAU Allocations 1


*** Variables ***
&{contact1_fields} Email=test@example.com
${amount} 100
${stage_name} Closed Won


*** Test Cases ***
Assign GAU to Campaign and Verify Allocation on Opportunity
${gau_id}= Create GAU

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sungysang looks like this can be part of Setup Test Data since it isn't part of the test.

API Create Campaign GAU Allocation ${gau_id}
... &{campaign}[Id]
... ${ns}Percent__c=100.0
Comment on lines +86 to +88

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could group this into a keyword called Create 100% Campaign GAU Allocation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to leave this keyword on this robot file then I'd just hard code the API Create keyword to be 100%. If you want the keyword to be more generic and usable in other tests, then I would promote your API Create Keyword to NPSP.robot file (first I'd check to make sure one doesn't already exist that you can just use an update). And then you can create a localized keyword that references the above. While not a requirement, I recommend building keywords so that there are no variables in the tests so that the tests can be very readable steps.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you promote it, you can probably put it near this keyword: https://github.com/SalesforceFoundation/NPSP/blob/master/robot/Cumulus/resources/NPSP.robot#L139

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Julian88Tex Thanks, I basically copy pasted the original keyword since that one only worked for Opportunities, how would I promote it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sungysang promote it means cut it from this file and paste it in the NPSP.robot file

Create Opportunity With Campaign ${data}[contact][LastName] Household
... ${campaign}[Name]
Comment on lines +89 to +90

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this needs to be UI? If you just testing the trigger logic, you might as well just create Opportunity through API. Looks like you can use this existing Keyword: https://github.com/SalesforceFoundation/NPSP/blob/master/robot/Cumulus/resources/NPSP.robot#L50

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Julian88Tex I felt like this should try to re-create the user scenario as close as possible through the UI, but would you recommend API?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sungysang it all depends on what you're trying to test. If you trying to test the trigger, then API should be fine IMO since I wouldn't expect UI to have any impact on trigger logic vs. making an API call. If you're trying to test UI then stick with UI.

Verify GAU Allocation is Automatically Created