Show "Login.gov" app name in IdV app password confirmation step#6342
Show "Login.gov" app name in IdV app password confirmation step#6342
Conversation
Let "config" stand for common application values
For common values
**Why**: So that the user sees "Login.gov" in the browser tab, not "%{app_name}".
changelog: Upcoming Features, Identity Verification, Add password confirmation step
| if (config === undefined) { | ||
| config = JSON.parse(document.querySelector('[data-config]')?.textContent || ''); | ||
| } |
There was a problem hiding this comment.
yay big fan of caching it like this -- would it also make sense to add a method to clear/reset the config value for tests and such?
There was a problem hiding this comment.
yay big fan of caching it like this -- would it also make sense to add a method to clear/reset the config value for tests and such?
Yeah, turns out we'll need some way to reset it in tests. I went through a few different ideas for how to implement this, and landed at the changes in 7378e6a to exempt caching in the test environment. I had dabbled with a few ideas including resetting via method or property, but the downside is that either each spec file which uses a config value would need to be aware to do the reset, or apply it globally in test setup, neither of which were very appealing to me.
The nice thing about NODE_ENV conditions is that through Webpack source replacement + Terser dead code elimination, the logic gets excluded from production build.
let config;
const isCacheEnvironment = 'production' !== 'test';
function getValue(key) {
if (config === undefined || !isCacheEnvironment) {
config = {};
}
return config[key];
}
console.log(getValue('example'));let e;console.log((void 0===e&&(e={}),e["example"]));There was a problem hiding this comment.
That seems like a good compromise! 👍
So that we don't need to deal with assuring the element exists in test environments, and to improve tolerance to an invalid page setup
For consistency, smaller API
Why: So that the user sees "Login.gov" in the browser tab, not "%{app_name}".
Screenshot: