-
Notifications
You must be signed in to change notification settings - Fork 1
fix: broken e2e tests #1391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: broken e2e tests #1391
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,11 @@ | ||||||||||||||||||||||||||||||
| import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test"; | ||||||||||||||||||||||||||||||
| import { createSettleMintClient } from "@settlemint/sdk-js"; | ||||||||||||||||||||||||||||||
| import { loadEnv } from "@settlemint/sdk-utils/environment"; | ||||||||||||||||||||||||||||||
| import { fetchWithRetry } from "@settlemint/sdk-utils/http"; | ||||||||||||||||||||||||||||||
| import type { DotEnv } from "@settlemint/sdk-utils/validation"; | ||||||||||||||||||||||||||||||
| import { NODE_NAME_3_WITHOUT_PK } from "./constants/test-resources"; | ||||||||||||||||||||||||||||||
| import { forceExitAllCommands, runCommand } from "./utils/run-command"; | ||||||||||||||||||||||||||||||
| import { setupSettleMintClient } from "./utils/test-resources"; | ||||||||||||||||||||||||||||||
|
Comment on lines
+2
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused import and use existing helper instead. The Apply this diff to remove the unused import: -import { setupSettleMintClient } from "./utils/test-resources";
+import { findBlockchainNodeByName } from "./utils/test-resources";📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (2.1.2)[error] 8-8: This import is unused. Unused imports might be the result of an incomplete refactoring. (lint/correctness/noUnusedImports) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const COMMAND_TEST_SCOPE = __filename; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -14,11 +17,15 @@ afterEach(() => { | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| describe("Restart platform resources using the SDK", () => { | ||||||||||||||||||||||||||||||
| test("Restart blockchain node on the platform", async () => { | ||||||||||||||||||||||||||||||
| const blockchainNode = await findBlockchainNodeByName(NODE_NAME_3_WITHOUT_PK); | ||||||||||||||||||||||||||||||
| if (!blockchainNode) { | ||||||||||||||||||||||||||||||
| throw new Error(`Blockchain node ${NODE_NAME_3_WITHOUT_PK} not found`); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| const { output } = await runCommand(COMMAND_TEST_SCOPE, [ | ||||||||||||||||||||||||||||||
| "platform", | ||||||||||||||||||||||||||||||
| "restart", | ||||||||||||||||||||||||||||||
| "blockchain-node", | ||||||||||||||||||||||||||||||
| NODE_NAME_3_WITHOUT_PK, | ||||||||||||||||||||||||||||||
| blockchainNode.uniqueName, | ||||||||||||||||||||||||||||||
| "--wait", | ||||||||||||||||||||||||||||||
| "--accept-defaults", | ||||||||||||||||||||||||||||||
| ]).result; | ||||||||||||||||||||||||||||||
|
|
@@ -30,3 +37,13 @@ describe("Restart platform resources using the SDK", () => { | |||||||||||||||||||||||||||||
| expect(response.status).toBe(401); // Unauthorized as we did not provide a token | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| async function findBlockchainNodeByName(blockchainNodeName: string) { | ||||||||||||||||||||||||||||||
| const env: Partial<DotEnv> = await loadEnv(false, false); | ||||||||||||||||||||||||||||||
| const settlemint = createSettleMintClient({ | ||||||||||||||||||||||||||||||
| accessToken: env.SETTLEMINT_ACCESS_TOKEN!, | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the E2E-specific access token environment variable for authentication in tests to avoid targeting the wrong environment. Prefer reusing the shared client setup helper or switch this line to the E2E token. Prompt for AI agents |
||||||||||||||||||||||||||||||
| instance: env.SETTLEMINT_INSTANCE!, | ||||||||||||||||||||||||||||||
|
Comment on lines
+41
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new helper builds the SDK client with Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| const nodes = await settlemint.blockchainNode.list(env.SETTLEMINT_APPLICATION!); | ||||||||||||||||||||||||||||||
| return nodes.find((node) => node.name === blockchainNodeName); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Incorrect Access Token Usage in TestsLocal
Comment on lines
+41
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Comment on lines
+41
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The 🔍 Detailed AnalysisThe 💡 Suggested FixModify the 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
Comment on lines
+41
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove duplicate helper - reuse existing implementation. This function duplicates Remove this local function definition and import the existing helper as suggested in the earlier comment (lines 2-8). -
-async function findBlockchainNodeByName(blockchainNodeName: string) {
- const env: Partial<DotEnv> = await loadEnv(false, false);
- const settlemint = createSettleMintClient({
- accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
- instance: env.SETTLEMINT_INSTANCE!,
- });
- const nodes = await settlemint.blockchainNode.list(env.SETTLEMINT_APPLICATION!);
- return nodes.find((node) => node.name === blockchainNodeName);
-}
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
setupSettleMintClientfunction is imported but never used in this file. Unused imports should be removed to improve code readability and maintainability.