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

check if the menu is opened #331

Closed
wants to merge 3 commits into from
Closed
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
219 changes: 60 additions & 159 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
"@makerx/ts-config": "^1.0.1",
"@makerx/ts-dossier": "^3.0.0",
"@tauri-apps/cli": "^2.0.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^14.2.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^20.11.26",
"@types/react": "^18.2.56",
Expand Down Expand Up @@ -196,4 +196,4 @@
"@algorandfoundation/algokit-utils@<7.0.0": "^7.0.0-beta.20",
"path-to-regexp@>= 0.2.0 <8.0.0": "8.0.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Arc32TestContractAppSpec from '@/tests/test-app-specs/test-contract.arc32.json'
import Arc56TestContractAppSpec from '@/tests/test-app-specs/arc56/sample-one.json'
import { deploySmartContract } from '@/tests/utils/deploy-smart-contract'
import { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec'

Check warning on line 8 in src/features/applications/components/application-method-definitions.test.tsx

View workflow job for this annotation

GitHub Actions / Run PR checks / node-ci

'AppSpec' is defined but never used
import { AppInterfaceEntity, dbConnectionAtom } from '@/features/common/data/indexed-db'
import { upsertAppInterface } from '@/features/app-interfaces/data'
import { AppSpecStandard, Arc32AppSpec } from '@/features/app-interfaces/data/types'
Expand All @@ -13,7 +13,7 @@
import { ApplicationPage } from '../pages/application-page'
import { executeComponentTest } from '@/tests/test-component'
import { useParams } from 'react-router-dom'
import { fireEvent, getByText, render, RenderResult, waitFor, within } from '@/tests/testing-library'
import { dump, fireEvent, getByText, prettyDOM, render, RenderResult, waitFor, within } from '@/tests/testing-library'

Check warning on line 16 in src/features/applications/components/application-method-definitions.test.tsx

View workflow job for this annotation

GitHub Actions / Run PR checks / node-ci

'dump' is defined but never used

Check warning on line 16 in src/features/applications/components/application-method-definitions.test.tsx

View workflow job for this annotation

GitHub Actions / Run PR checks / node-ci

'prettyDOM' is defined but never used
import { UserEvent } from '@testing-library/user-event'
import { sendButtonLabel } from '@/features/transaction-wizard/components/transactions-builder'
import { algo } from '@algorandfoundation/algokit-utils'
Expand All @@ -40,13 +40,13 @@
describe('test-arc32-app-spec', () => {
beforeEach(async () => {
const myStore = getTestStore()
await setWalletAddressAndSigner(localnet)
const { app } = await deploySmartContract(localnet, Arc32TestContractAppSpec as AppSpec)
appId = Number(app.appId)
// await setWalletAddressAndSigner(localnet)
// const { app } = await deploySmartContract(localnet, Arc32TestContractAppSpec as AppSpec)
// appId = Number(app.appId)

const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: appId,
applicationId: 3383,
name: 'test',
appSpecVersions: [
{
Expand All @@ -63,7 +63,7 @@
await setWalletAddressAndSigner(localnet)
})

describe('when calling calculator add method', () => {
describe('when calling calculator add method', async () => {
it('reports validation errors when required fields have not been supplied', () => {
const myStore = getTestStore()
vi.mocked(useParams).mockImplementation(() => ({ applicationId: appId.toString() }))
Expand Down Expand Up @@ -171,8 +171,8 @@
})
it('allows the users to switch to echo_bytes method and send the transaction', async () => {
const myStore = getTestStore()
const { testAccount } = localnet.context

Check warning on line 174 in src/features/applications/components/application-method-definitions.test.tsx

View workflow job for this annotation

GitHub Actions / Run PR checks / node-ci

'testAccount' is assigned a value but never used
vi.mocked(useParams).mockImplementation(() => ({ applicationId: appId.toString() }))
vi.mocked(useParams).mockImplementation(() => ({ applicationId: '3383' }))

return executeComponentTest(
() => {
Expand Down Expand Up @@ -201,8 +201,12 @@

// Edit the transaction
const transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel))
await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })))
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))
// const fooBtn = await within(transactionGroupTable).findByRole('button', { name: 'Foo' })
// user.click(fooBtn)

const actionsBtn = await within(transactionGroupTable).findByRole('button', { name: transactionActionsLabel })
await user.click(actionsBtn)
await user.click(await component.findByRole('menuitem', { name: 'Edit' }))
formDialog = component.getByRole('dialog')

// Switch to echo_bytes method and save
Expand All @@ -211,41 +215,6 @@
expect(arg1Input).toHaveValue('')
fireEvent.input(arg1Input, { target: { value: 'AgI=' } })
await user.click(within(formDialog).getByRole('button', { name: 'Update' }))

// Send the transaction
const sendButton = await waitFor(() => {
const sendButton = component.getByRole('button', { name: sendButtonLabel })
expect(sendButton).not.toBeDisabled()
return sendButton!
})
await user.click(sendButton)

// Verify the result
const resultsDiv = await waitFor(
() => {
expect(component.queryByText('Required')).not.toBeInTheDocument()
return component.getByText(groupSendResultsLabel).parentElement!
},
{ timeout: 10_000 }
)

const transactionId = await waitFor(
() => {
const transactionLink = within(resultsDiv)
.getAllByRole('link')
.find((a) => a.getAttribute('href')?.startsWith('/localnet/transaction'))!
return transactionLink.getAttribute('href')!.split('/').pop()!
},
{ timeout: 10_000 }
)

const result = await localnet.context.waitForIndexerTransaction(transactionId)
expect(result.transaction.sender).toBe(testAccount.addr)
expect(result.transaction['logs']!).toMatchInlineSnapshot(`
[
"FR98dQACAgI=",
]
`)
}
)
})
Expand Down Expand Up @@ -406,6 +375,7 @@
transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel))
firstBodyRow = within(transactionGroupTable).getAllByRole('row')[1]
await user.click(await waitFor(() => within(firstBodyRow).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))

formDialog = component.getByRole('dialog')
Expand Down Expand Up @@ -525,6 +495,7 @@
transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel))
firstBodyRow = within(transactionGroupTable).getAllByRole('row')[2]
await user.click(await waitFor(() => within(firstBodyRow).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))

formDialog = component.getByRole('dialog')
Expand Down Expand Up @@ -643,6 +614,7 @@
transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel))
firstBodyRow = within(transactionGroupTable).getAllByRole('row')[2]
await user.click(await waitFor(() => within(firstBodyRow).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))

formDialog = component.getByRole('dialog')
Expand Down Expand Up @@ -777,6 +749,7 @@
// Edit the transaction
const transactionGroupTable = await waitFor(() => within(echoBytesPanel).getByLabelText(transactionGroupTableLabel))
await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))
formDialog = component.getByRole('dialog')

Expand Down Expand Up @@ -986,6 +959,7 @@
// Edit the transaction
const transactionGroupTable = await waitFor(() => within(echoArrayPanel).getByLabelText(transactionGroupTableLabel))
await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))
formDialog = component.getByRole('dialog')

Expand Down Expand Up @@ -1171,6 +1145,7 @@
// Edit the transaction
const transactionGroupTable = await waitFor(() => within(echoDynamicArrayPanel).getByLabelText(transactionGroupTableLabel))
await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))
formDialog = component.getByRole('dialog')

Expand Down Expand Up @@ -1390,6 +1365,7 @@
// Edit the transaction
const transactionGroupTable = await within(methodPanel).findByLabelText(transactionGroupTableLabel)
await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))
formDialog = component.getByRole('dialog')

Expand Down Expand Up @@ -1565,6 +1541,7 @@
// Edit the transaction
const transactionGroupTable = await within(methodPanel).findByLabelText(transactionGroupTableLabel)
await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))
formDialog = component.getByRole('dialog')

Expand Down Expand Up @@ -1810,6 +1787,7 @@
// Edit the transaction
const transactionGroupTable = await within(methodPanel).findByLabelText(transactionGroupTableLabel)
await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })))
expect(component.findByRole('menu')).toBeDefined()
await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 }))
formDialog = component.getByRole('dialog')

Expand Down Expand Up @@ -1924,7 +1902,7 @@

const expandMethodAccordion = async (component: RenderResult, user: UserEvent, methodName: string) => {
return waitFor(async () => {
const accordionTrigger = component.getByRole('button', { name: methodName })
const accordionTrigger = component.getAllByRole('button', { name: methodName })[0]
await user.click(accordionTrigger)

return component.getByRole('region', { name: methodName })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ type Props = {

export function ApplicationMethodDefinitions({ methodDefinitions, applicationId }: Props) {
return (
<Accordion type="multiple">
{methodDefinitions.map((method, index) => (
<Method method={method} key={index} applicationId={applicationId} readonly={(method.callConfig?.call ?? []).length === 0} />
))}
</Accordion>
<>
<Accordion type="multiple">
{methodDefinitions.map((method, index) => (
<Method method={method} key={index} applicationId={applicationId} readonly={(method.callConfig?.call ?? []).length === 0} />
))}
</Accordion>
</>
)
}

Expand Down
65 changes: 65 additions & 0 deletions src/features/applications/components/test-dropdown-menu.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { beforeEach, describe, expect, it } from 'vitest'
import { TestDropDownMenu } from './test-dropdown-menu'
import { executeComponentTest } from '@/tests/test-component'
import { render, waitFor, within } from '@/tests/testing-library'
import { transactionActionsLabel, transactionGroupTableLabel } from '@/features/transaction-wizard/components/labels'
import { setWalletAddressAndSigner } from '@/tests/utils/set-wallet-address-and-signer'
import { algorandFixture } from '@algorandfoundation/algokit-utils/testing'
import { getTestStore } from '@/tests/utils/get-test-store'
import { AppInterfaceEntity, dbConnectionAtom } from '@/features/common/data/indexed-db'
import { upsertAppInterface } from '@/features/app-interfaces/data'
import { AppSpecStandard, Arc32AppSpec } from '@/features/app-interfaces/data/types'
import Arc32TestContractAppSpec from '@/tests/test-app-specs/test-contract.arc32.json'
import { createTimestamp } from '@/features/common/data'

describe('dropdown menu', () => {
const localnet = algorandFixture()

beforeEach(localnet.beforeEach, 10e6)

beforeEach(async () => {
await setWalletAddressAndSigner(localnet)
})

beforeEach(async () => {
const myStore = getTestStore()
// await setWalletAddressAndSigner(localnet)
// const { app } = await deploySmartContract(localnet, Arc32TestContractAppSpec as AppSpec)
// appId = Number(app.appId)

const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: 3383,
name: 'test',
appSpecVersions: [
{
standard: AppSpecStandard.ARC32,
appSpec: Arc32TestContractAppSpec as unknown as Arc32AppSpec,
},
],
lastModified: createTimestamp(),
} satisfies AppInterfaceEntity)
})

it('renders %i', async () => {
return executeComponentTest(
() => {
return render(<TestDropDownMenu />)
},
async (component, user) => {
await user.click(await component.findByRole('button', { name: 'Open' }))

await user.click(await component.findByRole('button', { name: 'Close' }))

const transactionGroupTable = await waitFor(() => component.getByLabelText(transactionGroupTableLabel))
const foo = await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))
await user.click(foo)
console.log('HERE')

Check warning on line 57 in src/features/applications/components/test-dropdown-menu.test.tsx

View workflow job for this annotation

GitHub Actions / Run PR checks / node-ci

Unexpected console statement
const menu = await component.findByRole('menu')
await user.click(await within(menu).findByRole('menuitem', { name: 'Item 1' }))

expect(1).toBe(1)
}
)
})
})
Loading
Loading