Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test creation shouldn't include system.runas unless specified #82

Open
albarivas opened this issue Jul 5, 2024 · 1 comment
Open

Test creation shouldn't include system.runas unless specified #82

albarivas opened this issue Jul 5, 2024 · 1 comment
Labels
bug Something isn't working Generated Responses Issues/Questions related to responses generated using Einstein GPT Owned by another team We are maintaining this feedback for visibility but it is not within the control of our team triaged A work item has been created. Now being handled internally.

Comments

@albarivas
Copy link

Summary

Asked E4D to create a test for:

 @AuraEnabled(cacheable=true)
  public static Decimal getAveragePrice() {
      List<AggregateResult> price = [SELECT AVG(MSRP__c) avgPrice FROM Product__c];
      return (Decimal)price[0].get('avgPrice');
  }

And it came up with:

static void testAveragePrice() {
        System.runAs(new User(Id = UserInfo.getUserId())) {
            Test.startTest();
            Decimal avgPrice = ProductController.getAveragePrice();
            Test.stopTest();
            List<Product__c> productList = [SELECT MSRP__c FROM Product__c];
            Decimal expectedAveragePrice = productList[0].MSRP__c;
            for (Integer i = 1; i < productList.size(); i++) {
                expectedAveragePrice += productList[i].MSRP__c;
            }
            expectedAveragePrice = expectedAveragePrice / productList.size();
            System.assertEquals(expectedAveragePrice, avgPrice, 'The average price should be calculated correctly');
        }
    }

Steps to Reproduce

  1. Create the method specified
  2. Ask E4D to generate test

Actual Result

The one shared

Expected result

It should not include system.runAs unless specified

Additional information

Salesforce Extension Version in Code builder: 61.1.2

Salesforce Einstein For Developers Version in Code builder: 0.50.0

code-server: v4.18.0

Code: 1.83.1

@jonifazo jonifazo added the Generated Responses Issues/Questions related to responses generated using Einstein GPT label Jul 8, 2024
@jonifazo
Copy link

jonifazo commented Jul 8, 2024

Hi @albarivas - Thank you for this feedback. We will pass it on to the AI Research team.

@AnanyaJha AnanyaJha added bug Something isn't working triaged A work item has been created. Now being handled internally. Owned by another team We are maintaining this feedback for visibility but it is not within the control of our team labels Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Generated Responses Issues/Questions related to responses generated using Einstein GPT Owned by another team We are maintaining this feedback for visibility but it is not within the control of our team triaged A work item has been created. Now being handled internally.
Projects
None yet
Development

No branches or pull requests

3 participants