Skip to content

Commit

Permalink
search tests & tests refactoring to use fixtures,share code
Browse files Browse the repository at this point in the history
  • Loading branch information
uiii committed Nov 28, 2023
1 parent da6fe6c commit 84f0a03
Show file tree
Hide file tree
Showing 135 changed files with 11,370 additions and 1,369 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.37.0-focal
image: mcr.microsoft.com/playwright:v1.40.0-focal
strategy:
fail-fast: false
matrix:
Expand Down
93 changes: 72 additions & 21 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@
"devDependencies": {
"@argos-ci/cli": "^0.4.4",
"@emotion/eslint-plugin": "^11.10.0",
"@playwright/test": "^1.37.0",
"@playwright/test": "^1.40.0",
"@polkadot/api": "^10.1.4",
"@polkadot/apps-config": "^0.124.1",
"@subsquid/archive-registry": "^2.1.9",
"@subsquid/ss58": "^0.1.4",
"@types/pluralize": "^0.0.33",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"cli-table3": "^0.6.3",
"colors": "^1.4.0",
"cross-env": "^7.0.3",
"eslint": "^8.36.0",
"eslint-plugin-react": "^7.32.2",
"pluralize": "^8.0.0",
"serve": "^14.2.0",
"ts-node": "^10.9.1"
}
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config: Config = {
outputDir: "./test/results",
screenshotsDir: "./test/screenshots",
/* Maximum time one test can run for. */
timeout: 60 * 1000,
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
Expand Down
4 changes: 3 additions & 1 deletion src/components/ItemsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export type ItemsTableProps<T extends ItemsTableItem, S = any, A extends any[] =
errorMessage?: string;
sort?: SortOrder<any>;
pageInfo?: PageInfo;
tableProps?: HTMLAttributes<HTMLTableElement>;
onPageChange?: (page: number) => void;
};

Expand All @@ -115,6 +116,7 @@ export const ItemsTable = <T extends ItemsTableItem, S = any, A extends any[] =
errorMessage = "Unexpected error occured while fetching items",
sort,
pageInfo,
tableProps = {},
onPageChange,
...restProps
} = props;
Expand All @@ -140,7 +142,7 @@ export const ItemsTable = <T extends ItemsTableItem, S = any, A extends any[] =
return (
<div {...restProps} data-class="table">
<TableContainer css={containerStyle}>
<Table css={tableStyle}>
<Table {...tableProps} css={tableStyle}>
<colgroup>
{Children.map(children, (child) => child && <col css={child.props.colCss} />)}
</colgroup>
Expand Down
13 changes: 12 additions & 1 deletion src/components/Time.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,18 @@ export const Time = (props: TimeProps) => {
}
}, [time, fromNow]);

const timeElement = <span data-test="time">{fromNow ? fromNowFormatted : formatted}</span>;
const timeElement = (
<span
data-test="time"
data-time-format={
fromNow ? "fromNow"
: utc ? "utc"
: formatProp
}
>
{fromNow ? fromNowFormatted : formatted}
</span>
);

if (!tooltip) {
return timeElement;
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/AccountBalancesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const AccountBalancesTable = (props: AccountBalancesTableProps) => {
pageInfo={pageInfo}
onPageChange={onPageChange}
sort={sort}
data-test="account-balances-table"
data-test="balances-items"
>
<AccountBalancesTableAttribute
label="Network"
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/AccountIdentityInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const AccountIdentityInfo = (props: AccountIdentityInfoProps) => {
}

return (
<div css={identityItemsStyle} {...divProps}>
<div css={identityItemsStyle} {...divProps} data-test="account-identity-info">
{identity.web &&
<Tooltip
arrow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import { Resource } from "../../model/resource";
import { UsdRates } from "../../model/usdRates";
import { decodeAddress } from "../../utils/address";

import { AccountAddress } from "../account/AccountAddress";
import { AccountAddress } from "./AccountAddress";

import { Currency } from "../Currency";
import { ItemsTable, ItemsTableAttribute } from "../ItemsTable";
import { Link } from "../Link";

export type BalancesTableProps = {
export type HoldersTableProps = {
network: Network;
balances: PaginatedResource<Balance>;
usdRates: Resource<UsdRates>;
onPageChange?: (page: number) => void;
};

const BalancesItemsTableAttribute = ItemsTableAttribute<Balance, never, [UsdRates|undefined]>;
const HoldersTableAttribute = ItemsTableAttribute<Balance, never, [UsdRates|undefined]>;

function BalancesTable(props: BalancesTableProps) {
function HoldersTable(props: HoldersTableProps) {
const { network, balances, usdRates, onPageChange } = props;

return (
Expand All @@ -33,9 +33,9 @@ function BalancesTable(props: BalancesTableProps) {
error={balances.error}
pageInfo={balances.pageInfo}
onPageChange={onPageChange}
data-test="balances-table"
data-test="holders-items"
>
<BalancesItemsTableAttribute
<HoldersTableAttribute
label="Account"
render={(balance) =>
<AccountAddress
Expand All @@ -46,7 +46,7 @@ function BalancesTable(props: BalancesTableProps) {
/>}
/>

<BalancesItemsTableAttribute
<HoldersTableAttribute
label="Total"
render={(balance, usdRates) =>
<Currency
Expand All @@ -60,7 +60,7 @@ function BalancesTable(props: BalancesTableProps) {
}
/>

<BalancesItemsTableAttribute
<HoldersTableAttribute
label="Free"
render={(balance, usdRates) =>
<Currency
Expand All @@ -74,7 +74,7 @@ function BalancesTable(props: BalancesTableProps) {
}
/>

<BalancesItemsTableAttribute
<HoldersTableAttribute
label="Reserved"
render={(balance, usdRates) =>
<Currency
Expand All @@ -88,7 +88,7 @@ function BalancesTable(props: BalancesTableProps) {
}
/>

<BalancesItemsTableAttribute
<HoldersTableAttribute
label="Last update"
render={(balance) =>
<Link to={`/${network.name}/search?query=${balance.updatedAtBlock}`}>
Expand All @@ -100,4 +100,4 @@ function BalancesTable(props: BalancesTableProps) {
);
}

export default BalancesTable;
export default HoldersTable;
2 changes: 1 addition & 1 deletion src/components/blocks/BlocksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ExtrinsicsTable(props: BlocksTableProps) {
error={blocks.error}
pageInfo={blocks.pageInfo}
onPageChange={onPageChange}
data-test="blocks-table"
data-test="blocks-items"
>
<BlocksTableAttribute
label="Height"
Expand Down
2 changes: 1 addition & 1 deletion src/components/calls/CallsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const CallsTable = (props: CallsTableProps) => {
error={calls.error}
pageInfo={calls.pageInfo}
onPageChange={onPageChange}
data-test="calls-table"
data-test="calls-items"
>
<CallsTableAttribute
label="ID"
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/EventsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function EventsTable(props: EventsTableProps) {
error={events.error}
pageInfo={events.pageInfo}
onPageChange={onPageChange}
data-test="events-table"
data-test="events-items"
>
<EventsItemsTableAttribute
label="ID"
Expand Down
2 changes: 1 addition & 1 deletion src/components/extrinsics/ExtrinsicsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ExtrinsicsTable(props: ExtrinsicsTableProps) {
error={extrinsics.error}
pageInfo={extrinsics.pageInfo}
onPageChange={onPageChange}
data-test="extrinsics-table"
data-test="extrinsics-items"
>
<ExtrinsicsTableAttribute
label="ID"
Expand Down
Loading

0 comments on commit 84f0a03

Please sign in to comment.