From 043faeaac396959e958d2c5f2a8e1f25f20b28a1 Mon Sep 17 00:00:00 2001 From: Jaco Date: Fri, 17 Mar 2023 10:16:43 +0200 Subject: [PATCH] Bump TS to 5.0, adjust TS aliases (#9193) * Adjust TS aliases (test-support problematic) * Bump TS to 5 * Flatten paths (somewhat) --- package.json | 2 +- .../page-accounts/src/Accounts/index.spec.ts | 9 ++++----- .../src/CreateAccount.slow.spec.tsx | 6 +++--- .../page-accounts/src/Sidebar/Sidebar.spec.tsx | 8 ++++---- .../page-accounts/src/modals/Create.spec.tsx | 4 ++-- .../test/pageElements/AccountRow.tsx | 2 +- .../page-accounts/test/pages/accountsPage.tsx | 7 ++++--- .../page-addresses/src/Contacts/index.spec.ts | 6 +++--- .../page-addresses/test/pages/addressesPage.tsx | 7 ++++--- .../page-bounties/src/Bounties.slow.spec.tsx | 9 ++++----- packages/page-bounties/src/Bounties.spec.ts | 11 +++++------ .../determineUnassignCuratorAction.spec.ts | 4 ++-- .../page-bounties/test/pages/bountiesPage.tsx | 2 +- packages/test-support/scripts/createBounties.ts | 4 ++-- .../scripts/lib/bountyWaitFunctions.ts | 6 ++++-- .../scripts/lib/changeBountyStateFunctions.ts | 2 +- packages/test-support/scripts/lib/helpers.ts | 4 ++-- .../test-support/scripts/lib/multiFunctions.ts | 2 +- .../{bounties/bountyFactory.ts => bounties.ts} | 2 +- .../{stakingInfo/stakingLedger.ts => staking.ts} | 0 .../{treasury/proposalFactory.ts => treasury.ts} | 14 +++++++++++--- .../src/creation/treasury/defaults.ts | 12 ------------ .../src/hooks/{mockHooks.ts => index.ts} | 2 +- .../src/mockData/{registrations.ts => index.ts} | 0 packages/test-support/src/pagesElements/index.ts | 1 + packages/test-support/src/types.ts | 2 ++ .../test-support/src/utils/accountDefaults.ts | 2 +- packages/test-support/src/utils/index.ts | 8 ++++++++ packages/test-support/src/utils/waitFor.ts | 4 ++-- tsconfig.base.json | 13 ++++++++++++- yarn.lock | 16 ++++++++-------- 31 files changed, 95 insertions(+), 76 deletions(-) rename packages/test-support/src/creation/{bounties/bountyFactory.ts => bounties.ts} (97%) rename packages/test-support/src/creation/{stakingInfo/stakingLedger.ts => staking.ts} (100%) rename packages/test-support/src/creation/{treasury/proposalFactory.ts => treasury.ts} (69%) delete mode 100644 packages/test-support/src/creation/treasury/defaults.ts rename packages/test-support/src/hooks/{mockHooks.ts => index.ts} (83%) rename packages/test-support/src/mockData/{registrations.ts => index.ts} (100%) create mode 100644 packages/test-support/src/utils/index.ts diff --git a/package.json b/package.json index 5af1321b92..d0f2dd4f41 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,6 @@ "@polkadot/x-textencoder": "^11.0.2", "@polkadot/x-ws": "^11.0.2", "styled-components": "^5.3.1", - "typescript": "^4.9.5" + "typescript": "^5.0.2" } } diff --git a/packages/page-accounts/src/Accounts/index.spec.ts b/packages/page-accounts/src/Accounts/index.spec.ts index d9d937c67e..1e7630ff60 100644 --- a/packages/page-accounts/src/Accounts/index.spec.ts +++ b/packages/page-accounts/src/Accounts/index.spec.ts @@ -10,11 +10,10 @@ import i18next from '@polkadot/react-components/i18n'; import { toShortAddress } from '@polkadot/react-components/util'; import { AddressFlags } from '@polkadot/react-hooks/types'; import { anAccountWithBalance, anAccountWithBalanceAndMeta, anAccountWithInfo, anAccountWithInfoAndMeta, anAccountWithMeta, anAccountWithStaking } from '@polkadot/test-support/creation/account'; -import { makeStakingLedger as ledger } from '@polkadot/test-support/creation/stakingInfo/stakingLedger'; -import { alice, bob, MemoryStore } from '@polkadot/test-support/keyring/index'; -import { Table } from '@polkadot/test-support/pagesElements/index'; -import { balance, showBalance } from '@polkadot/test-support/utils/balance'; -import { mockApiHooks } from '@polkadot/test-support/utils/mockApiHooks'; +import { makeStakingLedger as ledger } from '@polkadot/test-support/creation/staking'; +import { alice, bob, MemoryStore } from '@polkadot/test-support/keyring'; +import { Table } from '@polkadot/test-support/pagesElements'; +import { balance, mockApiHooks, showBalance } from '@polkadot/test-support/utils'; import { u32 } from '@polkadot/types'; import { TypeRegistry } from '@polkadot/types/create'; import { AccountId, Multisig, ProxyDefinition, Timepoint, Voting, VotingDelegating } from '@polkadot/types/interfaces'; diff --git a/packages/page-accounts/src/CreateAccount.slow.spec.tsx b/packages/page-accounts/src/CreateAccount.slow.spec.tsx index c1295e7c85..f485a56271 100644 --- a/packages/page-accounts/src/CreateAccount.slow.spec.tsx +++ b/packages/page-accounts/src/CreateAccount.slow.spec.tsx @@ -13,9 +13,9 @@ import { ThemeProvider } from 'styled-components'; import AccountsApp from '@polkadot/app-accounts'; import { lightTheme } from '@polkadot/apps/themes'; import { ApiCtxRoot } from '@polkadot/react-api'; -import { MemoryStore } from '@polkadot/test-support/keyring/index'; -import { WaitForApi } from '@polkadot/test-support/react/index'; -import { SUBSTRATE_PORT } from '@polkadot/test-support/substrate/index'; +import { MemoryStore } from '@polkadot/test-support/keyring'; +import { WaitForApi } from '@polkadot/test-support/react'; +import { SUBSTRATE_PORT } from '@polkadot/test-support/substrate'; function noop (): void { // do nothing diff --git a/packages/page-accounts/src/Sidebar/Sidebar.spec.tsx b/packages/page-accounts/src/Sidebar/Sidebar.spec.tsx index e7650c5e1c..30347407b3 100644 --- a/packages/page-accounts/src/Sidebar/Sidebar.spec.tsx +++ b/packages/page-accounts/src/Sidebar/Sidebar.spec.tsx @@ -8,10 +8,10 @@ import { fireEvent, screen, waitFor, within } from '@testing-library/react'; import i18next from '@polkadot/react-components/i18n'; import { AddressFlags } from '@polkadot/react-hooks/types'; import { anAccount, anAccountWithInfo, anAccountWithMeta } from '@polkadot/test-support/creation/account'; -import { alice, bob, MemoryStore } from '@polkadot/test-support/keyring/index'; -import { charlieShortAddress, ferdieShortAddress, mockRegistration, registrars } from '@polkadot/test-support/mockData/registrations'; -import { Sidebar } from '@polkadot/test-support/pagesElements/Sidebar'; -import { mockApiHooks } from '@polkadot/test-support/utils/mockApiHooks'; +import { alice, bob, MemoryStore } from '@polkadot/test-support/keyring'; +import { charlieShortAddress, ferdieShortAddress, mockRegistration, registrars } from '@polkadot/test-support/mockData'; +import { Sidebar } from '@polkadot/test-support/pagesElements'; +import { mockApiHooks } from '@polkadot/test-support/utils'; import { RegistrationJudgement } from '@polkadot/types/interfaces'; import { keyring } from '@polkadot/ui-keyring'; diff --git a/packages/page-accounts/src/modals/Create.spec.tsx b/packages/page-accounts/src/modals/Create.spec.tsx index 95e7d30d46..264943231a 100644 --- a/packages/page-accounts/src/modals/Create.spec.tsx +++ b/packages/page-accounts/src/modals/Create.spec.tsx @@ -6,8 +6,8 @@ import { fireEvent, screen, waitForElementToBeRemoved } from '@testing-library/react'; import i18next from '@polkadot/react-components/i18n'; -import { MemoryStore } from '@polkadot/test-support/keyring/index'; -import { assertButtonDisabled, assertText, clickButton, fillInput } from '@polkadot/test-support/utils/renderedScreenUtils'; +import { MemoryStore } from '@polkadot/test-support/keyring'; +import { assertButtonDisabled, assertText, clickButton, fillInput } from '@polkadot/test-support/utils'; import { keyring } from '@polkadot/ui-keyring'; import { cryptoWaitReady } from '@polkadot/util-crypto'; diff --git a/packages/page-accounts/test/pageElements/AccountRow.tsx b/packages/page-accounts/test/pageElements/AccountRow.tsx index f01508a09a..fba4487ab7 100644 --- a/packages/page-accounts/test/pageElements/AccountRow.tsx +++ b/packages/page-accounts/test/pageElements/AccountRow.tsx @@ -3,7 +3,7 @@ import { within } from '@testing-library/react'; -import { Row } from '@polkadot/test-support/pagesElements/Row'; +import { Row } from '@polkadot/test-support/pagesElements'; export class AccountRow extends Row { async assertParentAccountName (expectedParentAccount: string): Promise { diff --git a/packages/page-accounts/test/pages/accountsPage.tsx b/packages/page-accounts/test/pages/accountsPage.tsx index c1e653f57b..25c3fbffe5 100644 --- a/packages/page-accounts/test/pages/accountsPage.tsx +++ b/packages/page-accounts/test/pages/accountsPage.tsx @@ -1,14 +1,15 @@ // Copyright 2017-2023 @polkadot/page-accounts authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { AccountOverrides } from '@polkadot/test-support/types'; + import { fireEvent, screen, within } from '@testing-library/react'; import React from 'react'; import { anAccount } from '@polkadot/test-support/creation/account'; import { Page } from '@polkadot/test-support/pages/Page'; -import { Sidebar } from '@polkadot/test-support/pagesElements/Sidebar'; -import { AccountOverrides } from '@polkadot/test-support/types'; -import { assertText, clickButton } from '@polkadot/test-support/utils/renderedScreenUtils'; +import { Sidebar } from '@polkadot/test-support/pagesElements'; +import { assertText, clickButton } from '@polkadot/test-support/utils'; import { settings } from '@polkadot/ui-settings'; import AccountOverview from '../../src/Accounts/index.js'; diff --git a/packages/page-addresses/src/Contacts/index.spec.ts b/packages/page-addresses/src/Contacts/index.spec.ts index acef3159ad..63b0f815e1 100644 --- a/packages/page-addresses/src/Contacts/index.spec.ts +++ b/packages/page-addresses/src/Contacts/index.spec.ts @@ -7,9 +7,9 @@ import { screen } from '@testing-library/react'; import i18next from '@polkadot/react-components/i18n'; import { aContactWithBalance } from '@polkadot/test-support/creation/contact'; -import { MemoryStore } from '@polkadot/test-support/keyring/index'; -import { Table } from '@polkadot/test-support/pagesElements/index'; -import { balance } from '@polkadot/test-support/utils/balance'; +import { MemoryStore } from '@polkadot/test-support/keyring'; +import { Table } from '@polkadot/test-support/pagesElements'; +import { balance } from '@polkadot/test-support/utils'; import { keyring } from '@polkadot/ui-keyring'; import { AddressesPage } from '../../test/pages/addressesPage.js'; diff --git a/packages/page-addresses/test/pages/addressesPage.tsx b/packages/page-addresses/test/pages/addressesPage.tsx index 8bcbfad2a1..b1ce354b07 100644 --- a/packages/page-addresses/test/pages/addressesPage.tsx +++ b/packages/page-addresses/test/pages/addressesPage.tsx @@ -1,13 +1,14 @@ // Copyright 2017-2023 @polkadot/page-addresses authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { AccountOverrides as ContactOverrides } from '@polkadot/test-support/types'; + import React from 'react'; import { aContact } from '@polkadot/test-support/creation/contact'; import { Page } from '@polkadot/test-support/pages/Page'; -import { Row } from '@polkadot/test-support/pagesElements/index'; -import { AccountOverrides as ContactOverrides } from '@polkadot/test-support/types'; -import { mockAccountHooks } from '@polkadot/test-support/utils/accountDefaults'; +import { Row } from '@polkadot/test-support/pagesElements'; +import { mockAccountHooks } from '@polkadot/test-support/utils'; import AddressOverview from '../../src/Contacts/index.js'; diff --git a/packages/page-bounties/src/Bounties.slow.spec.tsx b/packages/page-bounties/src/Bounties.slow.spec.tsx index feea1134e5..17c1037fef 100644 --- a/packages/page-bounties/src/Bounties.slow.spec.tsx +++ b/packages/page-bounties/src/Bounties.slow.spec.tsx @@ -12,11 +12,10 @@ import { ThemeProvider } from 'styled-components'; import { lightTheme } from '@polkadot/apps/themes'; import { ApiCtxRoot } from '@polkadot/react-api'; -import { createApi } from '@polkadot/test-support/api/index'; -import { MemoryStore } from '@polkadot/test-support/keyring/index'; -import { aliceSigner } from '@polkadot/test-support/keyring/signers'; -import { WaitForApi } from '@polkadot/test-support/react/index'; -import { execute } from '@polkadot/test-support/transaction/execute'; +import { createApi } from '@polkadot/test-support/api'; +import { aliceSigner, MemoryStore } from '@polkadot/test-support/keyring'; +import { WaitForApi } from '@polkadot/test-support/react'; +import { execute } from '@polkadot/test-support/transaction'; import { BN } from '@polkadot/util'; import BountiesApp from './index.js'; diff --git a/packages/page-bounties/src/Bounties.spec.ts b/packages/page-bounties/src/Bounties.spec.ts index 87faad3070..cee9b175d9 100644 --- a/packages/page-bounties/src/Bounties.spec.ts +++ b/packages/page-bounties/src/Bounties.spec.ts @@ -12,13 +12,12 @@ import { fireEvent } from '@testing-library/react'; import { ApiPromise } from '@polkadot/api'; import i18next from '@polkadot/react-components/i18n'; -import { createAugmentedApi } from '@polkadot/test-support/api/index'; +import { createAugmentedApi } from '@polkadot/test-support/api'; import { balanceOf } from '@polkadot/test-support/creation/balance'; -import { BountyFactory } from '@polkadot/test-support/creation/bounties/bountyFactory'; -import { proposalFactory } from '@polkadot/test-support/creation/treasury/proposalFactory'; -import { mockHooks } from '@polkadot/test-support/hooks/mockHooks'; -import { alice, bob } from '@polkadot/test-support/keyring/addresses'; -import { MemoryStore } from '@polkadot/test-support/keyring/index'; +import { BountyFactory } from '@polkadot/test-support/creation/bounties'; +import { proposalFactory } from '@polkadot/test-support/creation/treasury'; +import { mockHooks } from '@polkadot/test-support/hooks'; +import { alice, bob, MemoryStore } from '@polkadot/test-support/keyring'; import { keyring } from '@polkadot/ui-keyring'; import { BN } from '@polkadot/util'; diff --git a/packages/page-bounties/src/helpers/determineUnassignCuratorAction.spec.ts b/packages/page-bounties/src/helpers/determineUnassignCuratorAction.spec.ts index 92d0e9238f..ee343509c3 100644 --- a/packages/page-bounties/src/helpers/determineUnassignCuratorAction.spec.ts +++ b/packages/page-bounties/src/helpers/determineUnassignCuratorAction.spec.ts @@ -3,8 +3,8 @@ /// -import { createAugmentedApi } from '@polkadot/test-support/api/index'; -import { BountyFactory } from '@polkadot/test-support/creation/bounties/bountyFactory'; +import { createAugmentedApi } from '@polkadot/test-support/api'; +import { BountyFactory } from '@polkadot/test-support/creation/bounties'; import { BN } from '@polkadot/util'; import { determineUnassignCuratorAction } from './determineUnassignCuratorAction.js'; diff --git a/packages/page-bounties/test/pages/bountiesPage.tsx b/packages/page-bounties/test/pages/bountiesPage.tsx index 55c433580f..8636e3a272 100644 --- a/packages/page-bounties/test/pages/bountiesPage.tsx +++ b/packages/page-bounties/test/pages/bountiesPage.tsx @@ -18,7 +18,7 @@ import { ApiProps } from '@polkadot/react-api/types'; import { KeyringCtxRoot } from '@polkadot/react-hooks'; import { QueueCtx } from '@polkadot/react-hooks/ctx/Queue'; import { balanceOf } from '@polkadot/test-support/creation/balance'; -import { BountyFactory } from '@polkadot/test-support/creation/bounties/bountyFactory'; +import { BountyFactory } from '@polkadot/test-support/creation/bounties'; import { TypeRegistry } from '@polkadot/types/create'; import { BountyIndex, BountyStatus } from '@polkadot/types/interfaces'; diff --git a/packages/test-support/scripts/createBounties.ts b/packages/test-support/scripts/createBounties.ts index b4bbf65062..2ab2e8ce96 100644 --- a/packages/test-support/scripts/createBounties.ts +++ b/packages/test-support/scripts/createBounties.ts @@ -1,8 +1,8 @@ // Copyright 2017-2023 @polkadot/test-support authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { createApi } from '@polkadot/test-support/api/index'; -import { aliceSigner } from '@polkadot/test-support/keyring/index'; +import { createApi } from '@polkadot/test-support/api'; +import { aliceSigner } from '@polkadot/test-support/keyring'; import { multiAcceptCurator, multiApproveBounty, multiAwardBounty, multiClaimBounty, multiProposeBounty, multiProposeCurator, multiWaitForBountyFunded, multiWaitForClaim } from './lib/multiFunctions.js'; diff --git a/packages/test-support/scripts/lib/bountyWaitFunctions.ts b/packages/test-support/scripts/lib/bountyWaitFunctions.ts index 1df60711c3..a0bd87b0d0 100644 --- a/packages/test-support/scripts/lib/bountyWaitFunctions.ts +++ b/packages/test-support/scripts/lib/bountyWaitFunctions.ts @@ -1,9 +1,11 @@ // Copyright 2017-2023 @polkadot/test-support authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { DeriveBounty } from '@polkadot/api-derive/types'; +import type { WaitOptions } from '@polkadot/test-support/types'; + import { ApiPromise } from '@polkadot/api'; -import { DeriveBounty } from '@polkadot/api-derive/types'; -import { waitFor, WaitOptions } from '@polkadot/test-support/utils/waitFor'; +import { waitFor } from '@polkadot/test-support/utils'; type bStatus = 'isFunded' | 'isActive'; diff --git a/packages/test-support/scripts/lib/changeBountyStateFunctions.ts b/packages/test-support/scripts/lib/changeBountyStateFunctions.ts index d8c266d588..7de64e1cd7 100644 --- a/packages/test-support/scripts/lib/changeBountyStateFunctions.ts +++ b/packages/test-support/scripts/lib/changeBountyStateFunctions.ts @@ -5,7 +5,7 @@ import type { ApiPromise } from '@polkadot/api'; import type { KeyringPair } from '@polkadot/keyring/types'; import type { BN } from '@polkadot/util'; -import { execute } from '@polkadot/test-support/transaction/index'; +import { execute } from '@polkadot/test-support/transaction'; import { acceptMotion, fillTreasury, getMotion, proposeMotion } from './helpers.js'; diff --git a/packages/test-support/scripts/lib/helpers.ts b/packages/test-support/scripts/lib/helpers.ts index 101695777c..cd27ae6549 100644 --- a/packages/test-support/scripts/lib/helpers.ts +++ b/packages/test-support/scripts/lib/helpers.ts @@ -5,8 +5,8 @@ import { ApiPromise } from '@polkadot/api'; import { SubmittableExtrinsic } from '@polkadot/api/types'; import { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import { KeyringPair } from '@polkadot/keyring/types'; -import { charlieSigner, daveSigner, eveSigner, ferdieSigner } from '@polkadot/test-support/keyring/index'; -import { execute } from '@polkadot/test-support/transaction/index'; +import { charlieSigner, daveSigner, eveSigner, ferdieSigner } from '@polkadot/test-support/keyring'; +import { execute } from '@polkadot/test-support/transaction'; import { Hash } from '@polkadot/types/interfaces'; import { BN } from '@polkadot/util'; diff --git a/packages/test-support/scripts/lib/multiFunctions.ts b/packages/test-support/scripts/lib/multiFunctions.ts index da0e345541..a9269c0a1d 100644 --- a/packages/test-support/scripts/lib/multiFunctions.ts +++ b/packages/test-support/scripts/lib/multiFunctions.ts @@ -3,7 +3,7 @@ import { ApiPromise } from '@polkadot/api'; import { KeyringPair } from '@polkadot/keyring/types'; -import { execute } from '@polkadot/test-support/transaction/index'; +import { execute } from '@polkadot/test-support/transaction'; import { BN } from '@polkadot/util'; import { waitForBountyState, waitForClaim } from './bountyWaitFunctions.js'; diff --git a/packages/test-support/src/creation/bounties/bountyFactory.ts b/packages/test-support/src/creation/bounties.ts similarity index 97% rename from packages/test-support/src/creation/bounties/bountyFactory.ts rename to packages/test-support/src/creation/bounties.ts index 4971fe72e4..2be3c641f1 100644 --- a/packages/test-support/src/creation/bounties/bountyFactory.ts +++ b/packages/test-support/src/creation/bounties.ts @@ -6,7 +6,7 @@ import { BountyIndex, BountyStatus } from '@polkadot/types/interfaces'; import { PalletBountiesBounty } from '@polkadot/types/lookup'; import { Registry } from '@polkadot/types/types'; -import { balanceOf } from '../balance.js'; +import { balanceOf } from './balance.js'; export class BountyFactory { readonly #api: ApiPromise; diff --git a/packages/test-support/src/creation/stakingInfo/stakingLedger.ts b/packages/test-support/src/creation/staking.ts similarity index 100% rename from packages/test-support/src/creation/stakingInfo/stakingLedger.ts rename to packages/test-support/src/creation/staking.ts diff --git a/packages/test-support/src/creation/treasury/proposalFactory.ts b/packages/test-support/src/creation/treasury.ts similarity index 69% rename from packages/test-support/src/creation/treasury/proposalFactory.ts rename to packages/test-support/src/creation/treasury.ts index 8c25d2790f..a3b363105e 100644 --- a/packages/test-support/src/creation/treasury/proposalFactory.ts +++ b/packages/test-support/src/creation/treasury.ts @@ -1,13 +1,15 @@ // Copyright 2017-2023 @polkadot/test-support authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { SubmittableExtrinsic } from '@polkadot/api/types'; import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import { ApiPromise } from '@polkadot/api'; -import { SubmittableExtrinsic } from '@polkadot/api/types'; +import { BN_ONE, BN_ZERO } from '@polkadot/util'; -import { alice, bob } from '../../keyring/addresses.js'; -import { aHash } from '../hashes.js'; +import { alice, bob } from '../keyring/addresses.js'; +import { balanceOf } from './balance.js'; +import { aHash } from './hashes.js'; export interface ProposalFactory { aProposal: (extrinsic: SubmittableExtrinsic<'promise'>, ayes?: string[], nays?: string[]) => DeriveCollectiveProposal @@ -29,3 +31,9 @@ export function proposalFactory (api: ApiPromise): ProposalFactory { }) }; } + +export const defaultTreasury = { + burn: BN_ONE, + spendPeriod: BN_ZERO, + value: balanceOf(1) +}; diff --git a/packages/test-support/src/creation/treasury/defaults.ts b/packages/test-support/src/creation/treasury/defaults.ts deleted file mode 100644 index b101e76a0c..0000000000 --- a/packages/test-support/src/creation/treasury/defaults.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017-2023 @polkadot/test-support authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import { BN_ONE, BN_ZERO } from '@polkadot/util'; - -import { balanceOf } from '../balance.js'; - -export const defaultTreasury = { - burn: BN_ONE, - spendPeriod: BN_ZERO, - value: balanceOf(1) -}; diff --git a/packages/test-support/src/hooks/mockHooks.ts b/packages/test-support/src/hooks/index.ts similarity index 83% rename from packages/test-support/src/hooks/mockHooks.ts rename to packages/test-support/src/hooks/index.ts index 537ea68d9d..cd235d83a5 100644 --- a/packages/test-support/src/hooks/mockHooks.ts +++ b/packages/test-support/src/hooks/index.ts @@ -3,7 +3,7 @@ import { extractTime } from '@polkadot/util'; -import { defaultTreasury } from '../creation/treasury/defaults.js'; +import { defaultTreasury } from '../creation/treasury.js'; import { defaultMembers } from '../keyring/addresses.js'; export const mockHooks = { diff --git a/packages/test-support/src/mockData/registrations.ts b/packages/test-support/src/mockData/index.ts similarity index 100% rename from packages/test-support/src/mockData/registrations.ts rename to packages/test-support/src/mockData/index.ts diff --git a/packages/test-support/src/pagesElements/index.ts b/packages/test-support/src/pagesElements/index.ts index a4a157957c..e44dfbf82b 100644 --- a/packages/test-support/src/pagesElements/index.ts +++ b/packages/test-support/src/pagesElements/index.ts @@ -1,6 +1,7 @@ // Copyright 2017-2023 @polkadot/test-supports authors & contributors // SPDX-License-Identifier: Apache-2.0 +export * from './JudgementTag.js'; export * from './Row.js'; export * from './Sidebar.js'; export * from './Table.js'; diff --git a/packages/test-support/src/types.ts b/packages/test-support/src/types.ts index 9b6f5f6f72..557bdb29d4 100644 --- a/packages/test-support/src/types.ts +++ b/packages/test-support/src/types.ts @@ -15,3 +15,5 @@ export interface AccountOverrides { staking?: Override; info?: Override; } + +export type WaitOptions = { interval?: number, timeout?: number }; diff --git a/packages/test-support/src/utils/accountDefaults.ts b/packages/test-support/src/utils/accountDefaults.ts index 55265fe9bc..8f44a849f9 100644 --- a/packages/test-support/src/utils/accountDefaults.ts +++ b/packages/test-support/src/utils/accountDefaults.ts @@ -9,7 +9,7 @@ import type { KeyringJson$Meta } from '@polkadot/ui-keyring/types'; import { BN } from '@polkadot/util'; import { balanceOf } from '../creation/balance.js'; -import { makeStakingLedger } from '../creation/stakingInfo/stakingLedger.js'; +import { makeStakingLedger } from '../creation/staking.js'; export interface Account { balance: DeriveBalancesAll, diff --git a/packages/test-support/src/utils/index.ts b/packages/test-support/src/utils/index.ts new file mode 100644 index 0000000000..1f1acf239d --- /dev/null +++ b/packages/test-support/src/utils/index.ts @@ -0,0 +1,8 @@ +// Copyright 2017-2023 @polkadot/test-supports authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +export * from './accountDefaults.js'; +export * from './balance.js'; +export * from './mockApiHooks.js'; +export * from './renderedScreenUtils.js'; +export * from './waitFor.js'; diff --git a/packages/test-support/src/utils/waitFor.ts b/packages/test-support/src/utils/waitFor.ts index e1bcf6e058..057d9497dc 100644 --- a/packages/test-support/src/utils/waitFor.ts +++ b/packages/test-support/src/utils/waitFor.ts @@ -1,9 +1,9 @@ // Copyright 2017-2023 @polkadot/test-support authors & contributors // SPDX-License-Identifier: Apache-2.0 -export type WaitOptions = { interval?: number, timeout?: number }; +import type { WaitOptions } from '../types.js'; -export async function waitFor (predicate: () => Promise | boolean, { interval = 500, timeout = 10000 } = {}): Promise { +export async function waitFor (predicate: () => Promise | boolean, { interval = 500, timeout = 10000 }: WaitOptions = {}): Promise { const asyncPredicate = () => Promise.resolve(predicate()); let elapsed = 0; diff --git a/tsconfig.base.json b/tsconfig.base.json index c8b89bd7aa..5d3807934d 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -106,7 +106,18 @@ "@polkadot/react-query": ["react-query/src/index.ts"], "@polkadot/react-signer": ["react-signer/src/index.tsx"], "@polkadot/react-signer/signers/*": ["react-signer/src/signers/*.ts"], - "@polkadot/test-support/*": ["test-support/src/*.ts", "test-support/src/*.tsx"] + "@polkadot/test-support/api": ["test-support/src/api/index.ts"], + "@polkadot/test-support/creation/*": ["test-support/src/creation/*.ts"], + "@polkadot/test-support/hooks": ["test-support/src/hooks/index.ts"], + "@polkadot/test-support/keyring": ["test-support/src/keyring/index.ts"], + "@polkadot/test-support/mockData": ["test-support/src/mockData/index.ts"], + "@polkadot/test-support/pages/*": ["test-support/src/pages/*.tsx"], + "@polkadot/test-support/pagesElements": ["test-support/src/pagesElements/index.ts"], + "@polkadot/test-support/react": ["test-support/src/react/index.ts"], + "@polkadot/test-support/substrate": ["test-support/src/substrate/index.ts"], + "@polkadot/test-support/types": ["test-support/src/types.ts"], + "@polkadot/test-support/transaction": ["test-support/src/transaction/index.ts"], + "@polkadot/test-support/utils": ["test-support/src/utils/index.ts"] }, "skipLibCheck": true } diff --git a/yarn.lock b/yarn.lock index 2798b799fe..090b24c828 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17067,23 +17067,23 @@ fsevents@~2.3.2: languageName: node linkType: hard -"typescript@npm:^4.9.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" +"typescript@npm:^5.0.2": + version: 5.0.2 + resolution: "typescript@npm:5.0.2" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db + checksum: bef1dcd166acfc6934b2ec4d72f93edb8961a5fab36b8dd2aaf6f4f4cd5c0210f2e0850aef4724f3b4913d5aef203a94a28ded731b370880c8bcff7e4ff91fc1 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^4.9.5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=bda367" +"typescript@patch:typescript@npm%3A^5.0.2#~builtin": + version: 5.0.2 + resolution: "typescript@patch:typescript@npm%3A5.0.2#~builtin::version=5.0.2&hash=bda367" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 2eee5c37cad4390385db5db5a8e81470e42e8f1401b0358d7390095d6f681b410f2c4a0c496c6ff9ebd775423c7785cdace7bcdad76c7bee283df3d9718c0f20 + checksum: bdbf3d0aac0d6cf010fbe0536753dc19f278eb4aba88140dcd25487dfe1c56ca8b33abc0dcd42078790a939b08ebc4046f3e9bb961d77d3d2c3cfa9829da4d53 languageName: node linkType: hard