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

Jest/use commonjs libs #1652

Merged
merged 33 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9f2312d
First draft of Markdown implementation for desktop
josephlacey Apr 27, 2023
deac8d4
First draft of Markdown implementation for mobile
josephlacey Apr 27, 2023
720cb06
Adding horizontal rule back in. Some minor styling changes to lists
josephlacey Apr 28, 2023
4637a62
Overhauling of desktop markdown styling
josephlacey May 8, 2023
833e587
Merge branch 'develop' into feature/1088
josephlacey May 11, 2023
256f8d2
Codeblock styling changes to Desktop Markdown rendering
josephlacey May 13, 2023
97af2a5
Link styling changes to Mobile Markdown rendering
josephlacey May 13, 2023
684ea75
Desktop Markdown linting fixes
josephlacey May 15, 2023
7363051
Migration to a new React Native library, related code changes
josephlacey May 15, 2023
d702011
Mobile Markdown styling cleanup. Adding included Linkify feature.
josephlacey May 15, 2023
a55bc2c
Readding Headings to Desktop Markdown. Tweak to custom image handling
josephlacey May 16, 2023
d05f502
Migrating Typography to processing rule for Markdown paragraph. Styli…
josephlacey May 17, 2023
515025f
More desktop Markdown styling
josephlacey May 17, 2023
b2791b7
Removing previously alternate Markdown rendering package
josephlacey May 19, 2023
1ef01da
Merge remote-tracking branch 'upstream/develop' into feature/1088
josephlacey Jun 8, 2023
ab9d4a4
Switching to a more TypeScript-friendly react-native-markdown-display…
josephlacey Jun 9, 2023
cc21817
Adding related package-lock.json
josephlacey Jun 9, 2023
05024bb
Adding types to mobile Markdown renderinng rule customizations
josephlacey Jun 9, 2023
75735a0
Merge remote-tracking branch 'upstream/develop' into feature/1088
josephlacey Jun 15, 2023
2bc137b
Updating Cypress snapshots to reflect italics with Markdown implement…
josephlacey Jun 15, 2023
c270f77
Fixing minor styling issue with Markdown links
josephlacey Jun 15, 2023
8d156ce
Fixing TypeScript linting error.
josephlacey Jun 15, 2023
c7db125
merged upstream develop
vinkabuki Jul 19, 2023
0df6f18
Use older versions of react-markdown and remark-gfm
vinkabuki Jul 19, 2023
c914293
update package-lock.json
vinkabuki Jul 19, 2023
86eec08
Update snapshots
vinkabuki Jul 19, 2023
e1fa3b4
merged develop
vinkabuki Jul 19, 2023
5ae0d6e
linter
vinkabuki Jul 19, 2023
c8bc89c
merged develop
vinkabuki Aug 16, 2023
a3a3cb7
Mobile tests passing with mocked markdown library
vinkabuki Aug 16, 2023
ecd31d6
Mock simple react component to replace markdown
vinkabuki Aug 16, 2023
089cd45
merged develop into jest/use-commonjs-libs
vinkabuki Aug 29, 2023
e27ca2d
fix linter
vinkabuki Aug 29, 2023
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
4 changes: 1 addition & 3 deletions packages/backend/src/nest/libp2p/libp2p.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ describe('Libp2pService', () => {

it('creates libp2p address with proper ws type (%s)', async () => {
const libp2pAddress = libp2pService.createLibp2pAddress(params.localAddress, params.peerId.toString())
expect(libp2pAddress).toStrictEqual(
`/dns4/${params.localAddress}.onion/tcp/80/wss/p2p/${params.peerId.toString()}`
)
expect(libp2pAddress).toStrictEqual(`/dns4/${params.localAddress}.onion/tcp/80/wss/p2p/${params.peerId.toString()}`)
})

it('creates libp2p listen address', async () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
768 changes: 649 additions & 119 deletions packages/desktop/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@
"get-port": "^5.1.1",
"keymirror": "0.1.1",
"pkijs": "^3.0.8",
"react-markdown": "^6.0.3",
"react-qr-code": "^2.0.11",
"remark-gfm": "^1.0.0",
"socket.io-client": "4.6.0"
},
"devDependencies": {
Expand Down Expand Up @@ -297,4 +299,4 @@
"node": "18.12.1",
"npm": "8.19.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('MathMessageComponent', () => {
<body>
<div>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-1-0"
>
It is
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('MathMessageComponent', () => {
</mjx-container>
</span>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-1-2"
>
and
Expand Down Expand Up @@ -484,10 +484,21 @@ describe('MathMessageComponent', () => {
</mjx-container>
</span>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-1-1"
>
- look
<ul
class="TextMessageul"
depth="0"
>


<li>
look
</li>


</ul>
</span>
</div>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('BasicMessage', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('BasicMessage', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand All @@ -175,7 +175,7 @@ describe('BasicMessage', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-1"
>
message1
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('BasicMessage', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand All @@ -271,7 +271,7 @@ describe('BasicMessage', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-1"
>
message1
Expand Down Expand Up @@ -355,7 +355,7 @@ describe('BasicMessage', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand All @@ -365,7 +365,7 @@ describe('BasicMessage', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('ChannelMessages', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-string"
>
string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('NestedMessageContent', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand All @@ -40,7 +40,7 @@ describe('NestedMessageContent', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage TextMessagepending css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage TextMessagepending css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('NestedMessageContent', () => {
class="MuiGrid-root MuiGrid-item css-15myz84-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 TextMessagemessage TextMessagepending css-mg0tit-MuiTypography-root"
class="MuiTypography-root MuiTypography-body1 TextMessagemessage TextMessagepending css-1vefsqk-MuiTypography-root"
data-testid="messagesGroupContent-0"
>
message0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Typography, styled } from '@mui/material'
import classNames from 'classnames'
import React, { ReactNode } from 'react'
import Linkify from 'react-linkify'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import theme from '../../../theme'

const PREFIX = 'TextMessage'

const classes = {
message: `${PREFIX}message`,
pending: `${PREFIX}pending`,
blockquote: `${PREFIX}blockquote`,
code: `${PREFIX}code`,
pre: `${PREFIX}pre`,
hr: `${PREFIX}hr`,
link: `${PREFIX}link`,
ol: `${PREFIX}list`,
ul: `${PREFIX}ul`,
table: `${PREFIX}table`,
tableHeaderCell: `${PREFIX}tableHeaderCell`,
tableRowCell: `${PREFIX}tableRowCell`,
}

const StyledTypography = styled(Typography)(() => ({
Expand All @@ -24,13 +34,69 @@ const StyledTypography = styled(Typography)(() => ({
color: theme.palette.colors.lightGray,
},

[`& .${classes.blockquote}`]: {
lineHeight: '1em',
whiteSpace: 'normal',
marginInlineStart: 0,
marginBlockStart: '.5em',
marginBlockEnd: '.5em',
paddingTop: '.5em',
paddingBottom: '.5em',
paddingLeft: '1em',
borderLeft: 'solid',
borderLeftWidth: '3px',
borderColor: theme.palette.colors.lightGray,
color: theme.palette.colors.lightGray,
},

[`& .${classes.code}`]: {
backgroundColor: theme.palette.colors.veryLightGray,
padding: '.25em',
},

[`& .${classes.pre}`]: {
backgroundColor: theme.palette.colors.veryLightGray,
padding: '.25em',
},

[`& .${classes.hr}`]: {
marginTop: '2em',
},

[`& .${classes.link}`]: {
color: theme.palette.colors.lushSky,
cursor: 'pointer',
textDecoration: 'none',
'&:hover': {
textDecoration: 'underline',
},
},

[`& .${classes.ol}`]: {
paddingInlineStart: '15px',
whiteSpace: 'normal',
},

[`& .${classes.ul}`]: {
paddingInlineStart: '15px',
whiteSpace: 'normal',
listStyleType: 'disc',
},

[`& .${classes.table}`]: {
width: '100%',
},

[`& .${classes.tableHeaderCell}`]: {
borderBottom: 'solid',
borderBottomWidth: 1,
borderColor: theme.palette.colors.veryLightGray,
textAlign: 'center',
},

[`& .${classes.tableRowCell}`]: {
textAlign: 'center',
},
})) as typeof Typography

export interface TextMessageComponentProps {
Expand Down Expand Up @@ -64,7 +130,56 @@ export const TextMessageComponent: React.FC<TextMessageComponentProps> = ({ mess
})}
data-testid={`messagesGroupContent-${messageId}`}
>
<Linkify componentDecorator={componentDecorator}>{message}</Linkify>
<ReactMarkdown
remarkPlugins={[[remarkGfm, { singleTilde: false }]]}
children={message}
components={{
a: ({ node, ...props }) => (
<a
onClick={e => {
e.preventDefault()
if (props.href) openUrl(props.href)
}}
className={classNames({ [classes.link]: true })}
{...props}
/>
),
// Not working in older ReactMarkdown version we use because of ESM
// blockquote: ({ node, ...props }) => (
// <blockquote className={classNames({ [classes.blockquote]: true })} {...props} />
// ),
code: ({ node, ...props }) => <code className={classNames({ [classes.code]: true })} {...props} />,
pre: ({ node, ...props }) => <pre className={classNames({ [classes.pre]: true })} {...props} />,
hr: ({ node, ...props }) => <hr className={classNames({ [classes.hr]: true })} {...props} />,
img: ({ node, ...props }) => (
<p>
![{props.alt}](
<a
onClick={e => {
e.preventDefault()
if (props.src) openUrl(props.src)
}}
className={classNames({ [classes.link]: true })}
href={props.src}
>
{props.src}
</a>
)
</p>
),
p: React.Fragment,
ol: ({ node, ...props }) => <ol className={classNames({ [classes.ol]: true })} {...props} />,
ul: ({ node, ...props }) => <ul className={classNames({ [classes.ul]: true })} {...props} />,
table: ({ node, ...props }) => <table className={classNames({ [classes.table]: true })} {...props} />,
// Not working in older ReactMarkdown version we use because of ESM
// th: ({ node, ...props }) => (
// <th className={classNames({ [classes.tableHeaderCell]: props.isHeader })} {...props} />
// ),
// td: ({ node, ...props }) => (
// <td className={classNames({ [classes.tableRowCell]: true })} {...props} />
// )
}}
/>
</StyledTypography>
)
}
Loading
Loading