test: add encrypted and missing-key import tests (3.2.15, 3.2.18) - #3244
test: add encrypted and missing-key import tests (3.2.15, 3.2.18)#3244jbair06 wants to merge 10 commits into
Conversation
Signed-off-by: John Bair <john.bair@swirldslabs.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3244 +/- ##
=======================================
Coverage 99.98% 99.98%
=======================================
Files 192 192
Lines 6198 6198
Branches 1159 1159
=======================================
Hits 6197 6197
Misses 1 1 🚀 New features to boost your workflow:
|
Update test-scenarios.md and release-testing-checklist.md to reflect the new Playwright tests added for issue #3229. Signed-off-by: John Bair <john.bair@swirldslabs.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use the existing setDialogMockState IPC hook (PLAYWRIGHT_TEST=true path in utils:showOpenDialog) to inject a real .pem fixture so Browse never opens the native OS picker. Adds the fixture file, a data-testid on the Decrypt button, four new SettingsPage helpers, and removes test.skip. Both 3.2.15 and 3.2.18 are now fully automated; docs updated accordingly. Signed-off-by: John Bair <john.bair@swirldslabs.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds automated coverage for previously manual key-management scenarios by introducing Playwright tests for encrypted key import and restoring missing keys, along with supporting test hooks/selectors and updated documentation.
Changes:
- Added Playwright E2E tests for importing encrypted private keys (3.2.15) and importing an external private key for a missing key (3.2.18)
- Added test selectors/UI hooks and DB helper to support org-state injection during tests
- Updated scenario coverage documentation and release checklist to reflect new automation
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| front-end/src/renderer/components/KeyPair/ImportEncrypted/components/DecryptKeyModal.vue | Adds a stable test id to target the decrypt submit button in automation |
| docs/test-scenarios.md | Marks scenarios 3.2.15 and 3.2.18 as automated and updates coverage totals; removes Tier 1 blocker section tied to missing automation |
| docs/release-testing-checklist.md | Removes Tier 1 checklist items now covered by automation |
| automation/utils/db/localQueries.ts | Adds helper to insert an Organization row needed for FK constraints in tests |
| automation/utils/db/databaseQueries.ts | Re-exports the new DB helper for test usage |
| automation/tests/local-basic/settingsKeysImportTests.test.ts | Adds new Playwright tests for encrypted key import and restore-missing-key import flow |
| automation/pages/SettingsPage.ts | Adds selectors and helper methods for the new flows; injects fake org state into Pinia store |
| automation/data/encrypted-test-key.pem | Adds encrypted PEM fixture used by the new encrypted import test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…mport tests Signed-off-by: John Bair <john.bair@swirldslabs.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (4)
automation/tests/local-basic/settingsKeysImportTests.test.ts:3
crypto.randomUUID()is used in this test file, butcryptois not imported. This relies on a globalcryptobeing available in the Playwright/Node runtime and can break typechecking or execution depending on the runner config.
import { expect, test } from '@playwright/test';
import { PrivateKey } from '@hiero-ledger/sdk';
import {
automation/utils/crypto/keyUtil.ts:68
- The encrypted PEM fixture is written to the shared temp directory without explicitly restricting file permissions. Since it contains private-key material (even if test-only), it’s safer to write it with a restrictive mode (e.g., 0o600) to avoid accidental exposure on shared runners.
const pemPath = path.join(os.tmpdir(), `test-key-${crypto.randomUUID()}.pem`);
await fsp.writeFile(pemPath, pem, 'utf-8');
automation/tests/local-basic/settingsKeysImportTests.test.ts:92
- PR description says the 3.2.15 encrypted-key test is skipped due to native file-picker limitations, but the test here runs end-to-end using the dialog mock. Please update the PR description (or add an explicit
test.skip(...)if it’s intended to be non-executable in CI) so reviewers understand the actual behavior.
test('Verify user can import encrypted private key (3.2.15)', async () => {
// Generate a fresh encrypted PEM on disk so no private-key material is
// committed to the repository. The fixture is removed after the test.
const password = crypto.randomUUID();
const { pemPath, cleanup } = await generateEncryptedPemFixture(password);
front-end/src/renderer/main.ts:54
setSelectedOrganizationForTestingis a Pinia store mutator, while the nearby comment says these hooks mutate module-scoped refs outside Pinia. Adding a brief inline note here would prevent confusion about what kind of state this hook touches.
...(w.__testHooks__ ?? {}),
setVersionDataForOrg,
resetVersionStatusForOrg,
setSelectedOrganizationForTesting,
Signed-off-by: John Bair <john.bair@swirldslabs.com>
3.2.15: after clicking Import, RecoveryPhraseModal appears before DecryptKeyModal. Add data-testid to its Skip button and call skipRecoveryPhrase() between the two steps. 3.2.18: after the restore modal opens, clear the fake org so the import runs in local-only mode (no network call to the test server). Signed-off-by: John Bair <john.bair@swirldslabs.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace __testHooks__ / setSelectedOrganizationForTesting with direct $pinia._s access from page.evaluate(), the same pattern localUserSeeding already uses. No production code changes needed. Signed-off-by: John Bair <john.bair@swirldslabs.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…port-tests # Conflicts: # docs/test-scenarios.md
Description:
Adds automation tests for encrypted key import (3.2.15) and external private key import for a missing key slot (3.2.18). The 3.2.15 test uses the
setDialogMockStateIPC hook to inject a real PEM fixture, bypassing the native OS file-picker. The 3.2.18 test injects a missing-key state via a new DB helper and page method, then drives the full restore flow. Both scenarios are now fully automated; tracking docs updated accordingly.Related issue(s):
Fixes #3229
Checklist