Skip to content
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"zustand": "^5.0.14"
},
"devDependencies": {
"@axe-core/playwright": "^4.12.1",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
"@playwright/test": "^1.61.0",
Expand All @@ -75,7 +76,7 @@
"jest-image-snapshot": "^6.5.2",
"msw": "^2",
"msw-storybook-addon": "^2",
"playwright": "1.60.0",
"playwright": "^1.61.0",
"postcss": "^8.5.0",
"prettier": "^3.0.0",
"storybook": "^8",
Expand Down
59 changes: 24 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/components/ChainSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function ChainSwitcher({ disabledChains = [] }: { disabledChains?: Chain[
<select
value={chain}
onChange={(e) => setChain(e.target.value as Chain)}
aria-label="Chain"
className="h-8 appearance-none border border-outline-variant bg-surface px-3 py-1.5 pr-7 font-mono text-[10px] uppercase tracking-widest text-primary focus:border-primary focus:outline-none sm:h-9 sm:px-4 sm:py-2 sm:pr-8 sm:text-xs"
>
{chains.map((c) => (
Expand Down
47 changes: 24 additions & 23 deletions src/components/StellarReceive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import type { ImportResult } from '@/lib/stealthLabels';
import { KeyVault } from '@/vault';
import { STELLAR_ASSETS, getAssetByKey, parseAssetBalances } from '@/lib/stellar/assets';
import { useStellarNotifications } from '@/hooks/useStellarNotifications';
import { useStealthLabels } from '@/hooks/useStealthLabels';
import { StellarBatchWithdrawModal } from '@/components/StellarBatchWithdrawModal';

const ANNOUNCER_CONTRACT = 'CCJLJ2QRBJAAKIG6ELNQVXLLWMKKWVN5O2FKWUETHZGMPAD4MHK7WVWL';
Expand Down Expand Up @@ -1199,6 +1200,29 @@ export function StellarReceive() {
}
}, [stellarKeys, t]);

const handleToggleNotifications = useCallback(async () => {
if (notifications.state.enabled) {
await notifications.disableNotifications();
if (address) {
await notifications.unregisterViewingKey(address);
}
} else {
await notifications.enableNotifications();
if (address && stellarKeys) {
await notifications.registerViewingKey(address, stellarKeys);
}
}
}, [notifications, address, stellarKeys]);

const handleFireTestNotification = useCallback(async () => {
try {
await notifications.fireTestNotification();
} catch (err) {
console.error('Failed to fire test notification:', err);
setError(err instanceof Error ? err.message : 'Failed to fire test notification');
}
}, [notifications]);

if (!isConnected) {
return (
<section className="flex flex-col gap-3">
Expand Down Expand Up @@ -1265,29 +1289,6 @@ export function StellarReceive() {
setTimeout(() => setImportMessage(null), 3000);
};

const handleToggleNotifications = useCallback(async () => {
if (notifications.state.enabled) {
await notifications.disableNotifications();
if (address) {
await notifications.unregisterViewingKey(address);
}
} else {
await notifications.enableNotifications();
if (address && stellarKeys) {
await notifications.registerViewingKey(address, stellarKeys);
}
}
}, [notifications, address, stellarKeys]);

const handleFireTestNotification = useCallback(async () => {
try {
await notifications.fireTestNotification();
} catch (err) {
console.error('Failed to fire test notification:', err);
setError(err instanceof Error ? err.message : 'Failed to fire test notification');
}
}, [notifications]);

return (
<>
<input
Expand Down
22 changes: 22 additions & 0 deletions tests/a11y/a11y-fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test as base } from '@playwright/test';

const MOCK_ADDRESS = 'GCDURJMLJBNVUVWXZ7UBXEIAEC4ONEWPWK6KDUUSDTUJJGXCSMBC2XHX';

export const test = base.extend({});

export async function mockConnectedWallet(page: import('@playwright/test').Page) {
await page.addInitScript((address) => {
(window as any).freighter = {
isConnected: async () => ({ isConnected: true }),
isAllowed: async () => ({ isAllowed: true }),
getUserInfo: async () => ({ publicKey: address }),
getPublicKey: async () => address,
getAddress: async () => ({ address }),
requestAccess: async () => {},
signMessage: async () => new Uint8Array(64).fill(1),
signTransaction: async () => 'mock-tx',
};
}, MOCK_ADDRESS);
}

export { expect } from '@playwright/test';
50 changes: 50 additions & 0 deletions tests/a11y/send.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';
import { mockConnectedWallet } from './a11y-fixtures';

test.describe('Accessibility - /send', () => {
test('has zero critical or serious violations (Stellar, disconnected)', async ({ page }) => {
await page.goto('/send');
await page
.locator('select')
.filter({ has: page.locator('option[value="stellar"]') })
.selectOption('stellar');

const results = await new AxeBuilder({ page })
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])
.analyze();

const seriousOrCritical = results.violations.filter(
(v) => v.impact === 'critical' || v.impact === 'serious',
);

if (seriousOrCritical.length > 0) {
console.log(JSON.stringify(seriousOrCritical, null, 2));
}

expect(seriousOrCritical).toEqual([]);
});

test('has zero critical or serious violations (Stellar, connected)', async ({ page }) => {
await mockConnectedWallet(page);
await page.goto('/send');
await page
.locator('select')
.filter({ has: page.locator('option[value="stellar"]') })
.selectOption('stellar');

const results = await new AxeBuilder({ page })
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])
.analyze();

const seriousOrCritical = results.violations.filter(
(v) => v.impact === 'critical' || v.impact === 'serious',
);

if (seriousOrCritical.length > 0) {
console.log(JSON.stringify(seriousOrCritical, null, 2));
}

expect(seriousOrCritical).toEqual([]);
});
});
Loading