Conversation
Migration Safety CheckFound 1 potential issue: 20260318_204443_add_dev_mode.ts Warning (line 6): ALTER keyword detected - review for data loss sql`ALTER TABLE \`nac_widgets_config\` ADD \`dev_mode\` integer DEFAULT false NOT NULL;`,Review these patterns and add backup/restore logic if needed. See |
|
Preview deployment: https://nac-dev.preview.avy-fx.org |
|
@busbyk |
|
@busbyk Ready for review |
| jest.mock('../../src/services/nac/nac', () => ({ | ||
| getAvalancheCenterPlatforms: jest.fn(async (centerSlug: string) => { | ||
| const centerSlugToUse = centerSlug === 'dvac' ? 'nwac' : centerSlug | ||
|
|
||
| return mockCenters[centerSlugToUse] ?? allFalsePlatforms | ||
| }), | ||
| })) |
There was a problem hiding this comment.
Replacing the function we're testing here with a mocked function that's only used in this test doesn't actually test the getAvalancheCenterPlatforms function.
Ideally, we would intercept the API requests and return mocked data using MSW or something similar so that we would be testing the actual implementation of getAvalancheCenterPlatforms.
If you don't want to set up MSW, I suggest removing this test file completely.
| it('forces devMode to false in production even when global config has it enabled', async () => { | ||
| Object.defineProperty(process.env, 'NODE_ENV', { value: 'production', configurable: true }) | ||
| mockConfig.devMode = true | ||
|
|
||
| const result = await getNACWidgetsConfig() | ||
| expect(result.devMode).toBe(false) | ||
| }) |
There was a problem hiding this comment.
The PR description says that nacWidgetsConfig.devMode should be respected when NAC_WIDGET_DEV_MODE is not set.
| // In production, always force devMode off regardless of the admin setting | ||
| const devMode = | ||
| process.env.NODE_ENV === 'production' ? false : (nacWidgetsConfig?.devMode ?? false) |
There was a problem hiding this comment.
Yea I don't see why we wouldn't respect this in production.
There was a problem hiding this comment.
The intention was we would never want this to be accidentally true in production, but I guess we might want that? I can't think of a use case.
Summary
NAC_WIDGET_DEV_MODEenvironment variable to control thedevModevalue passed to NAC widget configs"true", overrides the production lock that currently forcesdevModetofalsenacWidgetsConfigglobal'sdevModefield when the env var is not setMotivation
Fixes #717
Currently,
devModeis always forced tofalsein production (getNACWidgetsConfig.ts), regardless of the admin panel setting. This makes it impossible to run a staging/preview deployment that uses the NAC staging widget URLs — useful fornwacus/app(AvyApp) development and testing custom data entered in staging.Changes
src/utilities/getNACWidgetsConfig.ts— CheckNAC_WIDGET_DEV_MODEenv var before falling back to the global config value. Remove the blanket production override so staging deployments can opt in..env.example— Document the newNAC_WIDGET_DEV_MODEvariable.How it works
Priority order for
devMode:NAC_WIDGET_DEV_MODEenv var ("true"→true,"false"→false)nacWidgetsConfig.devModeglobal value from admin panelfalseTest plan
devModerespects admin panel)NAC_WIDGET_DEV_MODE=trueand confirm widgets use the staging base URLNAC_WIDGET_DEV_MODE=falseand confirm it overrides an admin paneldevMode: truedevMode: false/api/[center]/nac-configendpoint returns the correctdevModevalue