Skip to content

Commit b99df57

Browse files
authored
Merge branch 'main' into fix/profile-empty-banner
2 parents a6c6ca0 + 56d2132 commit b99df57

19 files changed

Lines changed: 300 additions & 101 deletions

File tree

e2e/specs/stateless/wrapName.spec.ts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,147 @@ test('Wrapped, emancipated(NPC), 3LD Manager', async ({ login, makeName, makePag
471471
await transactionModal.autoComplete()
472472
await expect(morePage.wrapButton).toBeVisible()
473473
})
474+
475+
test('Should not show wrap button on unwrapped name in Grace period', async ({
476+
login,
477+
makeName,
478+
makePageObject,
479+
}) => {
480+
const name = await makeName({
481+
label: 'to-be-wrapped',
482+
type: 'legacy',
483+
duration: -24 * 60 * 60,
484+
})
485+
486+
const morePage = makePageObject('MorePage')
487+
await morePage.goto(name)
488+
489+
await login.connect()
490+
491+
await expect(morePage.wrapButton).not.toBeVisible()
492+
await expect(morePage.wrapButton).toHaveCount(0)
493+
})
494+
495+
test('should show wrap button on unwrapped subname in Grace period', async ({
496+
login,
497+
makeName,
498+
makePageObject,
499+
}) => {
500+
const name = await makeName({
501+
label: 'to-be-wrapped',
502+
type: 'legacy',
503+
subnames: [
504+
{
505+
label: 'sub',
506+
},
507+
],
508+
duration: -24 * 60 * 60,
509+
})
510+
511+
const morePage = makePageObject('MorePage')
512+
const transactionModal = makePageObject('TransactionModal')
513+
await morePage.goto(`sub.${name}`)
514+
515+
await login.connect()
516+
517+
await expect(morePage.wrapButton).toBeVisible()
518+
await expect(morePage.wrapButton).toBeEnabled()
519+
520+
await morePage.wrapButton.click()
521+
await transactionModal.autoComplete()
522+
523+
await morePage.goto(`sub.${name}`)
524+
await expect(morePage.wrapButton).toHaveCount(0)
525+
})
526+
527+
test('should not show unwrap button on wrapped name in Grace period', async ({
528+
login,
529+
makeName,
530+
makePageObject,
531+
}) => {
532+
const name = await makeName({
533+
label: 'wrapped',
534+
type: 'wrapped',
535+
duration: -24 * 60 * 60,
536+
})
537+
538+
const morePage = makePageObject('MorePage')
539+
await morePage.goto(name)
540+
541+
await login.connect()
542+
543+
await expect(morePage.unwrapButton).toHaveCount(0)
544+
})
545+
546+
test('should show unwrap button on wrapped subname in Grace period', async ({
547+
login,
548+
makeName,
549+
makePageObject,
550+
}) => {
551+
const name = await makeName({
552+
label: 'to-be-wrapped',
553+
type: 'wrapped',
554+
owner: 'user',
555+
subnames: [
556+
{
557+
label: 'sub',
558+
owner: 'user',
559+
},
560+
],
561+
duration: -24 * 60 * 60,
562+
})
563+
564+
const morePage = makePageObject('MorePage')
565+
const transactionModal = makePageObject('TransactionModal')
566+
await morePage.goto(`sub.${name}`)
567+
568+
await login.connect()
569+
570+
await expect(morePage.unwrapButton).toBeVisible()
571+
await expect(morePage.unwrapButton).toBeEnabled()
572+
573+
await morePage.unwrapButton.click()
574+
await transactionModal.autoComplete()
575+
576+
await morePage.goto(`sub.${name}`)
577+
await expect(morePage.unwrapButton).toHaveCount(0)
578+
})
579+
580+
test('Wrapped, emancipated(NPC), 3LD Manager should be able to unwrap when parent is in Grace period', async ({
581+
login,
582+
makeName,
583+
makePageObject,
584+
}) => {
585+
const name = await makeName({
586+
label: 'wrapped',
587+
type: 'wrapped',
588+
owner: 'user2',
589+
fuses: {
590+
named: ['CANNOT_UNWRAP'],
591+
},
592+
subnames: [
593+
{
594+
label: 'test',
595+
owner: 'user',
596+
fuses: {
597+
parent: {
598+
named: ['PARENT_CANNOT_CONTROL'],
599+
},
600+
},
601+
},
602+
],
603+
duration: -24 * 60 * 60,
604+
})
605+
606+
const morePage = makePageObject('MorePage')
607+
const transactionModal = makePageObject('TransactionModal')
608+
await morePage.goto(`test.${name}`)
609+
610+
await login.connect()
611+
612+
await expect(morePage.unwrapButton).toBeVisible()
613+
await expect(morePage.unwrapButton).toBeEnabled()
614+
await morePage.unwrapButton.click()
615+
await transactionModal.autoComplete()
616+
await expect(morePage.wrapButton).toBeVisible()
617+
})

next.config.mjs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,40 @@ const nextConfig = {
4343
images: {
4444
domains: ['metadata.ens.domains'],
4545
},
46+
async headers() {
47+
// keep this in case we need to debug Safe in the future
48+
if (process.env.NODE_ENV === 'development') {
49+
return [
50+
{
51+
source: '/manifest.json',
52+
headers: [
53+
{
54+
key: 'Access-Control-Allow-Origin',
55+
value: '*',
56+
},
57+
{
58+
key: 'Access-Control-Allow-Methods',
59+
value: 'GET, OPTIONS',
60+
},
61+
{
62+
key: 'Access-Control-Allow-Headers',
63+
value: 'X-Requested-With, content-type, Authorization',
64+
},
65+
],
66+
},
67+
{
68+
source: '/(.*)',
69+
headers: [
70+
{
71+
key: 'Content-Security-Policy',
72+
value: "frame-ancestors 'self' https://app.safe.global;",
73+
},
74+
],
75+
},
76+
]
77+
}
78+
return []
79+
},
4680
async rewrites() {
4781
return [
4882
{

public/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
],
1616
"theme_color": "#5298FF",
1717
"background_color": "#F6F6F6",
18-
"display": "standalone"
18+
"display": "standalone",
19+
"description": "Decentralised naming for wallets, websites, & more"
1920
}
Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
1-
import { describe, it, expect } from 'vitest'
21
import { render, screen } from '@testing-library/react'
3-
import { TextWithTooltip } from './TextWithTooltip'
42
import { userEvent } from '@testing-library/user-event'
53
import { ThemeProvider } from 'styled-components'
4+
import { describe, expect, it } from 'vitest'
5+
66
import { lightTheme } from '@ensdomains/thorin'
77

8+
import { TextWithTooltip } from './TextWithTooltip'
9+
810
const renderWithTheme = (component: React.ReactNode) => {
9-
return render(
10-
<ThemeProvider theme={lightTheme}>
11-
{component}
12-
</ThemeProvider>
13-
)
11+
return render(<ThemeProvider theme={lightTheme}>{component}</ThemeProvider>)
1412
}
1513

1614
describe('TextWithTooltip', () => {
1715
it('should render children and show tooltip on hover', async () => {
18-
renderWithTheme(
19-
<TextWithTooltip tooltipContent="This is a tooltip">
20-
Hover me
21-
</TextWithTooltip>
22-
)
23-
16+
renderWithTheme(<TextWithTooltip tooltipContent="This is a tooltip">Hover me</TextWithTooltip>)
17+
2418
const button = screen.getByText('Hover me')
2519
expect(button).toBeInTheDocument()
26-
20+
2721
await userEvent.hover(button)
2822
expect(screen.getByText('This is a tooltip')).toBeInTheDocument()
2923
})
3024

3125
it('should render learn more link when link prop is provided', async () => {
3226
renderWithTheme(
33-
<TextWithTooltip
34-
tooltipContent="Tooltip with link"
35-
link="https://example.com"
36-
>
27+
<TextWithTooltip tooltipContent="Tooltip with link" link="https://example.com">
3728
With link
38-
</TextWithTooltip>
29+
</TextWithTooltip>,
3930
)
40-
31+
4132
const button = screen.getByText('With link')
4233
await userEvent.hover(button)
43-
34+
4435
const learnMoreLink = screen.getByText('action.learnMore')
4536
expect(learnMoreLink).toBeInTheDocument()
4637
expect(learnMoreLink.closest('a')).toHaveAttribute('href', 'https://example.com')
@@ -50,14 +41,12 @@ describe('TextWithTooltip', () => {
5041

5142
it('should not render learn more link when link prop is not provided', async () => {
5243
renderWithTheme(
53-
<TextWithTooltip tooltipContent="Tooltip without link">
54-
No link
55-
</TextWithTooltip>
44+
<TextWithTooltip tooltipContent="Tooltip without link">No link</TextWithTooltip>,
5645
)
57-
46+
5847
const button = screen.getByText('No link')
5948
await userEvent.hover(button)
60-
49+
6150
expect(screen.queryByText('action.learnMore')).not.toBeInTheDocument()
6251
})
6352
})

src/components/@molecules/DateSelection/DateSelection.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Typography } from '@ensdomains/thorin'
77
import { Calendar } from '@app/components/@atoms/Calendar/Calendar'
88
import { PlusMinusControl } from '@app/components/@atoms/PlusMinusControl/PlusMinusControl'
99
import { roundDurationWithDay, secondsFromDateDiff } from '@app/utils/date'
10+
import { isInsideSafe } from '@app/utils/safe'
1011
import { formatDurationOfDates, secondsToYears } from '@app/utils/utils'
1112

1213
const YearsViewSwitch = styled.button(
@@ -73,9 +74,11 @@ export const DateSelection = ({
7374
// eslint-disable-next-line react-hooks/exhaustive-deps
7475
}, [dateInYears, durationType])
7576

77+
const isSafeApp = isInsideSafe()
78+
7679
return (
7780
<Container>
78-
{durationType === 'date' ? (
81+
{durationType === 'date' && !isSafeApp ? (
7982
<Calendar
8083
value={currentTime + seconds}
8184
onChange={(e) => {
@@ -113,13 +116,15 @@ export const DateSelection = ({
113116
postFix: mode === 'register' ? ' registration. ' : ' extension. ',
114117
t,
115118
})}
116-
<YearsViewSwitch
117-
type="button"
118-
data-testid="date-selection"
119-
onClick={() => onChangeDurationType?.(durationType === 'years' ? 'date' : 'years')}
120-
>
121-
{t(`calendar.pick_by_${durationType === 'date' ? 'years' : 'date'}`, { ns: 'common' })}
122-
</YearsViewSwitch>
119+
{!isSafeApp && (
120+
<YearsViewSwitch
121+
type="button"
122+
data-testid="date-selection"
123+
onClick={() => onChangeDurationType?.(durationType === 'years' ? 'date' : 'years')}
124+
>
125+
{t(`calendar.pick_by_${durationType === 'date' ? 'years' : 'date'}`, { ns: 'common' })}
126+
</YearsViewSwitch>
127+
)}
123128
</Typography>
124129
</Container>
125130
)

src/components/@molecules/NetworkNotifications/NetworkNotifications.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('NetworkNotifications', () => {
2626
it('should show notification if shouldOpenModal sets true', () => {
2727
vi.mocked(shouldOpenModal).mockReturnValue(true)
2828
mockUseAccount.mockReturnValue({
29-
chainId: 1
29+
chainId: 1,
3030
})
3131
mockUseChainId.mockReturnValue(1)
3232
render(<NetworkNotifications />)
@@ -36,7 +36,7 @@ describe('NetworkNotifications', () => {
3636
it('should not show notification if shouldOpenModal sets false', () => {
3737
vi.mocked(shouldOpenModal).mockReturnValue(false)
3838
mockUseAccount.mockReturnValue({
39-
chainId: 1
39+
chainId: 1,
4040
})
4141
mockUseChainId.mockReturnValue(1)
4242

src/components/@molecules/NetworkNotifications/utils.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
2-
import { shouldOpenModal } from './utils'
1+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
2+
33
import * as chains from '@app/constants/chains'
44

5+
import { shouldOpenModal } from './utils'
6+
57
describe('shouldOpenModal', () => {
68
beforeEach(() => {
79
vi.resetModules()

0 commit comments

Comments
 (0)