Skip to content

Commit

Permalink
Merge pull request #160 from SFDO-Community/feature-ccipkg1
Browse files Browse the repository at this point in the history
Feature ccipkg1
  • Loading branch information
iandrosov authored Nov 14, 2024
2 parents b6c5259 + 46a1f81 commit c8e6e54
Show file tree
Hide file tree
Showing 45 changed files with 550 additions and 103 deletions.
File renamed without changes.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ tempdata-out
.pmdCache
.vscode/*
.vscode/settings.json
test_results.json
test_results.xml
1 change: 1 addition & 0 deletions cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project:
name: GrantGuides
package:
name: ggw
namespace: GCKit
api_version: '55.0'
git:
default_branch: 'main'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
242 changes: 230 additions & 12 deletions force-app/main/default/classes/GGW_ApplicationCtrlTest.cls

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
42 changes: 40 additions & 2 deletions force-app/main/default/classes/GGW_ApplicationSelectorTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,36 @@
*/
@isTest
private class GGW_ApplicationSelectorTest {
@TestSetup
static void makeData(){

String uniqueUserName = 'grantuser' + DateTime.now().getTime() + '@labsorg.com';
// This code runs as the system user
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];

PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GGW_User_Permissions'];

User u = new User(Alias = 'standt', Email='[email protected]',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles',
UserName=uniqueUserName);
insert u;

insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id);
}
@isTest
static void testQueryGrantApp(){
// This code runs as the Grant Guide User with GGW Permission Set from the TestSetup makeData() method.
User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey,
LocaleSidKey, ProfileId, TimeZoneSidKey, UserName
FROM User WHERE Email = '[email protected]' AND Alias='standt' LIMIT 1];

System.runAs(u) {

//Create sample data
GGW_TestDataFactory.createGrantContentTestData();

// Query all suggested sections
List<GGW_SectionWrapper> lst = GGW_ApplicationCtrl.getSections();
List<String> sections = new List<String>();
Expand All @@ -43,10 +70,20 @@ private class GGW_ApplicationSelectorTest {
GGW_Grant_Application__c grant = GGW_ApplicationSelector.queryGrantApp(app.Id);
Test.stopTest();
System.assertEquals(grant.Name, 'Grant App', 'Could not create a new grant application');

}
}
@isTest
static void getGrantApplicationsTest(){
// This code runs as the Grant Guide User with GGW Permission Set from the TestSetup makeData() method.
User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey,
LocaleSidKey, ProfileId, TimeZoneSidKey, UserName
FROM User WHERE Email = '[email protected]' AND Alias='standt' LIMIT 1];

System.runAs(u) {

//Create sample data
GGW_TestDataFactory.createGrantContentTestData();

// Query all suggested sections
List<GGW_SectionWrapper> lst = GGW_ApplicationCtrl.getSections();
List<String> sections = new List<String>();
Expand All @@ -63,5 +100,6 @@ private class GGW_ApplicationSelectorTest {
List<GGW_Grant_Application__c> grantList = GGW_ApplicationSelector.getGrantApplications();
Test.stopTest();
System.assertEquals(2, grantList.size(), 'Query grant application invalid');
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
31 changes: 28 additions & 3 deletions force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,36 @@
public class GGW_ContentBlockWrapperTest {
@TestSetup
static void makeData(){
// Samlple content data for testing methods
GGW_TestDataFactory.createGrantContentTestData();

String uniqueUserName = 'grantuser' + DateTime.now().getTime() + '@labsorg.com';
// This code runs as the system user
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];

PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GGW_User_Permissions'];

User u = new User(Alias = 'standt', Email='[email protected]',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles',
UserName=uniqueUserName);
insert u;

insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id);
}

@isTest
static void testBlockWrapperConstructors(){

// This code runs as the Grant Guide User with GGW Permission Set from the TestSetup makeData() method.
User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey,
LocaleSidKey, ProfileId, TimeZoneSidKey, UserName
FROM User WHERE Email = '[email protected]' AND Alias='standt' LIMIT 1];

System.runAs(u) {

//Create sample data
GGW_TestDataFactory.createGrantContentTestData();

List<GGW_Content_Block__c> cbList = [SELECT Id, Name, Description__c, Short_Description__c,
Section__c, Section__r.Name, CreatedDate,
Language__c
Expand All @@ -33,6 +57,7 @@ public class GGW_ContentBlockWrapperTest {
System.assertEquals(2, textBlock.totalblocks, 'Expected total block 2 did not match');
System.assertEquals(firstBlock.Name, textBlock.title, 'Expected block name to tile did not match');
System.assertEquals(firstBlock.Section__c, textBlock.sectionid, 'Block parent section not valid');
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion force-app/main/default/classes/GGW_ExportCtrl.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
44 changes: 40 additions & 4 deletions force-app/main/default/classes/GGW_ExportCtrlTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,36 @@
public class GGW_ExportCtrlTest {
@TestSetup
static void makeData(){
// Create test sections
// Samlple content data for testing methods
GGW_TestDataFactory.createGrantContentTestData();

String uniqueUserName = 'grantuser' + DateTime.now().getTime() + '@labsorg.com';
// This code runs as the system user
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];

PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GGW_User_Permissions'];

User u = new User(Alias = 'standt', Email='[email protected]',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles',
UserName=uniqueUserName);
insert u;

insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id);
}

@isTest
static void testExportCtrl(){

// This code runs as the Grant Guide User with GGW Permission Set from the TestSetup makeData() method.
User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey,
LocaleSidKey, ProfileId, TimeZoneSidKey, UserName
FROM User WHERE Email = '[email protected]' AND Alias='standt' LIMIT 1];

System.runAs(u) {

//Create sample data
GGW_TestDataFactory.createGrantContentTestData();

// Unit test for conroller extention when used as part of record page context
// Query all suggested sections
List<GGW_SectionWrapper> lst = GGW_ApplicationCtrl.getSections();
Expand All @@ -41,10 +64,22 @@ public class GGW_ExportCtrlTest {
System.assertEquals(app.Name, grantExportController.appName, 'Grant name selected for export does not exist - MyTest Grant');
// 3 section expected to be added to grand
System.assertEquals(3, grantExportController.items.size(), 'Grant expected 3 items for export, size did not match test.');
}
}
}

@isTest
static void testExportWithPage(){

// This code runs as the Grant Guide User with GGW Permission Set from the TestSetup makeData() method.
User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey,
LocaleSidKey, ProfileId, TimeZoneSidKey, UserName
FROM User WHERE Email = '[email protected]' AND Alias='standt' LIMIT 1];

System.runAs(u) {

//Create sample data
GGW_TestDataFactory.createGrantContentTestData();

// Unit test for conroller extention when NOT Record page but pass parameter recordId
// Query all suggested sections
List<GGW_SectionWrapper> lst = GGW_ApplicationCtrl.getSections();
Expand All @@ -70,5 +105,6 @@ public class GGW_ExportCtrlTest {

System.assertEquals(null, grantExportController.recordId, 'Negative test with empty Grant for export expected null value');
System.assertEquals('This view requires a Grant record, missing.', grantExportController.appName, 'Negative test empty Grant expect missing name error message');
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
26 changes: 24 additions & 2 deletions force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,34 @@
public class GGW_GrantApplicationWrapperTest {
@TestSetup
static void makeData(){
// Samlple content data for testing methods
GGW_TestDataFactory.createGrantContentTestData();

String uniqueUserName = 'grantuser' + DateTime.now().getTime() + '@labsorg.com';
// This code runs as the system user
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];

PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GGW_User_Permissions'];

User u = new User(Alias = 'standt', Email='[email protected]',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles',
UserName=uniqueUserName);
insert u;

insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id);

}

@isTest
static void testGrantApplicationWrapperConstructor(){

// This code runs as the Grant Guide User with GGW Permission Set from the TestSetup makeData() method.
User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey,
LocaleSidKey, ProfileId, TimeZoneSidKey, UserName
FROM User WHERE Email = '[email protected]' AND Alias='standt' LIMIT 1];
System.runAs(u) {
// Samlple content data for testing methods
GGW_TestDataFactory.createGrantContentTestData();
Test.startTest();
GGW_GrantApplicationWrapper app = new GGW_GrantApplicationWrapper();
app.name = 'Test Grant';
Expand All @@ -28,5 +49,6 @@ public class GGW_GrantApplicationWrapperTest {
Test.stopTest();

System.assertNotEquals(null, app, 'Default constructor faild to create wrapper grant object');
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
</ApexClass>
2 changes: 1 addition & 1 deletion force-app/main/default/classes/GGW_SampleData.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading

0 comments on commit c8e6e54

Please sign in to comment.