-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tangle-dapp): Setup Tests, Fix Infinite Render on Restaking (#2674)
- Loading branch information
Showing
76 changed files
with
714 additions
and
753 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: test 🧪 | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
# TODO: Re-enable once @webb-tools/sdk-core is removed | ||
# pull_request: | ||
# branches: [develop, staging, master, feature/**] | ||
|
||
# push: | ||
# branches: [develop, staging, master, feature/**] | ||
|
||
jobs: | ||
build_code: | ||
name: run | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['>=18.12.x'] | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Enable corepack | ||
run: | | ||
corepack enable | ||
corepack prepare [email protected] --activate | ||
yarn set version 4.2.2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: yarn | ||
|
||
- name: Install deps | ||
run: yarn install | ||
|
||
- name: Run tests | ||
run: yarn nx run-many --all --target=test | ||
# Fix: JavaScript heap out of memory | ||
# https://github.com/actions/runner-images/issues/70#issuecomment-1191708172 | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'span'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default '/svgUrl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { act, render } from '@testing-library/react'; | ||
import { PolkadotApiProvider } from '@webb-tools/tangle-shared-ui/context/PolkadotApiContext'; | ||
|
||
import { RestakeContextProvider } from '../../context/RestakeContext'; | ||
import { mockMatchMedia } from '../test-utils'; | ||
import Page from './page'; | ||
|
||
describe('Blueprints Page', () => { | ||
beforeAll(() => { | ||
mockMatchMedia(); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render( | ||
<PolkadotApiProvider> | ||
<RestakeContextProvider> | ||
<Page /> | ||
</RestakeContextProvider> | ||
</PolkadotApiProvider>, | ||
); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { act, render } from '@testing-library/react'; | ||
|
||
import BridgeProvider from '../../context/BridgeContext'; | ||
import { mockMatchMedia } from '../test-utils'; | ||
import Page from './page'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
describe('Bridge Page', () => { | ||
beforeAll(() => { | ||
mockMatchMedia(); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render( | ||
<QueryClientProvider client={queryClient}> | ||
<BridgeProvider> | ||
<Page /> | ||
</BridgeProvider> | ||
</QueryClientProvider>, | ||
); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { act, render } from '@testing-library/react'; | ||
|
||
import Page from './page'; | ||
|
||
describe('Claim Page', () => { | ||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render(<Page />); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { act, render } from '@testing-library/react'; | ||
|
||
import Providers from '../providers'; | ||
import { mockFetch, mockMatchMedia } from '../test-utils'; | ||
import Page from './page'; | ||
|
||
describe('Liquid Staking Page', () => { | ||
beforeAll(() => { | ||
mockMatchMedia(); | ||
mockFetch({ country_code: 'US', state: 'CA' }); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render( | ||
<Providers> | ||
<Page /> | ||
</Providers>, | ||
); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { act, render } from '@testing-library/react'; | ||
|
||
import Providers from '../providers'; | ||
import { mockFetch, mockMatchMedia } from '../test-utils'; | ||
import Page from './page'; | ||
|
||
describe('Nomination Page', () => { | ||
beforeAll(() => { | ||
mockMatchMedia(); | ||
mockFetch({ country_code: 'US', state: 'CA' }); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render( | ||
<Providers> | ||
<Page /> | ||
</Providers>, | ||
); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { act, render } from '@testing-library/react'; | ||
|
||
import Page from './page'; | ||
import Providers from './providers'; | ||
import { mockFetch, mockMatchMedia } from './test-utils'; | ||
|
||
describe('Account Page', () => { | ||
beforeAll(() => { | ||
mockMatchMedia(); | ||
mockFetch({ country_code: 'US', state: 'CA' }); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render( | ||
<Providers> | ||
<Page /> | ||
</Providers>, | ||
); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { act, render } from '@testing-library/react'; | ||
|
||
import { mockMatchMedia } from '../../test-utils'; | ||
import Page from './page'; | ||
|
||
describe('Deposit Page', () => { | ||
beforeAll(() => { | ||
mockMatchMedia(); | ||
}); | ||
|
||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render(<Page />); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
apps/tangle-dapp/app/restake/operators/[address]/page.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { act, render } from '@testing-library/react'; | ||
|
||
import { mockMatchMedia } from '../../../test-utils'; | ||
import Page from './page'; | ||
|
||
const address = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'; | ||
|
||
describe('Operators Page', () => { | ||
beforeAll(() => { | ||
mockMatchMedia(); | ||
}); | ||
|
||
it('renders without crashing', async () => { | ||
let container; | ||
await act(async () => { | ||
const result = render( | ||
<Page | ||
params={{ | ||
address, | ||
}} | ||
/>, | ||
); | ||
container = result.container; | ||
}); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
'use client'; | ||
|
||
import { PolkadotApiProvider } from '@webb-tools/tangle-shared-ui/context/PolkadotApiContext'; | ||
import { NuqsAdapter } from 'nuqs/adapters/next/app'; | ||
import { type PropsWithChildren } from 'react'; | ||
|
||
import { RestakeContextProvider } from '../../context/RestakeContext'; | ||
|
||
export default function Providers({ children }: PropsWithChildren) { | ||
return ( | ||
<PolkadotApiProvider> | ||
<RestakeContextProvider> | ||
<NuqsAdapter>{children}</NuqsAdapter> | ||
</RestakeContextProvider> | ||
<RestakeContextProvider>{children}</RestakeContextProvider> | ||
</PolkadotApiProvider> | ||
); | ||
} |
Oops, something went wrong.