Skip to content

Commit

Permalink
Merge branch 'master' into nj/test/e2e-for-wallet-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
nelitow authored Dec 12, 2024
2 parents 14eef3a + d5861eb commit 30e09a2
Show file tree
Hide file tree
Showing 50 changed files with 575 additions and 196 deletions.
5 changes: 0 additions & 5 deletions .changeset/calm-kangaroos-matter.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/dry-flies-add.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/giant-points-happen.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/good-candles-perform.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/orange-points-laugh.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/serious-kiwis-kiss.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/spicy-parents-attend.md

This file was deleted.

7 changes: 0 additions & 7 deletions .github/workflows/pr-tests-e2e-crx-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ jobs:
- name: Generate .env
run: cp packages/app/.env.example packages/app/.env

- name: Build Application
run: pnpm build:app
env:
## increase node.js m memory limit for building
## with sourcemaps
NODE_OPTIONS: "--max-old-space-size=4096"

- uses: ./.github/actions/setup-playwright

- name: Run E2E Tests
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/pr-tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ jobs:
- name: Generate .env
run: cp packages/app/.env.example packages/app/.env

- name: Build Application
run: pnpm build:app
env:
## increase node.js m memory limit for building
## with sourcemaps
NODE_OPTIONS: "--max-old-space-size=4096"

- uses: ./.github/actions/setup-playwright

- name: Run E2E Tests
Expand Down
36 changes: 36 additions & 0 deletions packages/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# fuels-wallet

## 0.44.0

### Minor Changes

- [#1700](https://github.com/FuelLabs/fuels-wallet/pull/1700) [`be181de6`](https://github.com/FuelLabs/fuels-wallet/commit/be181de610d15f18efa977e183d449ae3f871c54) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - feat: implemented recoverWallet method and in case of disaster recover it

- [#1700](https://github.com/FuelLabs/fuels-wallet/pull/1700) [`be181de6`](https://github.com/FuelLabs/fuels-wallet/commit/be181de610d15f18efa977e183d449ae3f871c54) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - feat: synchronize db with chrome storage

- [#1700](https://github.com/FuelLabs/fuels-wallet/pull/1700) [`be181de6`](https://github.com/FuelLabs/fuels-wallet/commit/be181de610d15f18efa977e183d449ae3f871c54) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - feat: create new database and table (outside of react) to identify if only dexiedb database is breaking

- [#1700](https://github.com/FuelLabs/fuels-wallet/pull/1700) [`be181de6`](https://github.com/FuelLabs/fuels-wallet/commit/be181de610d15f18efa977e183d449ae3f871c54) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - chore: report to sentry when there's a recover happening

### Patch Changes

- [#1695](https://github.com/FuelLabs/fuels-wallet/pull/1695) [`89454569`](https://github.com/FuelLabs/fuels-wallet/commit/8945456956dcf4117d1ca0f01ab91c504bb1095e) Thanks [@arthurgeron](https://github.com/arthurgeron)! - Fixed setup page not finding some local assets

- [#1691](https://github.com/FuelLabs/fuels-wallet/pull/1691) [`33f3d77a`](https://github.com/FuelLabs/fuels-wallet/commit/33f3d77ac8b5bf53be33963e1df3e1a03450b731) Thanks [@nelitow](https://github.com/nelitow)! - ### Changed

Updated nanoid to the latest versions for better performance and security.

- [#1692](https://github.com/FuelLabs/fuels-wallet/pull/1692) [`473067c9`](https://github.com/FuelLabs/fuels-wallet/commit/473067c9c3c442b3f51f28c10b99edd1827f1cad) Thanks [@arthurgeron](https://github.com/arthurgeron)! - Updated Biome to 1.9.4 and fixed lint errors.

- [#1639](https://github.com/FuelLabs/fuels-wallet/pull/1639) [`b0b5f2f5`](https://github.com/FuelLabs/fuels-wallet/commit/b0b5f2f529fe0c9844fa35d41c8f18d0978ca151) Thanks [@arthurgeron](https://github.com/arthurgeron)! - Fixed wallet not loading correctly in local environment on Chrome 130+

- [#1704](https://github.com/FuelLabs/fuels-wallet/pull/1704) [`55606980`](https://github.com/FuelLabs/fuels-wallet/commit/55606980a9204d6f21fbb8c290b9b1c6ba2e7dcf) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - chore: reduce reported data to sentry

- [#1696](https://github.com/FuelLabs/fuels-wallet/pull/1696) [`8b68c21e`](https://github.com/FuelLabs/fuels-wallet/commit/8b68c21e39e7b5b0fbb9791c7d306d536a6d37ad) Thanks [@arthurgeron](https://github.com/arthurgeron)! - Fix exception when injecting content in the hello page

- [#1695](https://github.com/FuelLabs/fuels-wallet/pull/1695) [`89454569`](https://github.com/FuelLabs/fuels-wallet/commit/8945456956dcf4117d1ca0f01ab91c504bb1095e) Thanks [@arthurgeron](https://github.com/arthurgeron)! - Upgrade Vite to V6 major

- [#1694](https://github.com/FuelLabs/fuels-wallet/pull/1694) [`cfcf2209`](https://github.com/FuelLabs/fuels-wallet/commit/cfcf220966cafc9bf7cd8861f0421a7560315365) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - chore: update 'dev:crx' script to use default env

- Updated dependencies [[`473067c9`](https://github.com/FuelLabs/fuels-wallet/commit/473067c9c3c442b3f51f28c10b99edd1827f1cad), [`55606980`](https://github.com/FuelLabs/fuels-wallet/commit/55606980a9204d6f21fbb8c290b9b1c6ba2e7dcf)]:
- @fuels/playwright-utils@0.44.0
- @fuel-wallet/connections@0.44.0

## 0.43.0

### Minor Changes
Expand Down
29 changes: 29 additions & 0 deletions packages/app/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ jest.mock('react-dom/test-utils', () => {
};
});

// Replace chromeStorage
jest.mock('./src/systems/Core/services/chromeStorage', () => {
return {
chromeStorage: {
accounts: {
get: jest.fn(),
getAll: jest.fn(),
set: jest.fn(),
remove: jest.fn(),
clear: jest.fn(),
},
networks: {
get: jest.fn(),
getAll: jest.fn(),
set: jest.fn(),
remove: jest.fn(),
clear: jest.fn(),
},
vaults: {
get: jest.fn(),
getAll: jest.fn(),
set: jest.fn(),
remove: jest.fn(),
clear: jest.fn(),
},
},
};
});

console.warn = jest.fn();

const noop = () => {};
Expand Down
1 change: 0 additions & 1 deletion packages/app/load.envs.cts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { resolve } from 'node:path';
import { config } from 'dotenv';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fuels-wallet",
"private": true,
"version": "0.43.0",
"version": "0.44.0",
"type": "module",
"database": "23",
"scripts": {
Expand Down
3 changes: 0 additions & 3 deletions packages/app/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { join } from 'node:path';
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import {
type PlaywrightTestConfig,
defineConfig,
devices,
} from '@playwright/test';
import './load.envs';
import './load.envs.cts';

const PORT = process.env.PORT;
Expand Down
7 changes: 2 additions & 5 deletions packages/app/playwright.crx-lock.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import { join } from 'path';
import { defineConfig, devices } from '@playwright/test';
import { playwrightConfig } from './playwright.config';

const __dirname = new URL('.', import.meta.url).pathname;
import './load.envs.cts';

export default defineConfig({
...playwrightConfig,
testMatch: join(__dirname, './playwright/crx/lock.test.ts'),
testMatch: 'playwright/crx/lock.test.ts',
testIgnore: undefined,
projects: [
{
Expand Down
3 changes: 1 addition & 2 deletions packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NetworkData, Account as WalletAccount } from '@fuel-wallet/types';
import { type Locator, type Page, expect } from '@playwright/test';
import { type Locator, expect } from '@playwright/test';

import {
delay,
Expand All @@ -10,7 +10,6 @@ import {
hasText,
reload,
seedWallet,
visit,
waitAriaLabel,
} from '../commons';
import {
Expand Down
36 changes: 22 additions & 14 deletions packages/app/playwright/crx/lock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ import { test } from './utils';
test.setTimeout(360_000);

test.describe('Lock FuelWallet after inactivity', () => {
test('If user opens popup it should force open a sign-up page', async ({
context,
extensionId,
}) => {
const popupPage = await context.newPage();
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
const page = await context.waitForEvent('page', {
predicate: (page) => page.url().includes('sign-up'),
});
expect(page.url()).toContain('sign-up');
});

test('should lock the wallet after 1 minute of inactivity (config in .env file)', async ({
context,
baseURL,
Expand Down Expand Up @@ -50,19 +62,7 @@ test.describe('Lock FuelWallet after inactivity', () => {

await test.step('Create wallet', async () => {
const pages = context.pages();
let page = pages.find((page) => page.url().includes('sign-up'));

if (!page) {
page = await context.waitForEvent('page', {
predicate: (page) => page.url().includes('sign-up'),
timeout: 10000, // Adjust timeout as needed
});
}

if (!page) {
throw new Error('Sign-up page did not open');
}

const [page] = pages.filter((page) => page.url().includes('sign-up'));
await reload(page);
await getElementByText(page, /Create new wallet/i).click();

Expand Down Expand Up @@ -97,6 +97,7 @@ test.describe('Lock FuelWallet after inactivity', () => {

/** Account created */
await hasText(page, /Wallet created successfully/i, 0, 15000);

await page.close();
});

Expand All @@ -111,10 +112,17 @@ test.describe('Lock FuelWallet after inactivity', () => {
await getByAriaLabel(popupPage, 'Accounts').click();
await popupPage.waitForTimeout(65_000);
await hasText(popupPage, /Assets/i);

const pages = context.pages();
const walletPages = pages.filter((page) => {
return page.url().includes('chrome-extension://');
});
for (const page of walletPages) {
await page.close();
}
});

await test.step('Resume auto-lock timer after closing wallet', async () => {
await popupPage.close();
const page = await context.newPage();
await page.waitForTimeout(65_000);
await page.goto(`chrome-extension://${extensionId}/popup.html`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const BalanceAssets = ({
[balances]
);

if (isLoading) return <AssetList.Loading items={4} />;
if (isLoading || !balances) return <AssetList.Loading items={4} />;
const isEmpty = !balances || !balances.length;
if (isEmpty) return <AssetList.Empty {...emptyProps} />;
const balancesToShow = balances.filter(
Expand All @@ -40,6 +40,7 @@ export const BalanceAssets = ({
function toggle() {
setShowUnknown((s) => !s);
}

return (
<CardList>
{balancesToShow.map((balance) => {
Expand All @@ -49,7 +50,7 @@ export const BalanceAssets = ({

return (
<AssetItem
key={balance.asset?.name}
key={balance.assetId + balance.asset?.name}
fuelAsset={balance.asset}
amount={balance.amount}
onRemove={onRemove}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const FuelAddress = ({
css,
}: AddressProps) => {
const account = useMemo<string>(() => {
if (!address) return '';
if (isContract) return Address.fromDynamicInput(address).toB256();
return Address.fromDynamicInput(address).toString();
}, [isContract, address]);
Expand Down
7 changes: 2 additions & 5 deletions packages/app/src/systems/Account/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import { Services } from '~/store';

export function accountEvents(store: Store) {
return {
reloadBalance() {
store.send(Services.accounts, { type: 'RELOAD_BALANCE' });
},
updateAccounts() {
store.send(Services.accounts, { type: 'REFRESH_ACCOUNTS' });
refreshAccounts(input?: { skipLoading?: boolean }) {
store.send(Services.accounts, { type: 'REFRESH_ACCOUNTS', input });
},
setCurrentAccount(account: Account) {
store.send(Services.accounts, {
Expand Down
4 changes: 1 addition & 3 deletions packages/app/src/systems/Account/hooks/useAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ const selectors = {
};

const listenerAccountFetcher = () => {
store.send(Services.accounts, {
type: 'REFRESH_ACCOUNT',
});
store.refreshAccounts({ skipLoading: true });
};

export function useAccounts() {
Expand Down
Loading

0 comments on commit 30e09a2

Please sign in to comment.