• Cristina Camacho
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi all,

I am completly stuck with step8, my test coverage is good enough and the pages work as expected, however I am getting the error 

Challenge Not yet complete... here's what's wrong: 
Ensure that product2Controller is still working as specified in the earlier challenge.


User-added image

 I have tried to do all the advice given in this forum with no luck, still same error.... can someone please help me to solve the issue? I can´t go back to retake the challenge as i already passed all the previous steps!!

Thanks,
Cristina
Hello all,

why is the definition of my event not working?

User-added image

BoatDetailController.js
 
({
	doInit: function (component, event, helper) {       	
        var viewRecordEvent = $A.get('event.force:navigateToSObject');
        console.log("viewRecordEvent " + viewRecordEvent);
        if(viewRecordEvent){
            console.log("showButton");
            component.set('v.showButton', true);
        }
    },  
    
    onFullDetails : function(component, event, helper) {
		var homeEvent = $A.get("event.force:navigateToSObject");
        homeEvent.setParams({
            "recordId": component.get("v.boat.Id")
        });
        homeEvent.fire();
	}
})


BoatDetail.cmp
 
<aura:component >
    <aura:attribute name="boat" type="Boat__c"/>    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="showButton" type="Boolean" default="false"/>
        
	<lightning:card iconName="utility:anchor">        
        <aura:set attribute="title">{!v.boat.Contact__r.Name}'s Boat</aura:set>  
         <aura:set attribute="actions">
            <aura:if isTrue='{!v.showButton}'>
                <lightning:button label="Full Details" onclick="{!c.onFullDetails}" />
            </aura:if>    
        </aura:set>      
       <lightning:layout multipleRows="true" >
                        <lightning:layoutItem size="6" padding="around-small">
                           <div class="slds-p-horizontal--small">
                        <div class="boatproperty">
                            <span class="label">Boat Name:</span>
                            <span><ui:outputText value="{!v.boat.Name}"/></span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Type:</span>
                            <span><ui:outputText value="{!v.boat.BoatType__r.Name}"/></span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Length:</span>
                            <span><ui:outputText value="{!v.boat.Length__c}"/> ft</span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Est. Price:</span>
                            <span><lightning:formattedNumber value="{!v.boat.Price__c}" currencyCode="USD" style="currency" currencyDisplayAs="symbol"/></span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Description:</span>
                            <span><ui:outputRichText class="slds-text-longform" value="{!v.boat.Description__c}"/></span>
                        </div>
                    </div>
                        </lightning:layoutItem>
                        <lightning:layoutItem size="6" padding="around-small">                            
                            <div class="imageview" style="{!'background-image: url(\'' + v.boat.Picture__c + '\')'}" />                           
                        </lightning:layoutItem>
                     </lightning:layout>
   	</lightning:card>
</aura:component>


 
Hi all,

I am completly stuck with step8, my test coverage is good enough and the pages work as expected, however I am getting the error 

Challenge Not yet complete... here's what's wrong: 
Ensure that product2Controller is still working as specified in the earlier challenge.


User-added image

 I have tried to do all the advice given in this forum with no luck, still same error.... can someone please help me to solve the issue? I can´t go back to retake the challenge as i already passed all the previous steps!!

Thanks,
Cristina
Hello all,

why is the definition of my event not working?

User-added image

BoatDetailController.js
 
({
	doInit: function (component, event, helper) {       	
        var viewRecordEvent = $A.get('event.force:navigateToSObject');
        console.log("viewRecordEvent " + viewRecordEvent);
        if(viewRecordEvent){
            console.log("showButton");
            component.set('v.showButton', true);
        }
    },  
    
    onFullDetails : function(component, event, helper) {
		var homeEvent = $A.get("event.force:navigateToSObject");
        homeEvent.setParams({
            "recordId": component.get("v.boat.Id")
        });
        homeEvent.fire();
	}
})


BoatDetail.cmp
 
<aura:component >
    <aura:attribute name="boat" type="Boat__c"/>    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="showButton" type="Boolean" default="false"/>
        
	<lightning:card iconName="utility:anchor">        
        <aura:set attribute="title">{!v.boat.Contact__r.Name}'s Boat</aura:set>  
         <aura:set attribute="actions">
            <aura:if isTrue='{!v.showButton}'>
                <lightning:button label="Full Details" onclick="{!c.onFullDetails}" />
            </aura:if>    
        </aura:set>      
       <lightning:layout multipleRows="true" >
                        <lightning:layoutItem size="6" padding="around-small">
                           <div class="slds-p-horizontal--small">
                        <div class="boatproperty">
                            <span class="label">Boat Name:</span>
                            <span><ui:outputText value="{!v.boat.Name}"/></span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Type:</span>
                            <span><ui:outputText value="{!v.boat.BoatType__r.Name}"/></span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Length:</span>
                            <span><ui:outputText value="{!v.boat.Length__c}"/> ft</span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Est. Price:</span>
                            <span><lightning:formattedNumber value="{!v.boat.Price__c}" currencyCode="USD" style="currency" currencyDisplayAs="symbol"/></span>
                        </div>
                        <div class="boatproperty">
                            <span class="label">Description:</span>
                            <span><ui:outputRichText class="slds-text-longform" value="{!v.boat.Description__c}"/></span>
                        </div>
                    </div>
                        </lightning:layoutItem>
                        <lightning:layoutItem size="6" padding="around-small">                            
                            <div class="imageview" style="{!'background-image: url(\'' + v.boat.Picture__c + '\')'}" />                           
                        </lightning:layoutItem>
                     </lightning:layout>
   	</lightning:card>
</aura:component>


 
I've gone through every step successfully but am banging my head against the wall with step 8. I have more than adequate code coverage but continue to get this error message:
User-added image
I have gone back and rewritten OrderTests twice according to the requirements but can't get past this error. Anyone else had any luck with this?

Here's my code for reference:
@isTest (SeeAllData=false)
private class OrderTests {
    
    static void SetupTestData() {
	    TestDataFactory.InsertTestData(5);
    }
 
    @isTest static void OrderExtension_UnitTest() {
        PageReference pageRef = Page.OrderEdit;
        Test.setCurrentPage(pageRef);
        SetupTestData();
        ApexPages.StandardController stdcontroller = new ApexPages.StandardController(TestDataFactory.orders[0]);        
        OrderExtension ext = new OrderExtension(stdcontroller);        
       	System.assertEquals(Constants.DEFAULT_ROWS, ext.orderItemList.size());
        ext.OnFieldChange();
        ext.SelectFamily();
        ext.Save();
        ext.First();
        ext.Next();
        ext.Previous();
        ext.Last();
        ext.GetHasPrevious();
        ext.GetHasNext();
        ext.GetTotalPages();
        ext.GetPageNumber();
        List<SelectOption> options = ext.GetFamilyOptions();
    }
    
@isTest
public static void OrderUpdate_UnitTest(){
    setupTestData();
    
   
    Test.startTest();
    
    List<Order> orders = TestDataFactory.orders;
    for (Order o : orders){
        o.Status = Constants.ACTIVATED_ORDER_STATUS;
    }
    List<Product2> oldProducts = TestDataFactory.products;
    Set<Id> productIds = new Set<Id>();
    for (Product2 oldProd : oldProducts){
        productIds.add(oldProd.Id);
    }
    oldProducts = [SELECT Id, Quantity_Ordered__c FROM Product2 WHERE ID IN :productIds];
    Map<Id, Integer> quantities = new Map<Id, Integer>();
    for (OrderItem oi : TestDataFactory.orderItems){
        Integer quantity = 0;
        List<PricebookEntry> pricebookentries = TestDataFactory.pbes;
        for (PricebookEntry pbe : pricebookentries){
            if (oi.PricebookEntryId == pbe.Id){                
                if (quantities.containsKey(pbe.Product2Id)){
                    quantity = quantities.get(pbe.Product2Id);
                }
                quantity += (Integer)oi.Quantity;
                quantities.put(pbe.Product2Id, quantity);
                break;
            }
        }
    }
   
    update orders;
    Map<Id, Product2> currentProducts = new Map<Id, Product2>([Select Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);
  
    for (Product2 prod : oldProducts){
      
        TestDataFactory.VerifyQuantityOrdered(prod, currentProducts.get(prod.Id), quantities.get(prod.Id));
  }
  Test.stopTest();
}
}