|
14 | 14 | import java.util.Locale; |
15 | 15 | import java.util.Set; |
16 | 16 | import java.util.concurrent.TimeUnit; |
| 17 | +import java.nio.file.Files; |
| 18 | +import java.nio.file.Path; |
17 | 19 | import java.util.regex.Pattern; |
18 | 20 |
|
19 | 21 | import org.junit.jupiter.api.AfterAll; |
@@ -120,6 +122,63 @@ void autoPilotToggle() throws Exception { |
120 | 122 | System.out.println("Second /autopilot result: " + secondOutput); |
121 | 123 | } |
122 | 124 |
|
| 125 | + @Test |
| 126 | + void listDirs() throws Exception { |
| 127 | + SlashCommandInvocationResult result = session.getRpc().commands |
| 128 | + .invoke(new SessionCommandsInvokeParams(null, "list-dirs", null)).get(15, TimeUnit.SECONDS); |
| 129 | + |
| 130 | + String output = extractDisplayText(result); |
| 131 | + assertTrue(Pattern.compile("(?s)^.*Total: [0-9]+ directories.*$").matcher(output).matches(), |
| 132 | + "Expected /list-dirs output to include total directories count"); |
| 133 | + System.out.println("/list-dirs result:"); |
| 134 | + System.out.println(output); |
| 135 | + } |
| 136 | + |
| 137 | + @Test |
| 138 | + void addDir() throws Exception { |
| 139 | + String buildDirectory = System.getProperty("project.build.directory"); |
| 140 | + assertNotNull(buildDirectory, "System property 'project.build.directory' must be set by failsafe"); |
| 141 | + |
| 142 | + Path addDirPath = Path.of(buildDirectory, "addDirTest").toAbsolutePath().normalize(); |
| 143 | + Files.createDirectories(addDirPath); |
| 144 | + String addDirPathString = addDirPath.toString(); |
| 145 | + |
| 146 | + SlashCommandInvocationResult beforeListResult = session.getRpc().commands |
| 147 | + .invoke(new SessionCommandsInvokeParams(null, "list-dirs", null)).get(15, TimeUnit.SECONDS); |
| 148 | + String beforeListOutput = extractDisplayText(beforeListResult); |
| 149 | + System.out.println("/list-dirs (before /add-dir) result:"); |
| 150 | + System.out.println(beforeListOutput); |
| 151 | + |
| 152 | + SlashCommandInvocationResult addDirResult = session.getRpc().commands |
| 153 | + .invoke(new SessionCommandsInvokeParams(null, "add-dir", addDirPathString)).get(15, TimeUnit.SECONDS); |
| 154 | + String addDirOutput = extractDisplayText(addDirResult); |
| 155 | + System.out.println("/add-dir result:"); |
| 156 | + System.out.println(addDirOutput); |
| 157 | + |
| 158 | + SlashCommandInvocationResult afterListResult = session.getRpc().commands |
| 159 | + .invoke(new SessionCommandsInvokeParams(null, "list-dirs", null)).get(15, TimeUnit.SECONDS); |
| 160 | + String afterListOutput = extractDisplayText(afterListResult); |
| 161 | + System.out.println("/list-dirs (after /add-dir) result:"); |
| 162 | + System.out.println(afterListOutput); |
| 163 | + |
| 164 | + assertTrue(afterListOutput.contains(addDirPathString), |
| 165 | + "Expected /list-dirs output to contain added directory path: " + addDirPathString); |
| 166 | + } |
| 167 | + |
| 168 | + @Test |
| 169 | + void usage() throws Exception { |
| 170 | + SlashCommandInvocationResult result = session.getRpc().commands |
| 171 | + .invoke(new SessionCommandsInvokeParams(null, "usage", null)).get(15, TimeUnit.SECONDS); |
| 172 | + |
| 173 | + String output = extractDisplayText(result); |
| 174 | + assertTrue(Pattern.compile("(?s)^.*Changes:.*$").matcher(output).matches(), |
| 175 | + "Expected /usage output to include a Changes summary line"); |
| 176 | + assertTrue(Pattern.compile("(?s)^.*Requests:.*$").matcher(output).matches(), |
| 177 | + "Expected /usage output to include a Requests/AI Units summary line"); |
| 178 | + System.out.println("/usage result:"); |
| 179 | + System.out.println(output); |
| 180 | + } |
| 181 | + |
123 | 182 | private static String extractDisplayText(SlashCommandInvocationResult result) { |
124 | 183 | assertNotNull(result, "slash command result must not be null"); |
125 | 184 |
|
|
0 commit comments