diff --git a/src/components/DAO.tsx b/src/components/DAO.tsx index d3e4e50..2dc2391 100644 --- a/src/components/DAO.tsx +++ b/src/components/DAO.tsx @@ -9,7 +9,7 @@ import { } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Address of the DAO Avatar address: string; } diff --git a/src/components/DAOs.tsx b/src/components/DAOs.tsx index 3edbf70..f3eafc7 100644 --- a/src/components/DAOs.tsx +++ b/src/components/DAOs.tsx @@ -43,6 +43,7 @@ class InferredDAOs extends ComponentList { key={`${entity.id}_${index}`} address={entity.id} config={config} + entity={entity} > {children} diff --git a/src/components/Member.tsx b/src/components/Member.tsx index dd6a34c..db1203b 100644 --- a/src/components/Member.tsx +++ b/src/components/Member.tsx @@ -1,4 +1,5 @@ import * as React from "react"; +import { Member as Entity, IMemberState as Data } from "@dorgtech/arc.js"; import { Arc as Protocol, ArcConfig as ProtocolConfig, @@ -9,9 +10,8 @@ import { ComponentProps, } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -import { Member as Entity, IMemberState as Data } from "@dorgtech/arc.js"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Address of the member address: string; dao?: string | DAOEntity; diff --git a/src/components/Members.tsx b/src/components/Members.tsx index 90e6446..f8ae9fc 100644 --- a/src/components/Members.tsx +++ b/src/components/Members.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { Observable } from "rxjs"; +import { IMemberQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { Arc as Protocol, ArcConfig as ProtocolConfig, @@ -14,7 +15,6 @@ import { ComponentListProps, createFilterFromScope, } from "../"; -import { IMemberQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { CreateContextFeed } from "../runtime/ContextFeed"; type Scopes = "DAO"; @@ -59,6 +59,7 @@ class InferredMembers extends ComponentList { address={entity.coreState!.address} dao={entity.coreState!.dao.entity} config={config} + entity={entity} > {children} diff --git a/src/components/Queue.tsx b/src/components/Queue.tsx index 6d41880..d40eb5b 100644 --- a/src/components/Queue.tsx +++ b/src/components/Queue.tsx @@ -11,7 +11,7 @@ import { } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Address of the Queue Avatar id: string; dao?: string | DAOEntity; diff --git a/src/components/Queues.tsx b/src/components/Queues.tsx index 0e32c42..c42c9d3 100644 --- a/src/components/Queues.tsx +++ b/src/components/Queues.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { Observable } from "rxjs"; +import { IQueueQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { Arc as Protocol, ArcConfig as ProtocolConfig, @@ -14,7 +15,6 @@ import { ComponentListProps, createFilterFromScope, } from "../"; -import { IQueueQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { CreateContextFeed } from "../runtime/ContextFeed"; type Scopes = "DAO"; @@ -57,6 +57,7 @@ class InferredQueues extends ComponentList { dao={dao} id={entity.id} config={config} + entity={entity} > {children} diff --git a/src/components/Reputation.tsx b/src/components/Reputation.tsx index ba7c5fe..01d916b 100644 --- a/src/components/Reputation.tsx +++ b/src/components/Reputation.tsx @@ -14,7 +14,7 @@ import { } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Address of the Reputation Token address?: string; } diff --git a/src/components/Reputations.tsx b/src/components/Reputations.tsx index 5324585..0001b64 100644 --- a/src/components/Reputations.tsx +++ b/src/components/Reputations.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { Observable } from "rxjs"; +import { IReputationQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { Arc as Protocol, ArcConfig as ProtocolConfig, @@ -11,8 +12,6 @@ import { ComponentListLogs, ComponentListProps, } from "../"; - -import { IReputationQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { CreateContextFeed } from "../runtime/ContextFeed"; type RequiredProps = ComponentListProps; @@ -44,6 +43,7 @@ class InferredReputations extends ComponentList { key={`${entity.id}_${index}`} address={entity.address} config={config} + entity={entity} > {children} diff --git a/src/components/Reward.tsx b/src/components/Reward.tsx index 880f3f8..bf8b3dc 100644 --- a/src/components/Reward.tsx +++ b/src/components/Reward.tsx @@ -9,7 +9,7 @@ import { ComponentProps, } from "../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Reward ID id: string; } diff --git a/src/components/Rewards.tsx b/src/components/Rewards.tsx index 349ca82..d966536 100644 --- a/src/components/Rewards.tsx +++ b/src/components/Rewards.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { Observable } from "rxjs"; +import { IRewardQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { Arc as Protocol, ArcConfig as ProtocolConfig, @@ -21,7 +22,6 @@ import { createFilterFromScope, } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -import { IRewardQueryOptions as FilterOptions } from "@dorgtech/arc.js"; type Scopes = "DAO" | "Member as beneficiary" | "Proposal" | "Token"; @@ -66,7 +66,12 @@ class InferredRewards extends ComponentList { const { config } = this.props; return ( - + {children} ); diff --git a/src/components/Stake.tsx b/src/components/Stake.tsx index 5bd0715..aaf2330 100644 --- a/src/components/Stake.tsx +++ b/src/components/Stake.tsx @@ -9,7 +9,7 @@ import { } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Stake ID id: string; } diff --git a/src/components/Stakes.tsx b/src/components/Stakes.tsx index d1fe041..e69f83f 100644 --- a/src/components/Stakes.tsx +++ b/src/components/Stakes.tsx @@ -67,7 +67,12 @@ class InferredStakes extends ComponentList { } return ( - + {children} ); diff --git a/src/components/Tag.tsx b/src/components/Tag.tsx index 07bd52c..00d985c 100644 --- a/src/components/Tag.tsx +++ b/src/components/Tag.tsx @@ -9,7 +9,7 @@ import { } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Address of the Tag Avatar id: string; } diff --git a/src/components/Tags.tsx b/src/components/Tags.tsx index 066ab3a..c6e875c 100644 --- a/src/components/Tags.tsx +++ b/src/components/Tags.tsx @@ -39,7 +39,12 @@ class InferredTags extends ComponentList { const { config } = this.props; return ( - + {children} ); diff --git a/src/components/Token.tsx b/src/components/Token.tsx index 764eee5..bd703e0 100644 --- a/src/components/Token.tsx +++ b/src/components/Token.tsx @@ -11,7 +11,7 @@ import { } from "../"; import { CreateContextFeed } from "../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Address of the Token address?: string; } diff --git a/src/components/Tokens.tsx b/src/components/Tokens.tsx index 6014f8d..e00e671 100644 --- a/src/components/Tokens.tsx +++ b/src/components/Tokens.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { Observable } from "rxjs"; +import { ITokenQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { Arc as Protocol, ArcConfig as ProtocolConfig, @@ -11,7 +12,6 @@ import { ComponentListLogs, ComponentListProps, } from "../"; -import { ITokenQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { CreateContextFeed } from "../runtime/ContextFeed"; type RequiredProps = ComponentListProps; @@ -43,6 +43,7 @@ class InferredTokens extends ComponentList { key={`${entity.id}_${index}`} address={entity.address} config={config} + entity={entity} > {children} diff --git a/src/components/Vote.tsx b/src/components/Vote.tsx index 9774510..67aa960 100644 --- a/src/components/Vote.tsx +++ b/src/components/Vote.tsx @@ -1,10 +1,10 @@ import * as React from "react"; +import { Vote as Entity, IVoteState as Data } from "@dorgtech/arc.js"; import { Component, ComponentLogs, ComponentProps } from "../runtime"; import { CreateContextFeed } from "../runtime/ContextFeed"; import { Arc as Protocol, ArcConfig as ProtocolConfig } from "../protocol"; -import { Vote as Entity, IVoteState as Data } from "@dorgtech/arc.js"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Vote ID id: string; } diff --git a/src/components/Votes.tsx b/src/components/Votes.tsx index ed32e44..d858b5c 100644 --- a/src/components/Votes.tsx +++ b/src/components/Votes.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { Observable } from "rxjs"; +import { IVoteQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { Arc as Protocol, ArcConfig as ProtocolConfig, @@ -18,7 +19,6 @@ import { ComponentListProps, createFilterFromScope, } from "../"; -import { IVoteQueryOptions as FilterOptions } from "@dorgtech/arc.js"; import { CreateContextFeed } from "../runtime/ContextFeed"; type Scopes = "DAO" | "Member as voter" | "Proposal"; @@ -66,7 +66,12 @@ class InferredVotes extends ComponentList { } return ( - + {children} ); diff --git a/src/components/plugins/Competition/Plugin.tsx b/src/components/plugins/Competition/Plugin.tsx index 964c253..db4b67a 100644 --- a/src/components/plugins/Competition/Plugin.tsx +++ b/src/components/plugins/Competition/Plugin.tsx @@ -13,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } diff --git a/src/components/plugins/Competition/Proposal.tsx b/src/components/plugins/Competition/Proposal.tsx index 9707816..82f1b34 100644 --- a/src/components/plugins/Competition/Proposal.tsx +++ b/src/components/plugins/Competition/Proposal.tsx @@ -13,7 +13,7 @@ import { } from "../../../"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id?: string | Entity; } diff --git a/src/components/plugins/ContributionReward/Plugin.tsx b/src/components/plugins/ContributionReward/Plugin.tsx index ea7be5f..cff8ba6 100644 --- a/src/components/plugins/ContributionReward/Plugin.tsx +++ b/src/components/plugins/ContributionReward/Plugin.tsx @@ -13,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } diff --git a/src/components/plugins/ContributionReward/Proposal.tsx b/src/components/plugins/ContributionReward/Proposal.tsx index a275224..59b72d1 100644 --- a/src/components/plugins/ContributionReward/Proposal.tsx +++ b/src/components/plugins/ContributionReward/Proposal.tsx @@ -13,7 +13,7 @@ import { } from "../../../"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id?: string | Entity; } diff --git a/src/components/plugins/ContributionRewardExt/Plugin.tsx b/src/components/plugins/ContributionRewardExt/Plugin.tsx index 6edd5d8..8ce8684 100644 --- a/src/components/plugins/ContributionRewardExt/Plugin.tsx +++ b/src/components/plugins/ContributionRewardExt/Plugin.tsx @@ -13,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } diff --git a/src/components/plugins/ContributionRewardExt/Proposal.tsx b/src/components/plugins/ContributionRewardExt/Proposal.tsx index 5177cba..389be9d 100644 --- a/src/components/plugins/ContributionRewardExt/Proposal.tsx +++ b/src/components/plugins/ContributionRewardExt/Proposal.tsx @@ -13,7 +13,7 @@ import { } from "../../../"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id?: string | Entity; } diff --git a/src/components/plugins/FundingRequest/Plugin.tsx b/src/components/plugins/FundingRequest/Plugin.tsx index 7c5cfc0..86f7991 100644 --- a/src/components/plugins/FundingRequest/Plugin.tsx +++ b/src/components/plugins/FundingRequest/Plugin.tsx @@ -1,7 +1,7 @@ import * as React from "react"; -import { +import { FundingRequest as Entity, - IFundingRequestState as Data + IFundingRequestState as Data, } from "@dorgtech/arc.js"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; import { @@ -13,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } @@ -120,5 +120,5 @@ export { FundingRequestPlugin, InferredFundingRequestPlugin, Entity as FundingRequestPluginEntity, - Data as FundingRequestPluginData + Data as FundingRequestPluginData, }; diff --git a/src/components/plugins/FundingRequest/Proposal.tsx b/src/components/plugins/FundingRequest/Proposal.tsx index e57c36a..8f08484 100644 --- a/src/components/plugins/FundingRequest/Proposal.tsx +++ b/src/components/plugins/FundingRequest/Proposal.tsx @@ -1,7 +1,7 @@ import * as React from "react"; -import { +import { FundingRequestProposal as Entity, - IFundingRequestProposalState as Data + IFundingRequestProposalState as Data, } from "@dorgtech/arc.js"; import { Arc as Protocol, @@ -13,7 +13,7 @@ import { } from "../../../"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id?: string | Entity; } @@ -119,5 +119,5 @@ export { InferredFundingRequestProposal, FundingRequestProposal, Entity as FundingRequestProposalEntity, - Data as FundingRequestProposalData + Data as FundingRequestProposalData, }; diff --git a/src/components/plugins/GenericPlugin/Plugin.tsx b/src/components/plugins/GenericPlugin/Plugin.tsx index e7c57da..ddda2d5 100644 --- a/src/components/plugins/GenericPlugin/Plugin.tsx +++ b/src/components/plugins/GenericPlugin/Plugin.tsx @@ -13,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } diff --git a/src/components/plugins/GenericPlugin/Proposal.tsx b/src/components/plugins/GenericPlugin/Proposal.tsx index 25ee00e..fdb57d7 100644 --- a/src/components/plugins/GenericPlugin/Proposal.tsx +++ b/src/components/plugins/GenericPlugin/Proposal.tsx @@ -13,7 +13,7 @@ import { } from "../../../"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id?: string | Entity; } diff --git a/src/components/plugins/JoinAndQuit/Plugin.tsx b/src/components/plugins/JoinAndQuit/Plugin.tsx index 4e8e840..8ac3941 100644 --- a/src/components/plugins/JoinAndQuit/Plugin.tsx +++ b/src/components/plugins/JoinAndQuit/Plugin.tsx @@ -1,5 +1,8 @@ import * as React from "react"; -import { JoinAndQuit as Entity, IJoinAndQuitState as Data } from "@dorgtech/arc.js"; +import { + JoinAndQuit as Entity, + IJoinAndQuitState as Data, +} from "@dorgtech/arc.js"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; import { Arc as Protocol, @@ -10,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } @@ -20,11 +23,7 @@ interface InferredProps extends RequiredProps { id: string | Entity; } -class InferredJoinAndQuitPlugin extends Component< - InferredProps, - Entity, - Data -> { +class InferredJoinAndQuitPlugin extends Component { protected createEntity(): Entity { const { config, id } = this.props; @@ -117,5 +116,5 @@ export { JoinAndQuitPlugin, InferredJoinAndQuitPlugin, Entity as JoinAndQuitPluginEntity, - Data as JoinAndQuitPluginData + Data as JoinAndQuitPluginData, }; diff --git a/src/components/plugins/JoinAndQuit/Proposal.tsx b/src/components/plugins/JoinAndQuit/Proposal.tsx index 4df9013..b6b3227 100644 --- a/src/components/plugins/JoinAndQuit/Proposal.tsx +++ b/src/components/plugins/JoinAndQuit/Proposal.tsx @@ -1,7 +1,7 @@ import * as React from "react"; -import { +import { JoinAndQuitProposal as Entity, - IJoinAndQuitProposalState as Data + IJoinAndQuitProposalState as Data, } from "@dorgtech/arc.js"; import { Arc as Protocol, @@ -13,7 +13,7 @@ import { } from "../../../"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id?: string | Entity; } @@ -119,5 +119,5 @@ export { InferredJoinAndQuitProposal, JoinAndQuitProposal, Entity as JoinAndQuitProposalEntity, - Data as JoinAndQuitProposalData + Data as JoinAndQuitProposalData, }; diff --git a/src/components/plugins/Plugin.tsx b/src/components/plugins/Plugin.tsx index d323437..3959adc 100644 --- a/src/components/plugins/Plugin.tsx +++ b/src/components/plugins/Plugin.tsx @@ -16,7 +16,7 @@ import { CreateContextFeed } from "../../runtime/ContextFeed"; abstract class Entity extends BaseEntity {} type Data = BaseData; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id: Entity | string; } diff --git a/src/components/plugins/Plugins.tsx b/src/components/plugins/Plugins.tsx index ae00387..2d476a8 100644 --- a/src/components/plugins/Plugins.tsx +++ b/src/components/plugins/Plugins.tsx @@ -53,7 +53,12 @@ class InferredPlugins extends ComponentList { const { config } = this.props; return ( - + {children} ); diff --git a/src/components/plugins/Proposal.tsx b/src/components/plugins/Proposal.tsx index 5f688ba..305255c 100644 --- a/src/components/plugins/Proposal.tsx +++ b/src/components/plugins/Proposal.tsx @@ -16,7 +16,7 @@ import { CreateContextFeed } from "../../runtime/ContextFeed"; abstract class Entity extends BaseEntity {} type Data = BaseData; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id: Entity | string; } diff --git a/src/components/plugins/Proposals.tsx b/src/components/plugins/Proposals.tsx index de03a6a..90e22f3 100644 --- a/src/components/plugins/Proposals.tsx +++ b/src/components/plugins/Proposals.tsx @@ -61,6 +61,7 @@ class InferredProposals extends ComponentList { key={`${entity.id}_${index}`} id={entity.id} config={this.props.config} + entity={entity} > {children} diff --git a/src/components/plugins/ReputationFromToken/Plugin.tsx b/src/components/plugins/ReputationFromToken/Plugin.tsx index 514ead8..589d40c 100644 --- a/src/components/plugins/ReputationFromToken/Plugin.tsx +++ b/src/components/plugins/ReputationFromToken/Plugin.tsx @@ -13,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } diff --git a/src/components/plugins/SchemeRegistrar/Plugin.tsx b/src/components/plugins/SchemeRegistrar/Plugin.tsx index 0441387..abf951d 100644 --- a/src/components/plugins/SchemeRegistrar/Plugin.tsx +++ b/src/components/plugins/SchemeRegistrar/Plugin.tsx @@ -13,7 +13,7 @@ import { Plugin, } from "../../../"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Plugin ID id?: string | Entity; } diff --git a/src/components/plugins/SchemeRegistrar/Proposal.tsx b/src/components/plugins/SchemeRegistrar/Proposal.tsx index 74db6ae..0f040ad 100644 --- a/src/components/plugins/SchemeRegistrar/Proposal.tsx +++ b/src/components/plugins/SchemeRegistrar/Proposal.tsx @@ -13,7 +13,7 @@ import { } from "../../../"; import { CreateContextFeed } from "../../../runtime/ContextFeed"; -interface RequiredProps extends ComponentProps { +interface RequiredProps extends ComponentProps { // Proposal ID id?: string | Entity; } diff --git a/src/runtime/Component.tsx b/src/runtime/Component.tsx index 1358d26..0bfb840 100644 --- a/src/runtime/Component.tsx +++ b/src/runtime/Component.tsx @@ -15,12 +15,16 @@ export interface State { logs: ComponentLogs; } -export interface ComponentProps { +export interface ComponentProps< + Entity extends StatefulEntity, + Data extends IStatefulEntityData +> { noSub?: boolean; + entity?: Entity; } export abstract class Component< - Props extends ComponentProps, + Props extends ComponentProps, Entity extends StatefulEntity, Data extends IStatefulEntityData > extends React.Component> { @@ -134,6 +138,7 @@ export abstract class Component< props: Props ): Promise { const { logs } = this.state; + const { entity } = this.props; logs.entityCreated(); @@ -142,8 +147,16 @@ export abstract class Component< this.clearPrevState(); try { - const asyncFunction = this.createEntity.bind(this); - this._entity = await executeMaybeAsyncFunction(asyncFunction); + if (entity !== undefined) { + this._entity = entity; + } else { + const func = this.createEntity.bind(this); + this._entity = await executeMaybeAsyncFunction(func); + } + + if (!this._entity) { + throw Error(`This should never happen, Entity undefined.`); + } logs.dataQueryStarted(); await this.initialize(this._entity); diff --git a/test/customLoader.spec.tsx b/test/customLoader.spec.tsx index fd2a4cc..f2325c1 100644 --- a/test/customLoader.spec.tsx +++ b/test/customLoader.spec.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { render, screen, cleanup } from "@testing-library/react"; import { Arc, ArcConfig, @@ -7,7 +8,6 @@ import { LoadingRenderProps, DAOData, } from "../src"; -import { render, screen, cleanup } from "@testing-library/react"; describe("Custom loader ", () => { afterEach(() => cleanup()); diff --git a/test/dao.spec.tsx b/test/dao.spec.tsx index f8683f6..f887ddb 100644 --- a/test/dao.spec.tsx +++ b/test/dao.spec.tsx @@ -1,4 +1,10 @@ import React from "react"; +import { + render, + screen, + cleanup, + waitForElementToBeRemoved, +} from "@testing-library/react"; import { Arc, ArcConfig, @@ -9,7 +15,6 @@ import { Member, MemberData, } from "../src"; -import { render, screen, cleanup } from "@testing-library/react"; const daoAddress = "0x666a6eb4618d0438511c8206df4d5b142837eb0d"; const arcConfig = new ArcConfig("private"); @@ -56,7 +61,10 @@ describe("DAO List", () => { } it("Show list of DAOS ", async () => { - const { findAllByText } = render(); + const { findAllByText, queryAllByTestId } = render(); + await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { + timeout: 8000, + }); const daos = await findAllByText(/DAO address:/); expect(daos.length).toBeGreaterThan(1); }); @@ -83,7 +91,10 @@ describe("DAO List", () => { ); } } - const { findAllByText } = render(); + const { findAllByText, queryAllByTestId } = render(); + await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { + timeout: 8000, + }); const members = await findAllByText(/Member address:/); expect(members.length).toBeGreaterThan(1); }); diff --git a/test/member.spec.tsx b/test/member.spec.tsx index 1c64bfb..ecbe15b 100644 --- a/test/member.spec.tsx +++ b/test/member.spec.tsx @@ -1,4 +1,10 @@ import React from "react"; +import { + render, + screen, + cleanup, + waitForElementToBeRemoved, +} from "@testing-library/react"; import { Arc, ArcConfig, @@ -8,7 +14,6 @@ import { DAOData, Members, } from "../src"; -import { render, screen, cleanup } from "@testing-library/react"; const daoAddress = "0x666a6eb4618d0438511c8206df4d5b142837eb0d"; const memberAddress = "0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1"; @@ -108,7 +113,10 @@ describe("Member List", () => { } it("Show list of member ", async () => { - const { findAllByText } = render(); + const { findAllByText, queryAllByTestId } = render(); + await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { + timeout: 8000, + }); const members = await findAllByText(/Member address:/); expect(members.length).toBeGreaterThan(1); }); diff --git a/test/plugin.spec.tsx b/test/plugin.spec.tsx index a335819..25c890a 100644 --- a/test/plugin.spec.tsx +++ b/test/plugin.spec.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { Arc, ArcConfig, PluginData, Plugin, Plugins } from "../src"; import { render, screen, @@ -7,15 +6,16 @@ import { waitFor, cleanup, } from "@testing-library/react"; +import { Arc, ArcConfig, PluginData, Plugin, Plugins } from "../src"; const arcConfig = new ArcConfig("private"); +const pluginId = + "0x3687cd051fa5d1da87b25fe33a68bedfbe70f57a781336b48392e4b0fa93f4ce"; describe("Plugin component ", () => { afterEach(() => cleanup()); it("Shows plugin name", async () => { - const pluginId = - "0x3687cd051fa5d1da87b25fe33a68bedfbe70f57a781336b48392e4b0fa93f4ce"; const { container } = render( @@ -57,10 +57,10 @@ describe("Plugin List", () => { const { findAllByText, queryAllByTestId, findByText } = render( ); - await waitFor(() => findByText(/Plugin id:/), { + await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { timeout: 20000, }); - await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { + await waitFor(() => findByText(`Plugin id: ${pluginId}`), { timeout: 20000, }); const plugins = await findAllByText(/Plugin id:/); diff --git a/test/proposal.spec.tsx b/test/proposal.spec.tsx index 505bfd9..9ce1da5 100644 --- a/test/proposal.spec.tsx +++ b/test/proposal.spec.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { Arc, ArcConfig, ProposalData, Proposal, Proposals, DAO } from "../src"; import { render, screen, @@ -7,6 +6,7 @@ import { waitFor, cleanup, } from "@testing-library/react"; +import { Arc, ArcConfig, ProposalData, Proposal, Proposals, DAO } from "../src"; const arcConfig = new ArcConfig("private"); @@ -65,10 +65,10 @@ describe("Proposal List", () => { const { findAllByText, queryAllByTestId, findByText } = render( ); - await waitFor(() => findByText(/Proposal id/), { + await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { timeout: 8000, }); - await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { + await waitFor(() => findByText(`Proposal id: ${proposalId}`), { timeout: 8000, }); const proposals = await findAllByText(/Proposal id:/); diff --git a/test/queue.spec.tsx b/test/queue.spec.tsx index 1b2f570..8459d4f 100644 --- a/test/queue.spec.tsx +++ b/test/queue.spec.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { Arc, ArcConfig, Queue, QueueData, Queues, DAO } from "../src"; import { render, screen, @@ -7,6 +6,7 @@ import { waitFor, waitForElementToBeRemoved, } from "@testing-library/react"; +import { Arc, ArcConfig, Queue, QueueData, Queues, DAO } from "../src"; const daoAddress = "0x666a6eb4618d0438511c8206df4d5b142837eb0d"; const queueId = diff --git a/test/reputation.spec.tsx b/test/reputation.spec.tsx index 3a2d2f2..e09833b 100644 --- a/test/reputation.spec.tsx +++ b/test/reputation.spec.tsx @@ -1,4 +1,11 @@ import React from "react"; +import { + render, + screen, + waitForElementToBeRemoved, + waitFor, + cleanup, +} from "@testing-library/react"; import { Arc, ArcConfig, @@ -7,13 +14,6 @@ import { Reputations, DAO, } from "../src"; -import { - render, - screen, - waitForElementToBeRemoved, - waitFor, - cleanup, -} from "@testing-library/react"; const arcConfig = new ArcConfig("private"); const reputationAddress = "0xebbe3726558bea9869d397505c9dec2a6fb9a433"; diff --git a/test/reward.spec.tsx b/test/reward.spec.tsx index 0da0334..a8eed8f 100644 --- a/test/reward.spec.tsx +++ b/test/reward.spec.tsx @@ -1,12 +1,11 @@ import React from "react"; -import { Arc, ArcConfig, RewardData, Reward, Rewards } from "../src"; import { render, screen, waitForElementToBeRemoved, - waitFor, cleanup, } from "@testing-library/react"; +import { Arc, ArcConfig, RewardData, Reward, Rewards } from "../src"; const arcConfig = new ArcConfig("private"); const rewardId = @@ -55,12 +54,7 @@ describe("Reward List", () => { } it("Show list of reward ", async () => { - const { findAllByText, queryAllByTestId, findByText } = render( - - ); - await waitFor(() => findByText(/Reward id:/), { - timeout: 8000, - }); + const { findAllByText, queryAllByTestId } = render(); await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { timeout: 8000, }); diff --git a/test/stake.spec.tsx b/test/stake.spec.tsx index 91e4bd6..6b80ef2 100644 --- a/test/stake.spec.tsx +++ b/test/stake.spec.tsx @@ -59,9 +59,6 @@ describe("Stake List", () => { const { findAllByText, queryAllByTestId, findByText } = render( ); - await waitFor(() => findByText(/Stake id:/), { - timeout: 8000, - }); await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { timeout: 8000, }); diff --git a/test/vote.spec.tsx b/test/vote.spec.tsx index 1589c7e..88fc3b8 100644 --- a/test/vote.spec.tsx +++ b/test/vote.spec.tsx @@ -58,9 +58,6 @@ describe("Vote List", () => { const { findAllByText, queryAllByTestId, findByText } = render( ); - await waitFor(() => findByText(/Vote id/), { - timeout: 8000, - }); await waitForElementToBeRemoved(() => queryAllByTestId("default-loader"), { timeout: 8000, });