fix: handle skipped questions in when with display option#1853
fix: handle skipped questions in when with display option#1853Sakthieswaran-tech wants to merge 3 commits intoSBoudrias:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1853 +/- ##
=======================================
Coverage ? 94.77%
=======================================
Files ? 38
Lines ? 1587
Branches ? 466
=======================================
Hits ? 1504
Misses ? 80
Partials ? 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fe5866b to
7f04251
Compare
|
Hey @SBoudrias , I’ve added more test cases and all checks are passing. Could you take a look when you get a chance and let me know if anything needs changes? |
SBoudrias
left a comment
There was a problem hiding this comment.
The PR is a little big, so I didn't review all of it in depth yet. Here's a few early thoughts to streamline the code a little.
8e76e3c to
5b30e81
Compare
|
Rebased with latest main. |
|
Hi @SBoudrias , I’ve made the requested changes and resolved the conflicts. Please take a look when you have some time and let me know if I need to make any further changes. Thanks! |
|
Hi! Just checking in on this PR whenever you get a chance. Let me know if anything else is needed from my side. |
219cc1e to
2b9d1b8
Compare
SBoudrias
left a comment
There was a problem hiding this comment.
I did a slight refactoring pass on some core changes. Besides that, I think there's still a fair amount of work to properly consider how this works with plugins and how we respect user theme.
| const theme = makeTheme(); | ||
| const prefix = typeof theme.prefix === 'string' ? theme.prefix : theme.prefix.idle; |
There was a problem hiding this comment.
Doing here mean we're only support the default theme, whereas we should match the theme if one is provided by the user.
| }; | ||
|
|
||
| function renderLine(message: string, answerText: string) { | ||
| return theme.style.help(`${prefix} ${message} ${answerText}`); |
There was a problem hiding this comment.
help likely isn't the right theme key to use here; it's not semantically correct. We should add a new key to cover skipped question lines.
| }); | ||
|
|
||
| it('should display skipped question when `when` returns { ask: false, display: true }', async () => { | ||
| const writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true); |
There was a problem hiding this comment.
I think it'll be cleaner here to reuse the BufferedStream from packages/testing/src/index.ts to collect the writes.
| confirm: (question: TypedQuestion) => { | ||
| const defaultVal = question.default; | ||
| const answerText = defaultVal === true ? 'Yes' : defaultVal === false ? 'No' : ''; | ||
| return renderLine(question.message.toString(), answerText); | ||
| }, |
There was a problem hiding this comment.
I don't have a good suggestion right now, but implementing rendering here while the actual rendering is in other package isn't great...
Ideally rendering should be consistent and provided by each prompt.
| }, | ||
|
|
||
| default: (question: TypedQuestion) => { | ||
| const answerText = question.default !== undefined ? String(question.default) : ''; |
There was a problem hiding this comment.
Given default handle ALL prompts - not just the core ones within Inquirer, I don't think we can safely assume default can be stringified; for all we know default can be an object or an array.
| }, | ||
|
|
||
| editor: (question: TypedQuestion) => { | ||
| const answerText = question.default !== undefined ? '[Default Content]' : ''; |
There was a problem hiding this comment.
What user value does [Default Content] provide here? (same with PASSWORD SET later.)
Uh oh!
There was an error while loading. Please reload this page.