-
Notifications
You must be signed in to change notification settings - Fork 143
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
Generator creates a project with a singe-locale #325
Conversation
It looks like some of the CI tests are failing because they are hard coded to expect /en-GB as part of the url. We'll need to update the tests to be locale agnostic |
Yeah, I saw that. I'll work on updating those tests tomorrow. |
@adamraya It looks like you're still working on this PR. Pls let me know when it's ready for review, thanks. |
// Otherwise, our code would fall back to default and incorrectly pass the tests | ||
const supportedLocale = supportedLocales[1] | ||
|
||
const supportedLocale = supportedLocales[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 hmm, this test file assumes that it's working with a multi-locale setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that we have updated the tests such that they would pass for both the pwa
and the generated pwa project. But since the two have deviated from each other (one is a multi-locale site, while the other one is now a single locale), the tests can be more tricky to write and may not be clear to new developers.
How about we consider not running the tests for the generated project?
Lines 243 to 244 in 0073095
- runtests: | |
cwd: /tmp/project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generated project is our final most crucial product shipped to customers.
I think it is vital for us to run tests on the code that we hand to customers to make sure that the code they use as starting point works as expected.
The final transient dependencies installed in a generated project can be different from the set of dependencies installed in the PWA, they end up being different projects, thus in my opinion we still need to run tests on both.
You're right that writing tests that work for a single-locale and multi-locale setup can be harder to write.
Let me see what I can do on that particular test file to cover both single-locale and multi-locale scenarios in a simpler way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restored the original functionality on these tests and added a conditional with values for the specific single locale scenario.
const pkgSingleLocaleData = { | ||
l10n: { | ||
supportedCurrencies: ['USD'], | ||
defaultCurrency: 'USD', | ||
supportedLocales: [ | ||
{ | ||
id: 'en-US', | ||
preferredCurrency: 'USD' | ||
} | ||
], | ||
defaultLocale: 'en-US' | ||
} | ||
} | ||
|
||
const PWAKitConfigSingleLocaleData = { | ||
url: { | ||
locale: 'none' | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about extracting these config-related objects into files in the folder 'packages/pwa-kit-create-app/assets/'? The ticket asks about creating files in that asset folder. It may be better to group all the files together in the same location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! I didn't know that we added an /assets
folder to the generator and I missed that implementation detail.
Done, now the configuration objects are in files inside the assets folder.
@adamraya The steps to testdrive PR confused me, so I want to confirm the behavior here. The default project = when no preset is given to |
@sejal-salesforce Yes, with these changes, running the generator using However, the ticket doesn't refer to presets at all. We can not test the changes using
The command uses the This PR doesn't change the questions/answers or the presets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the latest changes. They look good. I also tested generating a project locally and running it. It's good too.
GUS: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00000TshIdYAJ/view
Description
The PWA Kit now supports multiple locales, but we want the generator to create a simplified project configured to use only a single locale. Users will be able to add multiple locales supported by PWA KIt by following the provided documentation.
This PR updates the generator script
create-mobify-app.js
to generate a project with theen-US
locale and theRefArch
siteId .Since we'll work only with one locale, the URL configuration locale type for the generated project it's set to
'none'
in thepwa-kit.config.js
file. This removes the locale shortcode from the URL.A lot of tests have been updated since they were using the hardcoded locale
en-GB
and thus all these tests were failing on a generated project using the single localeen-US
.These tests now use the locale defined as
defaultLocale
inpackage.json
and follow the configuration set in the URL configuration locale type on thepwa-kit.config.js
file to determine if the locale shortcode should be included in the URL pathname.Note: I decided to copy the content of the en-GB translations to the en-US translation since we need the strings for the default language to render the app.
Once we have the real en-US translation, we'll need to update the content of the en-US file.
Types of Changes
Changes
en-US
and the locale type URL configuration set tonone
.en-GB
.How to Test-Drive This PR
generator-single-site-singe-locale
.npm ci
.create-mobify-app.js
script:Verify
npm start
.en-US
is used, the data is from theRefArch
siteId and the locale shortcode is not being displayed in the URL.l10n
settings in the generated projectpackage.json
look like this:pwa-kit.config.js
file looks like this:Run tests
npm run test --prefix packages/pwa
npm run test
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization