ShellInputProvider inputs are not consumed by `ComponentFlow`-based interactive components (e.g. `ConfirmationInput`, `StringInput`)
还没有人认领这个 Issue。
评估
调研方向
Start with ShellInputProvider.Builder#withInput(String) and the ComponentFlow input-consumption path, using the shown ExampleCommandTest as the reproducer. Confirm that the two queued inputs populate the sequential string and confirmation steps, and that the test completes with confirm set to true.
由索引模型根据 Issue 内容生成。
描述
When a command runs a ComponentFlow with two sequential steps and the test supplies two queued inputs via ShellInputProvider.Builder#withInput(String), the flow throws a NoSuchElementException on the second step's context key — regardless of the value supplied (tested with "y", "yes", "true").
Steps to reproduce
Command under test:
@Component
public class ExampleCommand {
private final ComponentFlow.Builder builder;
public ExampleCommand(ComponentFlow.Builder builder) {
this.builder = builder;
}
@Command(name = "example")
public String example() {
ComponentFlow flow = builder.clone().reset()
.withStringInput("reason")
.name("Reason:")
.and()
.withConfirmationInput("confirm")
.name("Confirm?")
.and()
.build();
ComponentFlow.ComponentFlowResult result = flow.run();
boolean confirmed = result.getContext().get("confirm");
return confirmed ? "Confirmed" : "Cancelled";
}
}
Test:
@ShellTest
@ContextConfiguration(classes = ExampleApplication.class)
class ExampleCommandTest {
@Test
void testExample(@Autowired ShellTestClient client) throws Exception {
ShellInputProvider provider = ShellInputProvider.providerFor("example")
.withInput("some reason")
.withInput("true")
.build();
ShellScreen screen = client.sendCommand(provider);
ShellAssertions.assertThat(screen).containsText("Confirmed");
}
}
Expected behavior
The queued inputs are consumed sequentially by the ComponentFlow steps, and the flow completes with confirm = true.
Actual behavior
java.util.NoSuchElementException: Context does not contain key: confirm
at org.springframework.shell.jline.tui.component.context.BaseComponentContext.get(BaseComponentContext.java:44)
at ExampleCommand.example(ExampleCommand.java:...)
...
The exception is identical regardless of the value queued via withInput(...) (tried "y", "yes", "true"), which suggests the input is never reaching the ComponentFlow/ConfirmationInput reading mechanism at all, rather than being rejected as an invalid value.
Is ComponentFlow end-to-end testing currently expected to be unsupported in 4.0.3, or is there a recommended workaround I'm missing?
- 主要语言
- Java
- 星标
- 826
- 派生
- 404
- 平均合并
- 6 天 9 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spring-projects/spring-shell 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 72/100
spring-projects/spring-shell#1391 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 65/100
spring-projects/spring-shell#1390 · 1 条评论 ·
-
area/dependencies type/enhancement
难度 5/5 一周以上 新手友好度 25/100
spring-projects/spring-shell#1213 · 1 个 reaction ·
-
area/dependencies type/enhancement
难度 5/5 一周以上 新手友好度 25/100
spring-projects/spring-shell#1205 · 1 条评论 ·
-
status/need-triage
难度 5/5 一周以上 新手友好度 20/100
spring-projects/spring-shell#1198 · 2 条评论 ·
查看 spring-projects/spring-shell 的全部 Issue
相似的 Issue
-
[destination-snowflake] Custom domains rejected unlike source connections可能已有人在做 @kuza55 今天认领。 未关闭autoteam community connectors/destination/snowflake team/use
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
area-dashboard
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
component/operate kind/feature-request
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Forge coverage prompts carry text the agent cannot act on可能已有人在做 @graalvmbot 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
oracle/graalvm-reachability-metadata#10572 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
IBM/sample-app-mod#55 ·