Skip to content

Commit

Permalink
Merge pull request #561 from SFDO-Community/april24_unit_test_updates
Browse files Browse the repository at this point in the history
April24 unit test updates
  • Loading branch information
rdblake21 authored Apr 12, 2024
2 parents 240a5fa + a7d8a20 commit 5d967b3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tasks:
description: Makes fake account data to mimic schools with Education as industry
class_path: cumulusci.tasks.bulkdata.snowfakery.Snowfakery
options:
recipe: datasets/snowfackery/school_recipe.yml
recipe: datasets/snowfakery/school_recipe.yml

deploy_guest_sharing_rules:
description: Deploys configuration for Development.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public with sharing class SummitEventsCancelReviewController {

eventInstance = [
SELECT Id, Instance_Title__c, Instance_Start_Date__c, Instance_End_Date__c, Instance_Start_Time__c, Instance_End_Time__c, Instance_Time_Zone__c,
Registration_Close_Date__c, Current_Available_Capacity__c, Active_Status__c
Registration_Close_Date__c, Current_Available_Capacity__c, Active_Status__c, Registration_Close_Time__c
FROM Summit_Events_Instance__c W
WHERE Id = :eventRegistration.Event_Instance__c
WITH SECURITY_ENFORCED
Expand Down
23 changes: 13 additions & 10 deletions force-app/test/default/classes/SummitEventsAddToCalendar_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SummitEventsAddToCalendar_TEST {
@IsTest
static void testIcsFileGeneration() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User','Summit_Events_Registrant');
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
System.runAs(testUser) {
Test.startTest();
PageReference pageRef = Page.SummitEventsAddToCalendar;
Expand All @@ -24,7 +24,7 @@ public class SummitEventsAddToCalendar_TEST {
@IsTest
static void testForNullReturns() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User','Summit_Events_Registrant');
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
System.runAs(testUser) {
Test.startTest();
SummitEventsAddToCalendarController calendarController = new SummitEventsAddToCalendarController();
Expand All @@ -37,7 +37,7 @@ public class SummitEventsAddToCalendar_TEST {
@IsTest
static void testGoogleCalendarLink() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User','Summit_Events_Registrant');
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
System.runAs(testUser) {
Test.startTest();
PageReference pageRef = Page.SummitEventsAddToCalendar;
Expand All @@ -48,7 +48,7 @@ public class SummitEventsAddToCalendar_TEST {
SummitEventsAddToCalendarController calendarController = new SummitEventsAddToCalendarController();
String startDate = calendarController.DTStart;
String endDate = calendarController.DTEnd;
String comparePageReference = 'https://www.google.com/calendar/event?action=TEMPLATE&ctz=America%2FChicago&dates=' + startDate + '%2F' + endDate + '&details=&location=123+Electric+Ave.&sprop=%5Bevent_source_url%5DMap+Link+1&text=Test+Event+-+Test+Event+Session+0';
String comparePageReference = 'https://www.google.com/calendar/event?action=TEMPLATE&ctz=GMT&dates=' + startDate + '%2F' + endDate + '&details=&location=123+Electric+Ave.&sprop=%5Bevent_source_url%5DMap+Link+1&text=Test+Event+-+Test+Event+Session+0';
system.assertEquals(calendarController.calendarType().getUrl(), comparePageReference);
Test.stopTest();
}
Expand All @@ -57,7 +57,7 @@ public class SummitEventsAddToCalendar_TEST {
@IsTest
static void testYahooCalendarLink() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User','Summit_Events_Registrant');
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
System.runAs(testUser) {
Test.startTest();
PageReference pageRef = Page.SummitEventsAddToCalendar;
Expand All @@ -67,16 +67,16 @@ public class SummitEventsAddToCalendar_TEST {
SummitEventsAddToCalendarController calendarController = new SummitEventsAddToCalendarController();
String startDate = calendarController.DTStart;
String endDate = calendarController.DTEnd;
String testCalendarURL = 'https://calendar.yahoo.com?desc=&et=' + endDate + '&in_csz=America%2FChicago&in_loc=A+location&in_st=123+Electric+Ave.&st=' + startDate + '&title=Test+Event+-+Test+Event+Session+0&v=60';
system.assertEquals(calendarController.calendarType().getUrl(), testCalendarURL);
String testCalendarURL = 'https://calendar.yahoo.com?desc=&et=' + endDate + '&in_csz=GMT&in_loc=A+location&in_st=123+Electric+Ave.&st=' + startDate + '&title=Test+Event+-+Test+Event+Session+0&v=60';
System.assertEquals(calendarController.calendarType().getUrl(), testCalendarURL);
Test.stopTest();
}
}

@IsTest
static void testICalIcs() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User','Summit_Events_Registrant');
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
System.runAs(testUser) {
Test.startTest();
PageReference pageRef = Page.SummitEventsAddToCalendar;
Expand All @@ -92,7 +92,7 @@ public class SummitEventsAddToCalendar_TEST {
@IsTest
static void testOutlookIcs() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User','Summit_Events_Registrant');
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
System.runAs(testUser) {
Test.startTest();
PageReference pageRef = Page.SummitEventsAddToCalendar;
Expand All @@ -108,7 +108,10 @@ public class SummitEventsAddToCalendar_TEST {
@IsTest
static void testOutlookWeb() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User','Summit_Events_Registrant');
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
//Change from GMT to CDT to test daylight savings works
seaTestInstances[1].Instance_Time_Zone__c = 'Central Daylight Time (America/Chicago)';
update seaTestInstances;
System.runAs(testUser) {
Test.startTest();
PageReference pageRef = Page.SummitEventsAddToCalendar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,13 @@ private class SummitEventsConfirmation_TEST {
@IsTest static void testAdminOpen() {
SummitEventsTestSharedDataFactory.createContact('TestFirst1', 'TestLast1', '[email protected]', '55418', '(555) 555-5555', '1971-03-22');
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
Summit_Events_Registration__c seaTestRegistration = SummitEventsTestSharedDataFactory.createEventRegistration(seaTestInstances[1], 'TestFirst', 'TestLast', '[email protected]', '55418', '1971-03-22', '2012', null);
Summit_Events_Registration__c seaTestRegistration = SummitEventsTestSharedDataFactory.createEventRegistration(seaTestInstances[2], 'TestFirst', 'TestLast', '[email protected]', '55418', '1971-03-22', '2012', null);
User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');

System.runAs(testUser) {
Test.startTest();
PageReference pageRef = Page.SummitEventsConfirmation;

Test.setCurrentPage(pageRef);
SummitEventsShared.createEncryptedCookie('Transfer', seaTestInstances[1].Id, seaTestInstances[1].Event__c, seaTestRegistration.Id, true);
SummitEventsShared.createEncryptedCookie('Transfer', seaTestInstances[2].Id, seaTestInstances[2].Event__c, seaTestRegistration.Id, true);
SummitEventsConfirmationController confirmCtrl = new SummitEventsConfirmationController();
confirmCtrl.checkEventDetails();
Summit_Events_Registration__c checkRegistrationStatus = [
Expand All @@ -97,6 +95,7 @@ private class SummitEventsConfirmation_TEST {
Summit_Events_Registration__c
WHERE Id = :seaTestRegistration.Id
];
Test.startTest();
System.assertEquals(checkRegistrationStatus.Status__c, 'Registered');
Test.stopTest();
}
Expand Down
12 changes: 6 additions & 6 deletions force-app/test/default/classes/SummitEventsFeed_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ private class SummitEventsFeed_TEST {
RestContext.response = res;
SummitEventsFeed.getSummitEventsFeed();
eventsList = (List<SummitEventsFeed.eventItem>) JSON.deserialize(res.responseBody.toString(), List<SummitEventsFeed.eventItem>.class);
System.assertEquals(eventsList.size(), 10, 'All 10 instance have program related to them.');
System.assertEquals(eventsList.size(), 11, 'All 11 instance have program related to them.');


req.params.put('program', 'OCB');
RestContext.request = req;
RestContext.response = res;
SummitEventsFeed.getSummitEventsFeed();
eventsList = (List<SummitEventsFeed.eventItem>) JSON.deserialize(res.responseBody.toString(), List<SummitEventsFeed.eventItem>.class);
System.assertEquals(eventsList.size(), 10, 'All 10 instance have program related to them.');
System.assertEquals(eventsList.size(), 11, 'All 11 instance have program related to them.');

//test filter
req.params.put('rectype', 'UDAR');
Expand All @@ -141,10 +141,10 @@ private class SummitEventsFeed_TEST {

@IsTest static void testEventFeedOverrides() {
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
seaTestInstances[1].Alternate_Registration_URL_Override__c = 'https://testingAnOverride.com';
seaTestInstances[1].Location_Address_Override__c = 'New location override';
seaTestInstances[1].Location_Map_Link_Override__c = 'Map link override';
seaTestInstances[1].Feed_Registration_Button_Text_Override__c = 'New button override';
seaTestInstances[2].Alternate_Registration_URL_Override__c = 'https://testingAnOverride.com';
seaTestInstances[2].Location_Address_Override__c = 'New location override';
seaTestInstances[2].Location_Map_Link_Override__c = 'Map link override';
seaTestInstances[2].Feed_Registration_Button_Text_Override__c = 'New button override';
update seaTestInstances;

User testUser = SummitEventsTestSharedDataFactory.userToRunWith('Standard User', 'Summit_Events_Registrant');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public with sharing class SummitEventsTestSharedDataFactory {
Name = 'Test Event',
Event_Status__c = 'Active',
Event_Name__c = 'Test Event',
Start_Date__c = Date.today().addDays(-20),
End_Date__c = Date.today().addDays(20),
Start_Date__c = Date.today().addDays(-30),
End_Date__c = Date.today().addDays(30),
Template__c = 'GeneralSLDS',
Close_Event_Days_Before__c = 0,
Location_Title__c = 'A location',
Expand All @@ -38,6 +38,7 @@ public with sharing class SummitEventsTestSharedDataFactory {
Location_Address__c = '123 Electric Ave.',
Location_Type__c = 'On-Site',
Allow_Other_Attendees__c = true,
Private_Event__c = false,
Max_Other_Attendees__c = 10
);
insert testEvent;
Expand All @@ -52,10 +53,11 @@ public with sharing class SummitEventsTestSharedDataFactory {
seaInstance.Event__c = testEvent.Id;
seaInstance.Instance_Title__c = testEvent.Name + ' Session ' + x;
seaInstance.Instance_Start_Date__c = Date.today().addDays(x);
seaInstance.Instance_End_Date__c = Date.today().addDays(x);
seaInstance.Instance_End_Date__c = Date.today().addDays(x+1);
seaInstance.Instance_Start_Time__c = currentTime.addHours(-1);
seaInstance.Instance_End_Time__c = currentTime.addHours(8);
seaInstance.Instance_Time_Zone__c = 'Central Daylight Time (America/Chicago)';
seaInstance.Instance_Time_Zone__c = 'Greenwich Mean Time (GMT)';
seaInstance.Private_Instance__c = false;
seaInstance.Active_Status__c = 'Active';
seaInstance.Capacity__c = 500;
seaTestInstances.add(seaInstance);
Expand Down

0 comments on commit 5d967b3

Please sign in to comment.