function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Salesforce Dev199Salesforce Dev199 

test class for Lightning Page controller

Hello Everyone, Can You guys help me with a test class for this Controller of Lighning page.
public class SendForSignController {
	@AuraEnabled	
    public static MessageWrapper performValidation(String oppoRecId) {
        MessageWrapper returnwrapperClass = new  MessageWrapper (); 
        List<Opportunity> oppoRecordList = [Select id,
                                                    name,
                                                    AccountId,
                                                    Account.Customer_Success_Manager__c,
                                                    (
                                                        SELECT Id,
                                                            Name,
                                                            Ready_for_Approval__c
                                                        FROM 
                                                            zqu__Quotes__r
                                                        WHERE Ready_for_Approval__c = true
                                                        limit 1
                                                    ) 
                                                  FROM Opportunity WHERE Id = :oppoRecId ];
        System.debug('oppo record::'+oppoRecordList[0]);
        System.debug('oppo record::'+oppoRecordList[0].zqu__Quotes__r);
        
        if(oppoRecordList != NULL && !oppoRecordList.isEmpty()){
            if(oppoRecordList[0].Account != NULL &&  oppoRecordList[0].Account.Customer_Success_Manager__c != NULL){
                System.debug('Customer success manager of account is not blank'+oppoRecordList[0].Account.Customer_Success_Manager__c);
                if(oppoRecordList[0].zqu__Quotes__r != NULL && oppoRecordList[0].zqu__Quotes__r.size()>0){
                    if(oppoRecordList[0].zqu__Quotes__r[0].Ready_for_Approval__c == true){
                        if(){
                            returnwrapperClass.msgStr = 'Validations Successful..Redirecting to the Page.';
                            returnwrapperClass.msgType = 'success';
                            return returnwrapperClass;
                        }
                    }
                    else{
                         returnwrapperClass.msgStr = 'Validations failed..Cannot Redirect to the Page.';
                         returnwrapperClass.msgType = 'error';
                         return returnwrapperClass;
                    }
                    
                }
            }
            
        }
        return returnwrapperClass;
    }
    
    /*Error Wrapper Class*/
    public class MessageWrapper{
        @AuraEnabled public String msgStr {get;set;}
        @AuraEnabled public String msgType {get;set;}
    }
}

 
SwethaSwetha (Salesforce Developers) 
HI,
The forums community might not help with exact code snippets. The below articles give an idea of how to write test classes. You will need to customize based on your requirementhttps://trailhead.salesforce.com/en/content/learn/modules/apex_testing/apex_testing_intro for basics on test classes
https://salesforce.stackexchange.com/questions/87533/writing-test-class-for-wrapper-class
https://salesforce.stackexchange.com/questions/181448/salesforce-lightning-component-controller-apex-test-class
https://developer.salesforce.com/forums/?id=9060G000000I1OrQAK
Thanks