Skip to content

test: add encrypted and missing-key import tests (3.2.15, 3.2.18) - #3244

Draft
jbair06 wants to merge 10 commits into
mainfrom
3229-encrypted-key-import-tests
Draft

test: add encrypted and missing-key import tests (3.2.15, 3.2.18)#3244
jbair06 wants to merge 10 commits into
mainfrom
3229-encrypted-key-import-tests

Conversation

@jbair06

@jbair06 jbair06 commented Aug 6, 2026

Copy link
Copy Markdown
Member

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 setDialogMockState IPC 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

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: John Bair <john.bair@swirldslabs.com>
@swirlds-automation

swirlds-automation commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.98%. Comparing base (2adc28e) to head (4a3e3bf).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3244   +/-   ##
=======================================
  Coverage   99.98%   99.98%           
=======================================
  Files         192      192           
  Lines        6198     6198           
  Branches     1159     1159           
=======================================
  Hits         6197     6197           
  Misses          1        1           

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jbair06 and others added 2 commits August 6, 2026 09:42
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>
@jbair06
jbair06 marked this pull request as ready for review August 6, 2026 16:57
@jbair06
jbair06 requested a review from a team as a code owner August 6, 2026 16:58
@jbair06
jbair06 requested review from Copilot and ericleponner August 6, 2026 16:58
@jbair06 jbair06 self-assigned this Aug 6, 2026
@jbair06 jbair06 added Frontend Frontend development work Tests labels Aug 6, 2026
@jbair06 jbair06 added this to the v0.37.0 milestone Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread automation/utils/db/localQueries.ts Outdated
Comment thread automation/tests/local-basic/settingsKeysImportTests.test.ts Outdated
Comment thread automation/data/encrypted-test-key.pem Outdated
Comment thread automation/pages/SettingsPage.ts Outdated
…mport tests

Signed-off-by: John Bair <john.bair@swirldslabs.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, but crypto is not imported. This relies on a global crypto being 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

  • setSelectedOrganizationForTesting is 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,

jbair06 and others added 6 commits August 7, 2026 00:12
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
@steven-sheehy
steven-sheehy marked this pull request as draft August 12, 2026 15:20
@steven-sheehy steven-sheehy modified the milestones: v0.37.0, v0.38.0 Aug 18, 2026
@steven-sheehy steven-sheehy removed this from the v0.38.0 milestone Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend Frontend development work Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add encrypted and missing-key import automation tests (3.2.15, 3.2.18)

4 participants