Skip to content
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

Chore: Fix vault case failure and add one more test for vault key #8378

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/insomnia-smoke-test/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const config: PlaywrightTestConfig = {
screenshots: true,
snapshots: true,
},
permissions: ['clipboard-read'],
},
reporter: process.env.CI ? 'github' : 'list',
timeout: process.env.CI ? 60 * 1000 : 20 * 1000,
Expand Down
16 changes: 16 additions & 0 deletions packages/insomnia-smoke-test/tests/smoke/insomnia-vault.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import { test } from '../../playwright/test';

test.describe('Test Insomnia Vault', async () => {

test('check vault key display and can copy', async ({ page }) => {
await page.locator('[data-testid="settings-button"]').click();
await page.locator('text=Insomnia Preferences').first().click();
// get text under div with data-testid="vault-key"
const expectedVaultKeyValue = 'eyJhbGciOiJBMjU2R0NNIiwiZXh0Ijp0cnVlLCJrIjoia';
const vaultKeyValue = await page.getByTestId('VaultKeyDisplayPanel').innerText();
await expect(vaultKeyValue).toContain(expectedVaultKeyValue);
await page.getByTitle('Copy Vault Key').click();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there other ways for this check without using the clipboard api?

// get clipboard content
const handle = await page.evaluateHandle(() => navigator.clipboard.readText());
const clipboardContent = await handle.jsonValue();
await expect(clipboardContent).toContain(expectedVaultKeyValue);
});

test('create global private sub environment to store vaults', async ({ page, app }) => {
await page.getByLabel('Create in project').click();
await page.getByLabel('Create', { exact: true }).getByText('Environment').click();
Expand Down Expand Up @@ -61,6 +75,7 @@ test.describe('Test Insomnia Vault', async () => {
// activate request
await page.getByTestId('normal').getByLabel('GET normal', { exact: true }).click();
await page.getByRole('button', { name: 'Send' }).click();
await page.waitForTimeout(1000);
await page.getByRole('tab', { name: 'Console' }).click();
await page.getByText('bar').click();
await page.getByText('world').click();
Expand Down Expand Up @@ -101,6 +116,7 @@ test.describe('Test Insomnia Vault', async () => {
// activate request
await page.getByTestId('legacy-array-vault').getByLabel('GET legacy-array-vault', { exact: true }).click();
await page.getByRole('button', { name: 'Send' }).click();
await page.waitForTimeout(1000);
await page.getByRole('tab', { name: 'Console' }).click();
await page.getByText('password').click();
await page.getByText('bar').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,16 @@ export const OneLineEditor = forwardRef<OneLineEditorHandle, OneLineEditorProps>

useEffect(() => {
const unsubscribe = window.main.on('nunjucks-context-menu-command', (_, { key, tag, nunjucksTag, needsEnterprisePlan, displayName }) => {
if (needsEnterprisePlan && !isEnterprisePlan) {
// show modal if current user is not an enteprise user and the command is an enterprise feature
showModal(UpgradeModal, {
newPlan: 'enterprise',
featureName: displayName,
isOwner,
});
return;
}
if (id === key) {
if (needsEnterprisePlan && !isEnterprisePlan) {
// show modal if current user is not an enteprise user and the command is an enterprise feature
showModal(UpgradeModal, {
newPlan: 'enterprise',
featureName: displayName,
isOwner,
});
return;
};
if (nunjucksTag) {
const { type, template, range } = nunjucksTag as nunjucksTagContextMenuOptions;
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const VaultKeyDisplayInput = ({ vaultKey }: { vaultKey: string }) => {
<div className="flex items-center gap-3 bg-[--hl-xs] px-2 py-1 border border-solid border-[--hl-sm] w-full">
<div
className="w-[calc(100%-50px)] truncate"
data-testid="VaultKeyDisplayPanel"
onDoubleClick={(event: React.MouseEvent) => {
event.preventDefault();
event.stopPropagation();
Expand Down
Loading