Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/tests/lightspeed-install.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ describe('OLS UI', () => {
const args =
csv.spec.install.spec.deployments[0].spec.template.spec.containers[0].args.map(
(arg) =>
arg.startsWith('--console-image=')
? `--console-image=${Cypress.env('CONSOLE_IMAGE')}`
arg.startsWith('--console-image')
? arg.replace(/=.*/, `=${Cypress.env('CONSOLE_IMAGE')}`)
Comment on lines +176 to +177
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Handle split --console-image args explicitly

At Line 177, replacement only works when the arg already contains =. If CSV args are --console-image <value>, this leaves the old value untouched, so the PR image is not reliably enforced.

Suggested fix
-              const args =
-                csv.spec.install.spec.deployments[0].spec.template.spec.containers[0].args.map(
-                  (arg) =>
-                    arg.startsWith('--console-image')
-                      ? arg.replace(/=.*/, `=${Cypress.env('CONSOLE_IMAGE')}`)
-                      : arg,
-                );
+              const consoleImage = Cypress.env('CONSOLE_IMAGE');
+              const originalArgs =
+                csv.spec.install.spec.deployments[0].spec.template.spec.containers[0].args;
+              const args: string[] = [];
+              for (let i = 0; i < originalArgs.length; i += 1) {
+                const arg = originalArgs[i];
+                if (arg === '--console-image') {
+                  args.push(`--console-image=${consoleImage}`);
+                  if (i + 1 < originalArgs.length && !originalArgs[i + 1].startsWith('--')) i += 1;
+                  continue;
+                }
+                if (arg.startsWith('--console-image=')) {
+                  args.push(`--console-image=${consoleImage}`);
+                  continue;
+                }
+                args.push(arg);
+              }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
arg.startsWith('--console-image')
? arg.replace(/=.*/, `=${Cypress.env('CONSOLE_IMAGE')}`)
const consoleImage = Cypress.env('CONSOLE_IMAGE');
const originalArgs =
csv.spec.install.spec.deployments[0].spec.template.spec.containers[0].args;
const args: string[] = [];
for (let i = 0; i < originalArgs.length; i += 1) {
const arg = originalArgs[i];
if (arg === '--console-image') {
args.push(`--console-image=${consoleImage}`);
if (i + 1 < originalArgs.length && !originalArgs[i + 1].startsWith('--')) i += 1;
continue;
}
if (arg.startsWith('--console-image=')) {
args.push(`--console-image=${consoleImage}`);
continue;
}
args.push(arg);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/tests/lightspeed-install.cy.ts` around lines 176 - 177, The arg
transformation only replaces when the arg contains '=' so it misses the separate
form "--console-image <value>"; update the logic in the args mapping (the block
using arg.startsWith('--console-image')) to also handle when arg ===
'--console-image' by emitting a single joined form "--console-image=<env-value>"
using Cypress.env('CONSOLE_IMAGE') and ensuring the next token (the original
value) is not left as a separate arg (i.e., skip or remove it in the mapped
output). Target the mapping code that references the local variable arg and
replace it with this two-case handling so both "--console-image=<val>" and
"--console-image <val>" are normalized to the enforced PR image.

: arg,
);

Expand Down