diff --git a/.github/PULL_TEMPLATE/Pull_Request_Template.md b/.github/Pull_Request_Template.md similarity index 100% rename from .github/PULL_TEMPLATE/Pull_Request_Template.md rename to .github/Pull_Request_Template.md diff --git a/.github/workflows/beta_release.yml b/.github/workflows/beta_release.yml index 3fbef48..5936479 100644 --- a/.github/workflows/beta_release.yml +++ b/.github/workflows/beta_release.yml @@ -2,10 +2,12 @@ name: beta release on: workflow_dispatch: - -env: - CUMULUSCI_KEYCHAIN_CLASS: cumulusci.core.keychain.EnvironmentProjectKeychain - CUMULUSCI_SERVICE_github: ${{ secrets.CUMULUSCI_SERVICE_GITHUB }} + inputs: + versionName: + description: 'Name of release (e.g., Spring)' + required: true + + jobs: unit_tests: name: "Run Beta release" @@ -47,12 +49,12 @@ jobs: id: createPackageVersion run: | set +e - json=$(sf package version create -p "Grants Content Kit" -x -f config/project-scratch-def.json -w 10 -b main -c --json) + json=$(sf package version create -p "Grants Content Kit" -x -f config/project-scratch-def.json -a ${{ github.event.inputs.versionName}} -w 10 -b main -c --json) echo $json status=$(echo $json | jq '.status') if [ $status == "0" ]; then packageVersionId=$(echo $json | jq -r '.result.SubscriberPackageVersionId') - echo "::set-output name=packageVersionId::$packageVersionId" + echo "packageVersionId=$packageVersionId" >> $GITHUB_OUTPUT else echo "sf package creation failed" fi @@ -70,4 +72,26 @@ jobs: run: sf package install -p ${{ steps.createPackageVersion.outputs.packageVersionId }} -w 10 -o scratch-org -r # Housekeeping - name: 'Delete scratch org' - run: sf org delete scratch -p -o scratch-org \ No newline at end of file + run: sf org delete scratch -p -o scratch-org + + # Pull Request commit generated Package Id in sfdx-package.json file. + - name: Create Pull Request + id: create-pr + uses: peter-evans/create-pull-request@v6 + with: + title: 'Bump package version to ${{ steps.createPackageVersion.outputs.packageVersionId }}' + body: | + This pull request updates the package version to ${{ steps.createPackageVersion.outputs.packageVersionId }}. + branch: 'bump-package-version-${{ steps.createPackageVersion.outputs.packageVersionId }}' + commit-message: 'chore: bump package version to ${{ steps.createPackageVersion.outputs.packageVersionId }}' + labels: 'dependencies, automated pr' + token: ${{ secrets.GITHUB_TOKEN }} + + # Approve and mark PR for auto merge + - name: 'Approve and mark PR for auto merge' + run: | + gh pr review --approve "$PR_NUMBER" + gh pr merge --auto --squash --delete-branch "$PR_NUMBER" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ steps.create-pr.outputs.pull-request-number }} \ No newline at end of file diff --git a/.github/workflows/production_release.yml b/.github/workflows/production_release.yml new file mode 100644 index 0000000..1717fb1 --- /dev/null +++ b/.github/workflows/production_release.yml @@ -0,0 +1,57 @@ +name: Promote and release Salesforce package + +on: + workflow_dispatch: + inputs: + packageID: + description: 'ID (starts with 04t) of the package version to promote' + required: true + versionNumber: + description: 'Package version to release (e.g., 1.0.1 or 1.1.0)' + required: true + +jobs: + promote-sf-package: + runs-on: ubuntu-latest + + steps: + #Install Salesforce CLI + - name: 'Install Salesforce CLI' + run: | + npm install @salesforce/cli --location=global + nodeInstallPath=$(npm config get prefix) + echo "$nodeInstallPath/bin" >> $GITHUB_PATH + sf --version + + # Checkout the source code + - name: 'Checkout source code' + uses: actions/checkout@v4 + + # Store secret for dev hub + - name: 'Populate auth file with DEV_HUB_URL secret' + shell: bash + run: | + echo ${{ secrets.DEV_HUB_AUTH}} > ./DEV_HUB_AUTH.txt + secretFileSize=$(wc -c "./DEV_HUB_AUTH.txt" | awk '{print $1}') + if [ $secretFileSize == 1 ]; then + echo "Missing DEV_HUB_AUTH secret. Is this workflow running on a fork?"; + exit 1; + fi + + # Authenticate dev hub + - name: 'Authenticate Dev Hub' + run: sf org login sfdx-url -f ./DEV_HUB_AUTH.txt -a devhub -d + + # Remove auth file + - name: 'Remove auth file' + run: rm -f ./DEV_HUB_AUTH.txt + + # Promote Package version + - name: Run SFDX Promote command + run: sf package version promote --package ${{ github.event.inputs.packageID }} -n + + # Create release notes + - name: Create release + run: gh release create ${{ github.event.inputs.versionNumber }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.CUMULUSCI_SERVICE_GITHUB }} \ No newline at end of file diff --git a/README.md b/README.md index 1423a41..3b1f0b5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Create templates for your grant proposals with the Grants Content Kit! Grants Content Kit Resources: - [Documentation](https://github.com/Salesforce-org-Impact-Labs/GrantGuides/wiki) - [Trailblazer Group](https://trailhead.salesforce.com/trailblazer-community/groups/0F94S000000kJbMSAU?tab=discussion&sort=LAST_MODIFIED_DATE_DESC) -- [Intallation Instructions](https://github.com/Salesforce-org-Impact-Labs/GrantGuides/wiki#get-grants-content-kit) +- [Installation Instructions](https://github.com/Salesforce-org-Impact-Labs/GrantGuides/wiki#get-grants-content-kit) ## Community Sprints diff --git a/config/project-scratch-def.json b/config/project-scratch-def.json index 9922ac6..2566341 100644 --- a/config/project-scratch-def.json +++ b/config/project-scratch-def.json @@ -1,7 +1,7 @@ { "orgName": "Salesforce Impact Labs", "edition": "Developer", - "features": ["EnableSetPasswordInApi","AuthorApex", "EinsteinHawkingC2CEnabled", "EinsteinGPT"], + "features": ["EnableSetPasswordInApi","AuthorApex"], "settings": { "lightningExperienceSettings": { "enableS1DesktopEnabled": true diff --git a/cumulusci.yml b/cumulusci.yml index 4324e65..89968bb 100644 --- a/cumulusci.yml +++ b/cumulusci.yml @@ -3,6 +3,7 @@ project: name: GrantGuides package: name: ggw + namespace: GCKit api_version: '55.0' git: default_branch: 'main' diff --git a/force-app/main/default/classes/GGW_ApplicationCtrl.cls b/force-app/main/default/classes/GGW_ApplicationCtrl.cls index 38d104b..2fa2d4c 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrl.cls +++ b/force-app/main/default/classes/GGW_ApplicationCtrl.cls @@ -7,7 +7,7 @@ * GGW_ApplicationCtrl controller class support GGW. * */ -public without sharing class GGW_ApplicationCtrl { +public with sharing class GGW_ApplicationCtrl { public static String ggGtSteObj = GGW_Grant_State__c.sobjecttype.getDescribe().getName(); public static String ggGtStLanField = GGW_Grant_State__c.Language__c.getDescribe().getName(); // -- START LWC CONtroller Methods diff --git a/force-app/main/default/classes/GGW_ApplicationCtrl.cls-meta.xml b/force-app/main/default/classes/GGW_ApplicationCtrl.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrl.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ApplicationCtrl.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls index b80f417..615adca 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls +++ b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls @@ -11,12 +11,36 @@ public class GGW_ApplicationCtrlTest { @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='grantuser@labsorg.com', + 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 includeLogoTest(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -36,8 +60,20 @@ public class GGW_ApplicationCtrlTest { GGW_GrantApplicationWrapper grant = GGW_ApplicationCtrl.getApplication(app.Id); System.assertEquals(app.Id, grant.recordid, 'Invalid grant application Id'); System.assertEquals(true, grant.logostate, 'Logo include state is not valid'); + } } + static void excludeLogoTest(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -45,6 +81,7 @@ public class GGW_ApplicationCtrlTest { if(gww.selected){ sections.add(gww.recordid); } + } GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('MyTest Grant', sections); @@ -57,10 +94,22 @@ public class GGW_ApplicationCtrlTest { GGW_GrantApplicationWrapper grant = GGW_ApplicationCtrl.getApplication(app.Id); System.assertEquals(app.Id, grant.recordid, 'Invalid grant application Id'); System.assertEquals(false, grant.logostate, 'Logo exclude state is not valid'); + } } @isTest static void deleteLogoTest(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -98,10 +147,20 @@ public class GGW_ApplicationCtrlTest { Test.stopTest(); System.assertEquals('Logo image deleted', result, 'Logo delete is not valid'); - + } } @isTest static void createContentDistributionTest(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -130,10 +189,20 @@ public class GGW_ApplicationCtrlTest { System.assertNotEquals(null, downloadURL, 'Contenet distribution is invalid'); GGW_GrantApplicationWrapper grant = GGW_ApplicationCtrl.getApplication(app.Id); System.assertEquals(downloadURL, grant.logodisplayurl, 'Logo download URL is not valid'); - + } } @isTest static void testNewGrant(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -155,9 +224,21 @@ public class GGW_ApplicationCtrlTest { List selectedItems = [SELECT Id, Name, Grant_Application__c, GGW_Section__c, Sort_Order__c FROM GGW_Selected_Item__c WHERE Grant_Application__c =:app.Id]; System.assertEquals(sections.size(), selectedItems.size(), 'Clone for grant sections to items did not complete'); + } } @isTest static void testFindSections(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + String searchKey = 'Test'; Test.startTest(); List sw = GGW_ApplicationCtrl.findSections(searchKey); @@ -170,16 +251,40 @@ public class GGW_ApplicationCtrlTest { searchKey = 'fail'; List swfail = GGW_ApplicationCtrl.findSections(searchKey); System.assertEquals(0, swfail.size(), 'Section search for hidden section did not return valid data'); + } } @isTest static void testGetSections(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + Test.startTest(); List sw = GGW_ApplicationCtrl.getSections(); Test.stopTest(); System.assertEquals(3, sw.size(), 'No sample section data found'); + } } @isTest static void testContentBlocks(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + List sectionList = [SELECT Id, Name FROM GGW_Section__c WHERE Name = 'Statement of need']; String sectionid = sectionList[0].Id; Test.startTest(); @@ -187,9 +292,21 @@ public class GGW_ApplicationCtrlTest { Test.stopTest(); // TODO add detailed assertions System.assertNotEquals(0, blockList.size(), 'No sample data content blocks are found'); + } } @isTest static void testAddTextBlockToLibrary(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + List sectionList = [SELECT Id, Name FROM GGW_Section__c WHERE Name = 'Statement of need']; String sectionid = sectionList[0].Id; String richtext = 'Adding new block text content to section to reuse. Example text'; @@ -201,9 +318,20 @@ public class GGW_ApplicationCtrlTest { System.assertEquals('Test block', block.Name, 'Block name not matching'); System.assertEquals(str, block.Id, 'No Block ID found'); System.assertEquals(sectionList[0].Id, block.Section__c, 'Block link to Section missing'); - } + } + } @isTest static void testCreateNewSection(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + String name = 'Test section'; Test.startTest(); GGW_SectionWrapper sw = GGW_ApplicationCtrl.createNewSection(name); @@ -218,10 +346,21 @@ public class GGW_ApplicationCtrlTest { System.assertEquals(newSec.Recommended__c,sw.selected, 'Recommended section vs selected not matching'); System.assertEquals(true, newSec.Recommended__c, 'Default recommended section not valid'); System.assertEquals(true, newSec.Suggested__c, 'Default suggested section not set'); + } } @isTest static void testGetApplication(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -241,9 +380,20 @@ public class GGW_ApplicationCtrlTest { System.assertEquals('In Progress', appWrapper.status, 'Default grant status did not match expected - In Progress'); // Check selected Items created as content blocks wraper to number of sections System.assertEquals(sections.size(),appWrapper.selectedContentBlock.size(), 'The copy of created blocks from template did not match expected number'); - } + } + } @isTest static void testSaveSelectedSectionText(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -266,9 +416,20 @@ public class GGW_ApplicationCtrlTest { // assertion checks that item saved the Block text List savedItemList = GGW_SectionSelector.querySelectedItemsByGrant(app.Id); System.assertEquals(blocktext, savedItemList[0].Text_Block__c, 'Block text did not match template'); - } + } + } @isTest static void testReorderSections(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -296,9 +457,20 @@ public class GGW_ApplicationCtrlTest { List selOrderedList = GGW_SectionSelector.querySelectedItemsByGrant(app.Id); System.assertEquals(last, selOrderedList[0].Id, 'Last seleected section item did not match expected'); System.assertEquals(first, selOrderedList[selOrderedList.size()-1].Id, 'First seleectd section item did not match selected'); - } + } + } @isTest static void testUpdateSelectedItemText(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -322,10 +494,21 @@ public class GGW_ApplicationCtrlTest { GGW_Selected_Item__c selItem = [SELECT Id, Name, Text_Block__c, GGW_Section__c, Grant_Application__c, Sort_Order__c FROM GGW_Selected_Item__c WHERE Id =:itemid]; System.assertEquals(richtext, selItem.Text_Block__c, 'Rich text in block not matching expected text'); - } + } + } @isTest static void testDeleteSectionItem(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -348,17 +531,40 @@ public class GGW_ApplicationCtrlTest { // Check that item was deleted System.assertEquals(sectionCount-1, newItemList.size(),'Assert failed DeleteSectionItem'); - } + } + } @isTest static void testGetSupportedLanguages(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + Test.startTest(); List pl = GGW_ApplicationCtrl.getSupportedLanguages(); Test.stopTest(); System.assertEquals(pl.size()>0, true, 'Supported langauges found'); + } } @isTest static void testGetLanguageSelection(){ - // Query all suggested sections + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); for (GGW_SectionWrapper gww : lst){ @@ -378,9 +584,20 @@ public class GGW_ApplicationCtrlTest { // NO application ID System.assertEquals(strNoApp, 'en_US', 'Negative test failed to get language selectino'); System.assertEquals(strLngWire, 'en_US', 'Failed to get application language in wired method'); - } + } + } @isTest static void testSaveLanguageSelection(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -398,5 +615,6 @@ public class GGW_ApplicationCtrlTest { System.assertEquals(str, 'NEW Language state is inserted', 'Language select was not saved'); String lang = GGW_ApplicationCtrl.getLanguageSelection(app.Id); System.assertEquals(lang, 'en_US', 'Failed to get saved language'); + } } } diff --git a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls-meta.xml b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/classes/GGW_ApplicationSelector.cls-meta.xml b/force-app/main/default/classes/GGW_ApplicationSelector.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_ApplicationSelector.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ApplicationSelector.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls b/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls index c62d2f6..85e32f7 100644 --- a/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls +++ b/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls @@ -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='grantuser@labsorg.com', + 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -63,5 +100,6 @@ private class GGW_ApplicationSelectorTest { List grantList = GGW_ApplicationSelector.getGrantApplications(); Test.stopTest(); System.assertEquals(2, grantList.size(), 'Query grant application invalid'); - } + } + } } \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls-meta.xml b/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ApplicationSelectorTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml b/force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentBlockWrapper.cls-meta.xml b/force-app/main/default/classes/GGW_ContentBlockWrapper.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_ContentBlockWrapper.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ContentBlockWrapper.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls b/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls index 13c6ec1..cd19408 100644 --- a/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls +++ b/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls @@ -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='grantuser@labsorg.com', + 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + List cbList = [SELECT Id, Name, Description__c, Short_Description__c, Section__c, Section__r.Name, CreatedDate, Language__c @@ -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'); - } + } + } } \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls-meta.xml b/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ContentBlockWrapperTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml b/force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ExportCtrl.cls b/force-app/main/default/classes/GGW_ExportCtrl.cls index 16175b5..6ae39b9 100644 --- a/force-app/main/default/classes/GGW_ExportCtrl.cls +++ b/force-app/main/default/classes/GGW_ExportCtrl.cls @@ -7,7 +7,7 @@ * GGW_ExportCtrl controller class for VFP Export and render. * Standard controller extension used for Standard record page action */ -public without sharing class GGW_ExportCtrl { +public with sharing class GGW_ExportCtrl { public String recordId {get; set;} public String appName {get;set;} public String logoURL {get; set;} diff --git a/force-app/main/default/classes/GGW_ExportCtrl.cls-meta.xml b/force-app/main/default/classes/GGW_ExportCtrl.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_ExportCtrl.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ExportCtrl.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/classes/GGW_ExportCtrlTest.cls b/force-app/main/default/classes/GGW_ExportCtrlTest.cls index f7c567a..fa10f72 100644 --- a/force-app/main/default/classes/GGW_ExportCtrlTest.cls +++ b/force-app/main/default/classes/GGW_ExportCtrlTest.cls @@ -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='grantuser@labsorg.com', + 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 = 'grantuser@labsorg.com' 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 lst = GGW_ApplicationCtrl.getSections(); @@ -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 = 'grantuser@labsorg.com' 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 lst = GGW_ApplicationCtrl.getSections(); @@ -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'); + } } } diff --git a/force-app/main/default/classes/GGW_ExportCtrlTest.cls-meta.xml b/force-app/main/default/classes/GGW_ExportCtrlTest.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_ExportCtrlTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_ExportCtrlTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls-meta.xml b/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls-meta.xml +++ b/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls b/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls index 2214103..1394d48 100644 --- a/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls +++ b/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls @@ -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='grantuser@labsorg.com', + 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 = 'grantuser@labsorg.com' 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'; @@ -28,5 +49,6 @@ public class GGW_GrantApplicationWrapperTest { Test.stopTest(); System.assertNotEquals(null, app, 'Default constructor faild to create wrapper grant object'); + } } } \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls-meta.xml b/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls-meta.xml index 642d054..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_GrantApplicationWrapperTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active - \ No newline at end of file + diff --git a/force-app/main/default/classes/GGW_SampleData.cls-meta.xml b/force-app/main/default/classes/GGW_SampleData.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_SampleData.cls-meta.xml +++ b/force-app/main/default/classes/GGW_SampleData.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/classes/GGW_SampleDataTest.cls b/force-app/main/default/classes/GGW_SampleDataTest.cls index cf47e35..d1387ab 100644 --- a/force-app/main/default/classes/GGW_SampleDataTest.cls +++ b/force-app/main/default/classes/GGW_SampleDataTest.cls @@ -10,9 +10,32 @@ */ @IsTest public class GGW_SampleDataTest { + @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='grantuser@labsorg.com', + 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 testInsertSampleSections(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { // POSITIVE Test validation // Call this method to insert Sections & Content Block sample data Test.startTest(); @@ -25,10 +48,17 @@ public class GGW_SampleDataTest { System.assertEquals(10, lstSection.size(), 'Sections list is expected to have records'); List lstContentBlock = [SELECT Id, Name FROM GGW_Content_Block__c WITH SECURITY_ENFORCED]; System.assertEquals(13, lstContentBlock.size(), 'Block list is expected to have records'); + } } @isTest static void testInsertSampleSectionsWithExisting(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { // NEGATIVE Fail test validation // Create sample sections before test GGW_Section__c gs = new GGW_Section__c(); @@ -46,6 +76,6 @@ public class GGW_SampleDataTest { Test.stopTest(); System.assertNotEquals(null, str, 'Result string should not be null'); System.assertEquals('Section data already exists. IMPORT CANCELLED', str, 'Result string is expected as IMPORT CANCELED message'); - + } } } diff --git a/force-app/main/default/classes/GGW_SampleDataTest.cls-meta.xml b/force-app/main/default/classes/GGW_SampleDataTest.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_SampleDataTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_SampleDataTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml b/force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml +++ b/force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_SectionWrapper.cls-meta.xml b/force-app/main/default/classes/GGW_SectionWrapper.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_SectionWrapper.cls-meta.xml +++ b/force-app/main/default/classes/GGW_SectionWrapper.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_SectionWrapperTest.cls b/force-app/main/default/classes/GGW_SectionWrapperTest.cls index ad737f7..03f22fb 100644 --- a/force-app/main/default/classes/GGW_SectionWrapperTest.cls +++ b/force-app/main/default/classes/GGW_SectionWrapperTest.cls @@ -11,12 +11,35 @@ public class GGW_SectionWrapperTest { @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='grantuser@labsorg.com', + 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 testSectionWrapperConstructors(){ + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + List sectionList = [SELECT Id, Name, CreatedDate, Recommended__c, Suggested__c, Sort_Order__c, Language__c FROM GGW_Section__c @@ -34,6 +57,6 @@ public class GGW_SectionWrapperTest { System.assertNotEquals(null, swBlock, 'Default constructor faild to create wrapper section object'); System.assertEquals(firstSection.Name, swSection.label, 'Default constructor section label name not valid'); System.assertEquals(true, swSection.hasblocks, 'Default constructor section has no blocks'); - + } } } \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_SectionWrapperTest.cls-meta.xml b/force-app/main/default/classes/GGW_SectionWrapperTest.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_SectionWrapperTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_SectionWrapperTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_TestDataFactory.cls-meta.xml b/force-app/main/default/classes/GGW_TestDataFactory.cls-meta.xml index 642d054..3a10d2e 100644 --- a/force-app/main/default/classes/GGW_TestDataFactory.cls-meta.xml +++ b/force-app/main/default/classes/GGW_TestDataFactory.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_Util.cls b/force-app/main/default/classes/GGW_Util.cls index 5f24bbc..70d894d 100644 --- a/force-app/main/default/classes/GGW_Util.cls +++ b/force-app/main/default/classes/GGW_Util.cls @@ -8,7 +8,7 @@ * GGW_Util class for support utility methods on Grant application. * Used by standard and Custom controller */ -public without sharing class GGW_Util { +public with sharing class GGW_Util { public static String ggGtSteObj = GGW_Grant_State__c.sobjecttype.getDescribe().getName(); public static String ggGtStLanField = GGW_Grant_State__c.Language__c.getDescribe().getName(); diff --git a/force-app/main/default/classes/GGW_Util.cls-meta.xml b/force-app/main/default/classes/GGW_Util.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_Util.cls-meta.xml +++ b/force-app/main/default/classes/GGW_Util.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/classes/GGW_UtilTest.cls b/force-app/main/default/classes/GGW_UtilTest.cls index c2e70c2..da2c37f 100644 --- a/force-app/main/default/classes/GGW_UtilTest.cls +++ b/force-app/main/default/classes/GGW_UtilTest.cls @@ -13,13 +13,13 @@ public class GGW_UtilTest { @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='grantuser@labsorg.com', EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id, @@ -27,10 +27,22 @@ public class GGW_UtilTest { UserName=uniqueUserName); insert u; + insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id); } @isTest static void testNewsaveGrantState(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -40,14 +52,6 @@ public class GGW_UtilTest { } } - // This code runs as the system user - PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GGW_User_Permissions']; - User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey, - LocaleSidKey, ProfileId, TimeZoneSidKey, UserName - FROM User WHERE Email = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; - insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id); - - System.runAs(u) { GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('Grant App', sections); Test.startTest(); @@ -70,6 +74,18 @@ public class GGW_UtilTest { @isTest static void testExistingGrantState(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -78,14 +94,6 @@ public class GGW_UtilTest { sections.add(gww.recordid); } } - // This code runs as the system user - PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GGW_User_Permissions']; - User u = [SELECT Alias, Email, EmailEncodingKey, LastName, LanguageLocaleKey, - LocaleSidKey, ProfileId, TimeZoneSidKey, UserName - FROM User WHERE Email = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; - insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id); - - System.runAs(u) { GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('Grant App', sections); GGW_Util.saveGrantState(app.Id); @@ -102,6 +110,17 @@ public class GGW_UtilTest { @isTest static void testGetSelectedItems(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + // Query all suggested sections List lst = GGW_ApplicationCtrl.getSections(); List sections = new List(); @@ -116,10 +135,22 @@ public class GGW_UtilTest { List lstItems = GGW_Util.getSelectedItems(app.Id); Test.stopTest(); System.assertEquals(sections.size(), lstItems.size(), 'Grant app missing selected items'); - + } } @isTest static void testSelectOptionFromPicklist(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + + Test.startTest(); List picList = GGW_Util.getSelectOptionFromPicklist(ggGtSteObj, ggGtStLanField, true); Test.stopTest(); @@ -132,9 +163,22 @@ public class GGW_UtilTest { } } System.assertEquals(lcode, 'en_US', 'Supported Language not found in metadata'); + } } @isTest static void testToLanguageLabel(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + + Test.startTest(); // Translate ISO language code to language label en_US -> English String lang = GGW_Util.toLanguageLabel('en_US'); @@ -143,9 +187,21 @@ public class GGW_UtilTest { Test.stopTest(); System.assertEquals(lang, 'English', 'No language label found for code en_US'); System.assertEquals(lang, 'English', 'No language label found for code pi_NG'); // Defalt to English + } } @isTest static void testGetValueMapFromPicklist(){ + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + + System.runAs(u) { + + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + Test.startTest(); Map valMap = GGW_Util.getValueMapFromPicklist(ggGtSteObj, ggGtStLanField); Test.stopTest(); @@ -154,27 +210,30 @@ public class GGW_UtilTest { String ln = valMap.get('en_US'); System.assertEquals(ln, 'English', 'No language label found for code en_US'); } + } } @isTest static void saveGrantLanguage(){ - // Query all suggested sections - List lst = GGW_ApplicationCtrl.getSections(); - List sections = new List(); - for (GGW_SectionWrapper gww : lst){ - if(gww.selected){ - sections.add(gww.recordid); - } - } - - // This code runs as the system user - PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GGW_User_Permissions']; + + // 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 = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; - insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id); - + LocaleSidKey, ProfileId, TimeZoneSidKey, UserName + FROM User WHERE Email = 'grantuser@labsorg.com' AND Alias='standt' LIMIT 1]; + System.runAs(u) { + //Create sample data + GGW_TestDataFactory.createGrantContentTestData(); + + // Query all suggested sections + List lst = GGW_ApplicationCtrl.getSections(); + List sections = new List(); + for (GGW_SectionWrapper gww : lst){ + if(gww.selected){ + sections.add(gww.recordid); + } + } + GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('Grant App', sections); Test.startTest(); String str = GGW_Util.saveGrantLanguage('en_US', app.Id); diff --git a/force-app/main/default/classes/GGW_UtilTest.cls-meta.xml b/force-app/main/default/classes/GGW_UtilTest.cls-meta.xml index 7a51829..f5e18fd 100644 --- a/force-app/main/default/classes/GGW_UtilTest.cls-meta.xml +++ b/force-app/main/default/classes/GGW_UtilTest.cls-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 Active diff --git a/force-app/main/default/lwc/ggwActionConfirmModal/ggwActionConfirmModal.js-meta.xml b/force-app/main/default/lwc/ggwActionConfirmModal/ggwActionConfirmModal.js-meta.xml index ed8c872..73bb9a8 100644 --- a/force-app/main/default/lwc/ggwActionConfirmModal/ggwActionConfirmModal.js-meta.xml +++ b/force-app/main/default/lwc/ggwActionConfirmModal/ggwActionConfirmModal.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true Ggw action confirm modal diff --git a/force-app/main/default/lwc/ggwContentBlockModal/ggwContentBlockModal.js-meta.xml b/force-app/main/default/lwc/ggwContentBlockModal/ggwContentBlockModal.js-meta.xml index 1cda26c..58de161 100644 --- a/force-app/main/default/lwc/ggwContentBlockModal/ggwContentBlockModal.js-meta.xml +++ b/force-app/main/default/lwc/ggwContentBlockModal/ggwContentBlockModal.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true Ggw content block modal diff --git a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js-meta.xml b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js-meta.xml index f78d114..9226ad9 100644 --- a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js-meta.xml +++ b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true Ggw grant application Grant Application editor diff --git a/force-app/main/default/lwc/ggwIntro/ggwIntro.js-meta.xml b/force-app/main/default/lwc/ggwIntro/ggwIntro.js-meta.xml index 17a09ab..356d6a8 100644 --- a/force-app/main/default/lwc/ggwIntro/ggwIntro.js-meta.xml +++ b/force-app/main/default/lwc/ggwIntro/ggwIntro.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true Ggw intro diff --git a/force-app/main/default/lwc/ggwLanguageDisplay/ggwLanguageDisplay.js-meta.xml b/force-app/main/default/lwc/ggwLanguageDisplay/ggwLanguageDisplay.js-meta.xml index b9bdc37..aa841f7 100644 --- a/force-app/main/default/lwc/ggwLanguageDisplay/ggwLanguageDisplay.js-meta.xml +++ b/force-app/main/default/lwc/ggwLanguageDisplay/ggwLanguageDisplay.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true Ggw language display diff --git a/force-app/main/default/lwc/ggwLanguageSelector/ggwLanguageSelector.js-meta.xml b/force-app/main/default/lwc/ggwLanguageSelector/ggwLanguageSelector.js-meta.xml index 09aa516..5ace513 100644 --- a/force-app/main/default/lwc/ggwLanguageSelector/ggwLanguageSelector.js-meta.xml +++ b/force-app/main/default/lwc/ggwLanguageSelector/ggwLanguageSelector.js-meta.xml @@ -1,6 +1,6 @@ - 58.0 + 60.0 true Languga Selector diff --git a/force-app/main/default/lwc/ggwNewApplication/ggwNewApplication.js-meta.xml b/force-app/main/default/lwc/ggwNewApplication/ggwNewApplication.js-meta.xml index 9664297..f3742ce 100644 --- a/force-app/main/default/lwc/ggwNewApplication/ggwNewApplication.js-meta.xml +++ b/force-app/main/default/lwc/ggwNewApplication/ggwNewApplication.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true New Grant Application diff --git a/force-app/main/default/lwc/ggwOrderSections/ggwOrderSections.js-meta.xml b/force-app/main/default/lwc/ggwOrderSections/ggwOrderSections.js-meta.xml index 25e49a4..031d953 100644 --- a/force-app/main/default/lwc/ggwOrderSections/ggwOrderSections.js-meta.xml +++ b/force-app/main/default/lwc/ggwOrderSections/ggwOrderSections.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true Ggw order sections Compoenet shows list of sections and allow to reorder by setting order values for each. diff --git a/force-app/main/default/lwc/ggwSection/ggwSection.js-meta.xml b/force-app/main/default/lwc/ggwSection/ggwSection.js-meta.xml index cea07f0..cd1fbcb 100644 --- a/force-app/main/default/lwc/ggwSection/ggwSection.js-meta.xml +++ b/force-app/main/default/lwc/ggwSection/ggwSection.js-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 true Ggw section diff --git a/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml index 936a043..04f9de9 100644 --- a/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml +++ b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml @@ -1,5 +1,5 @@ - 52.0 + 60.0 true Ggw static no data card diff --git a/force-app/main/default/pages/GGW_GrantPreview.page-meta.xml b/force-app/main/default/pages/GGW_GrantPreview.page-meta.xml index 077ed01..ff7079b 100644 --- a/force-app/main/default/pages/GGW_GrantPreview.page-meta.xml +++ b/force-app/main/default/pages/GGW_GrantPreview.page-meta.xml @@ -1,6 +1,6 @@ - 58.0 + 60.0 true false diff --git a/force-app/main/default/pages/GGW_GrantPreviewPdf.page-meta.xml b/force-app/main/default/pages/GGW_GrantPreviewPdf.page-meta.xml index 39f1e17..c224243 100644 --- a/force-app/main/default/pages/GGW_GrantPreviewPdf.page-meta.xml +++ b/force-app/main/default/pages/GGW_GrantPreviewPdf.page-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 \ No newline at end of file diff --git a/force-app/main/default/pages/GGW_GrantPreviewWord.page-meta.xml b/force-app/main/default/pages/GGW_GrantPreviewWord.page-meta.xml index e96afb1..9d415d5 100644 --- a/force-app/main/default/pages/GGW_GrantPreviewWord.page-meta.xml +++ b/force-app/main/default/pages/GGW_GrantPreviewWord.page-meta.xml @@ -1,5 +1,5 @@ - 58.0 + 60.0 \ No newline at end of file diff --git a/gckitunlocked/sfdx-project.json b/gckitunlocked/sfdx-project.json new file mode 100644 index 0000000..18df267 --- /dev/null +++ b/gckitunlocked/sfdx-project.json @@ -0,0 +1,32 @@ +{ + "packageDirectories": [ + { + "path": "force-app", + "default": true, + "package": "Grants Content Kit", + "versionNumber": "3.0.0.NEXT", + "apexTestAccess": { + "permissionSets": [ + "GGW_User_Permissions" + ] + } + } + ], + "name": "Grants Content Kit", + "namespace": "", + "sfdcLoginUrl": "https://login.salesforce.com", + "sourceApiVersion": "54.0", + "packageAliases": { + "Grants Content Kit": "0Ho8a000000fxV5CAI", + "Grants Content Kit@0.1.0-1": "04t8a000001aJXYAA2", + "Grants Content Kit@0.1.0-2": "04t8a000001aJYWAA2", + "Grants Content Kit@0.1.0-3-main": "04t8a000001B8qcAAC", + "Grants Content Kit@0.1.0-4-main": "04t8a000001B8qhAAC", + "Grants Content Kit@0.1.0-5-main": "04t8a000001B8qmAAC", + "Grants Content Kit@1.0.0-1-main": "04t8a000001B8qrAAC", + "Grants Content Kit@1.0.0-2-main": "04t8a000001B8vnAAC", + "Grants Content Kit@2.0.0-1-main": "04t8a000001B8vsAAC", + "Grants Content Kit@2.1.0-1-main": "04t8a000000qq4HAAQ", + "Grants Content Kit@3.0.0-1-main": "04t8a000000qqHcAAI" + } +} \ No newline at end of file diff --git a/sfdx-project.json b/sfdx-project.json index 3541dee..8da8896 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -3,9 +3,6 @@ { "path": "force-app", "default": true, - "package": "Grants Content Kit", - "versionName": "Winter 24", - "versionNumber": "2.1.0.NEXT", "apexTestAccess": { "permissionSets": [ "GGW_User_Permissions" @@ -14,19 +11,6 @@ } ], "name": "Grants Content Kit", - "namespace": "", "sfdcLoginUrl": "https://login.salesforce.com", - "sourceApiVersion": "54.0", - "packageAliases": { - "Grants Content Kit": "0Ho8a000000fxV5CAI", - "Grants Content Kit@0.1.0-1": "04t8a000001aJXYAA2", - "Grants Content Kit@0.1.0-2": "04t8a000001aJYWAA2", - "Grants Content Kit@0.1.0-3-main": "04t8a000001B8qcAAC", - "Grants Content Kit@0.1.0-4-main": "04t8a000001B8qhAAC", - "Grants Content Kit@0.1.0-5-main": "04t8a000001B8qmAAC", - "Grants Content Kit@1.0.0-1-main": "04t8a000001B8qrAAC", - "Grants Content Kit@1.0.0-2-main": "04t8a000001B8vnAAC", - "Grants Content Kit@2.0.0-1-main": "04t8a000001B8vsAAC", - "Grants Content Kit@2.1.0-1-main": "04t8a000000qq4HAAQ" - } + "sourceApiVersion": "54.0" } \ No newline at end of file