diff --git a/apps/wallet/src/background/Transactions.ts b/apps/wallet/src/background/Transactions.ts index c7182567c1e..6c696bf0b12 100644 --- a/apps/wallet/src/background/Transactions.ts +++ b/apps/wallet/src/background/Transactions.ts @@ -82,7 +82,7 @@ class Transactions { if (!txResult) { throw new Error('Sign message result is empty'); } - if (!('messageBytes' in txResult)) { + if (!('bytes' in txResult)) { throw new Error('Sign message error, unknown result'); } return txResult as IotaSignPersonalMessageOutput; diff --git a/apps/wallet/tests/sites-to-cs-api.spec.ts b/apps/wallet/tests/sites-to-cs-api.spec.ts new file mode 100644 index 00000000000..3ed5774e19f --- /dev/null +++ b/apps/wallet/tests/sites-to-cs-api.spec.ts @@ -0,0 +1,38 @@ +// Copyright (c) Mysten Labs, Inc. +// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { type Page } from '@playwright/test'; +import { expect, test } from './fixtures'; +import { createWallet } from './utils/auth'; +import { demoDappConnect } from './utils/dapp-connect'; +import dotenv from 'dotenv'; + +dotenv.config(); + +test.beforeEach(async ({ page, extensionUrl }) => { + await createWallet(page, extensionUrl); + await page.close(); +}); + +test.describe('Wallet API', () => { + let demoPage: Page; + + test.beforeEach(async ({ context, demoPageUrl }) => { + demoPage = await context.newPage(); + await demoPage.goto(demoPageUrl); + await demoDappConnect(demoPage, demoPageUrl, context); + }); + test('signing message works', async ({ context }) => { + const newPage = context.waitForEvent('page'); + await demoPage.getByRole('button', { name: 'Sign message' }).click(); + const walletPage = await newPage; + await walletPage + .getByRole('button', { + name: 'Sign', + }) + .click(); + await demoPage.waitForTimeout(3000); + await expect(demoPage.getByText('Error')).toHaveCount(0); + }); +}); diff --git a/apps/wallet/tests/sites-to-cs-messaging.spec.ts b/apps/wallet/tests/sites-to-cs-messaging.spec.ts index 69ef27883a7..aac667175db 100644 --- a/apps/wallet/tests/sites-to-cs-messaging.spec.ts +++ b/apps/wallet/tests/sites-to-cs-messaging.spec.ts @@ -131,7 +131,7 @@ test.describe('Wallet interface', () => { await demoPage.getByRole('button', { name: 'Sign transaction' }).click(); await expect(demoPage.getByText('Error')).toBeVisible(); }); - test('signing a message', async () => { + test('signing a message fails', async () => { await demoPage.getByRole('button', { name: 'Sign message' }).click(); await expect(demoPage.getByText('Error')).toBeVisible(); }); @@ -150,6 +150,16 @@ test.describe('Wallet interface', () => { await expect(approve).toBeVisible(); await expect(approve).toBeEnabled(); }); + test('signing message works', async ({ context }) => { + const newPage = context.waitForEvent('page'); + await demoPage.getByRole('button', { name: 'Sign message' }).click(); + const walletPage = await newPage; + const sign = walletPage.getByRole('button', { + name: 'Sign', + }); + await expect(sign).toBeVisible(); + await expect(sign).toBeEnabled(); + }); test.describe('and using wrong account', () => { test.beforeEach(async () => { await demoPage.getByLabel('Use wrong account').check();