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

Issue Validating with Scratch Orgs When Working with a Community and State and Country Picklists #553

Closed
Jkenney94 opened this issue Aug 7, 2020 · 3 comments
Labels
area:apex Highlights the apex functional area of the CLI. owned by another team The Salesforce CLI team does not own this work but will pass on the information to the correct team.

Comments

@Jkenney94
Copy link

Summary

Using a Scratch Org for validation in Pipelines with a project involving a Community and Country and State Picklists, a standard Apex Class created for the Community (MyProfilePageController) has a failing unit test due to an invalid initialization of the User within the Scratch Org. User's Address is set to "US" and once Country and State Picklists are enabled the expectation is for this to be "United States" on the record. This seems to be a recent bug, I had a similar project setup roughly a year ago where all of this was working as expected.

Steps To Reproduce:

Repository to reproduce: sfdx-StateAndCountry-Community-Bug

Reproduction Steps:

  1. Create a new Scratch Org (the Scratch org config should enable Communities and State and Country Picklist Features) using sfdx force:org:create -s -f ./config/project-scratch-def.json -a ScratchOrg
  2. Push your sample Community to the scratch org using sfdx force:source:push
  3. Run Local Tests using sfdx force:apex:test:run -l RunLocalTests -w 15

Alternatively, use the setupScript.sh within the repo

Expected result

All tests should be passing, this was working as expected in a past project done roughly a year ago.

Actual result

MyProfilePageControllerTest.testSave fails because an Exception is thrown preventing the User Record from being updated thus preventing the System.assert to validate the record was updated.

The Exception is caused by calling Update on the Current User with a Country of "US" but enabling State and Country Picklists expects the Country to be from the picklist (in this case it should be "United States"). This causes a CI/CD process validating with Scratch Orgs to fail if verifying tests are working as expected.

The workaround is to run an Anonymous Apex Script to update the User's Country to be "United States" to then bypass the Exception, but I believe this should not be necessary.

Additional information

User Record:
User Record

Test Results:
Test Results

SFDX CLI Version(to find the version of the CLI engine run sfdx --version): sfdx-cli/7.69.0 darwin-x64 node-v12.18.2

SFDX plugin Version(to find the version of the CLI plugin run sfdx plugins --core)
@oclif/plugin-autocomplete 0.1.5 (core)
@oclif/plugin-commands 1.3.0 (core)
@oclif/plugin-not-found 1.2.4 (core)
@oclif/plugin-plugins 1.7.10 (core)
@oclif/plugin-warn-if-update-available 1.7.0 (core)
@oclif/plugin-which 1.0.3 (core)
@salesforce/lwc-dev-server 2.2.0
├─ @oclif/plugin-help 2.2.1
└─ @oclif/plugin-update 1.3.9
@salesforce/sfdx-diff 0.0.6
@salesforce/sfdx-trust 3.0.7 (core)
analytics 1.12.0 (core)
generator 1.1.3 (core)
salesforcedx 49.5.0 (core)
├─ custom-metadata 1.0.8 (core)
├─ salesforcedx-templates 49.2.0 (core)
├─ @salesforce/sfdx-plugin-lwc-test 0.1.7 (core)
└─ salesforce-alm 49.5.0 (core)
sfdx-cli 7.69.0 (core)

OS and version: MacOS Catalina 10.15.6

@clairebianchi clairebianchi added the investigating We're actively investigating this issue label Oct 23, 2020
@shetzel shetzel added owned by another team The Salesforce CLI team does not own this work but will pass on the information to the correct team. and removed investigating We're actively investigating this issue labels Oct 23, 2020
@shetzel
Copy link
Contributor

shetzel commented Oct 23, 2020

I've asked the apex team if this is working as designed or a bug. You might want to post in a salesforce community as well.

@preddivari preddivari added the area:apex Highlights the apex functional area of the CLI. label Sep 22, 2023
@iowillhoit
Copy link
Contributor

Hey @Jkenney94, I am grooming some old Github Issues. Is this still an issue? I tried to replicate it using your repo but had to remove enableSetPasswordInApi from the scratch org definition file since it was removed in Spring 21. After removing that setting, there were multiple test failures.

@iowillhoit
Copy link
Contributor

Going to close this issue for now. If this still a problem, please open a new Issue with updates to the reproduction steps. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:apex Highlights the apex functional area of the CLI. owned by another team The Salesforce CLI team does not own this work but will pass on the information to the correct team.
Projects
None yet
Development

No branches or pull requests

5 participants