Skip to content

Commit

Permalink
Bump up code coverage (#671)
Browse files Browse the repository at this point in the history
* WIP coverage tests

* Finish up code coverage 88%

* Change vijays address

* Upgrade cypress

* Downgrade back to Cypress 12
  • Loading branch information
elvijsTDL authored Sep 12, 2023
1 parent f3209bd commit 0420886
Show file tree
Hide file tree
Showing 37 changed files with 999 additions and 136 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "npx serve@latest out",
"lint": "next lint",
"coverage:build": "rm -rf tests/coverage tests/.nyc_output && INSTRUMENT_CODE=1 yarn build && yarn start",
"coverage:dev": "rm -rf tests/coverage tests/.nyc_output && INSTRUMENT_CODE=1 yarn dev",
"coverage:test": "cd tests && yarn cypress run --env network=polygon-mumbai,dev=false,coverage=true",
"post-update": "echo \"codesandbox preview only, need an update\" && yarn upgrade --latest",
"generate": "npm-run-all -s generate:*",
Expand Down
4 changes: 2 additions & 2 deletions src/components/AddressSearchDialog/AddressSearchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export const AddressSearchDialogContent: FC<AddressSearchDialogProps> = ({
)}
{ensQuery.isError && (
<ListItem sx={LIST_ITEM_STYLE}>
<ListItemText translate="yes" primary="Error" />
<ListItemText data-cy="ens-error" translate="yes" primary="Error" />
</ListItem>
)}
{!ensQuery.isLoading &&
Expand Down Expand Up @@ -371,7 +371,7 @@ export const AddressSearchDialogContent: FC<AddressSearchDialogProps> = ({
)}
{lensQuery.isError && (
<ListItem sx={LIST_ITEM_STYLE}>
<ListItemText translate="yes" primary="Error" />
<ListItemText data-cy="lens-error" translate="yes" primary="Error" />
</ListItem>
)}
{!lensQuery.isLoading &&
Expand Down
1 change: 1 addition & 0 deletions src/features/activityHistory/FlowUpdatedActivityRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ const FlowUpdatedActivityRow: FC<FlowUpdatedActivityRowProps> = ({
secondary={
<AddressCopyTooltip address={isOutgoing ? receiver : sender}>
<Typography
data-cy="address-to-copy"
variant="h6"
color="text.primary"
component="span"
Expand Down
1 change: 1 addition & 0 deletions src/features/common/CopyBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const CopyBtn: FC<CopyBtnProps> = ({ label, copyText, ButtonProps = {} }) => {

return (
<Button
data-cy={"address-modal-copy-button"}
{...ButtonProps}
endIcon={isCopied ? <CheckOutlinedIcon /> : <ContentCopyRoundedIcon />}
onClick={handleCopyClick}
Expand Down
1 change: 1 addition & 0 deletions src/features/minigame/MinigameContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default forwardRef<HTMLIFrameElement>(function MinigameContainer(
const { getUrl } = useMinigame();
return (
<Container
data-cy="minigame-component"
{...props}
component="iframe"
ref={ref}
Expand Down
7 changes: 7 additions & 0 deletions src/features/onboarding/OnboardingCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useConnectButton } from "../wallet/ConnectButtonProvider";
import Link from "../common/Link";

interface OnboardingItemProps {
dataCy?: string;
title: string;
subheader: string;
href: string;
Expand All @@ -30,6 +31,7 @@ interface OnboardingItemProps {
}

const OnboardingItem: FC<PropsWithChildren<OnboardingItemProps>> = ({
dataCy,
title,
subheader,
childrenGap = 1.5,
Expand All @@ -46,6 +48,7 @@ const OnboardingItem: FC<PropsWithChildren<OnboardingItemProps>> = ({
return (
<Link href={href} onClick={onClick}>
<Card
data-cy={dataCy}
elevation={isHovering ? 3 : 1}
sx={{
textDecoration: "none",
Expand Down Expand Up @@ -142,6 +145,7 @@ const OnboardingCards: FC<OnboardingCardsProps> = ({
translate="yes"
>
<OnboardingItem
dataCy="get-tokens-onboarding-card"
title="Get Super Tokens"
subheader="Wrap any token in your wallet"
href="/wrap?upgrade"
Expand All @@ -153,6 +157,7 @@ const OnboardingCards: FC<OnboardingCardsProps> = ({
</OnboardingItem>

<OnboardingItem
dataCy="send-stream-onboarding-card"
title="Send a Stream"
subheader="Pick a recipient, token and network"
href="/send"
Expand All @@ -173,6 +178,7 @@ const OnboardingCards: FC<OnboardingCardsProps> = ({
<StreamItem address="0xF9Ce34dFCD3cc92804772F3022AF27bCd5E43Ff2" />
</OnboardingItem>
<OnboardingItem
dataCy="modify-or-cancel-streams-onboarding-card"
title="Modify and Cancel Streams"
subheader="Don't let your balance hit zero!"
onClick={() => {
Expand All @@ -189,6 +195,7 @@ const OnboardingCards: FC<OnboardingCardsProps> = ({
</IconButton>
</OnboardingItem>
<OnboardingItem
dataCy="try-out-superfluid-onboarding-card"
title="Try out Superfluid"
subheader="Start on a Testnet"
onClick={onClick}
Expand Down
2 changes: 1 addition & 1 deletion src/features/theme/ThemeChanger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function ThemeChanger() {
const toggleTheme = () => setTheme(isDarkTheme ? "light" : "dark");

return (
<ListItemButton sx={{ borderRadius: "10px" }} onClick={toggleTheme}>
<ListItemButton data-cy={isDarkTheme ? "light-mode-button" : "dark-mode-button"} sx={{ borderRadius: "10px" }} onClick={toggleTheme}>
<ListItemIcon sx={{ ml: 0.25, mr: 2.25 }}>
{isDarkTheme ? (
<LightModeOutlinedIcon fontSize="small" />
Expand Down
4 changes: 2 additions & 2 deletions src/features/tokenPrice/FiatAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const FiatAmount: FC<PropsWithChildren<FiatAmountProps>> = ({
const decimal = new Decimal(utils.formatUnits(wei, decimals)).mul(price);

return (
<>
<span data-cy="fiat-amount">
{currency.format(decimal.toFixed(2))}
{children}
</>
</span>
);
};

Expand Down
2 changes: 2 additions & 0 deletions src/features/wallet/AccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const AccountModal: FC<AccountModalProps> = ({ open, onClose }) => {

return (
<ResponsiveDialog
data-cy="account-modal"
open={open}
onClose={handleClose}
PaperProps={{ sx: { width: 500 } }}
Expand Down Expand Up @@ -140,6 +141,7 @@ const AccountModal: FC<AccountModalProps> = ({ open, onClose }) => {
endIcon={<LogoutRoundedIcon />}
sx={{ flex: 1 }}
onClick={onDisconnect}
data-cy="disconnect-button"
>
Disconnect
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/features/wallet/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const AccountInfo: FC<AccountInfoProps> = ({
onClick,
stopImpersonation,
}) => (
<ListItem sx={{ px: 2, py: 0, cursor: "pointer" }} onClick={onClick}>
<ListItem data-cy={"connected-wallet-button"} sx={{ px: 2, py: 0, cursor: "pointer" }} onClick={onClick}>
<ListItemAvatar sx={{ mr: 2 }}>
<AddressAvatar address={address} />
</ListItemAvatar>
Expand Down
Loading

0 comments on commit 0420886

Please sign in to comment.