Skip to content

Commit

Permalink
Merge branch 'main' into feat/FET-1611-track-users-through-dns-import…
Browse files Browse the repository at this point in the history
…ing-flow
  • Loading branch information
sugh01 committed Nov 24, 2024
2 parents 6ef12d7 + 97b4a28 commit 5bdb6c5
Show file tree
Hide file tree
Showing 46 changed files with 1,821 additions and 372 deletions.
32 changes: 16 additions & 16 deletions e2e/specs/stateless/extendNames.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { daysToSeconds } from '@app/utils/time'

import { test } from '../../../playwright'

test('should be able to register multiple names on the address page', async ({
test('should be able to extend multiple names (including names in grace preiod) on the address page', async ({
page,
accounts,
login,
Expand All @@ -26,11 +26,13 @@ test('should be able to register multiple names on the address page', async ({
label: 'extend-legacy',
type: 'legacy',
owner: 'user2',
duration: -24 * 60 * 60,
},
{
label: 'wrapped',
type: 'wrapped',
owner: 'user2',
duration: -24 * 60 * 60,
},
])

Expand Down Expand Up @@ -65,29 +67,27 @@ test('should be able to register multiple names on the address page', async ({

// warning message
await expect(page.getByText('You do not own all these names')).toBeVisible()
await page.locator('button:has-text("I understand")').click()
await page.getByTestId('extend-names-confirm').click()

// name list
await page.waitForLoadState('networkidle')
await expect(page.getByText(`Extend ${extendableNameItems.length} Names`)).toBeVisible()
page.locator('button:has-text("Next")').waitFor({ state: 'visible' })
await page.locator('button:has-text("Next")').waitFor({ state: 'visible' })
await page.locator('button:has-text("Next")').click()

// check the invoice details
await page.waitForLoadState('networkidle')
await expect(page.getByText('1 year extension', { exact: true })).toBeVisible()
// increment and save
// TODO: Reimplement when date duration bug is fixed
// await expect(page.getByText('1 year extension', { exact: true })).toBeVisible()
await expect(page.getByTestId('plus-minus-control-label')).toHaveText('1 year')
await page.getByTestId('plus-minus-control-plus').click()
await expect(page.getByTestId('plus-minus-control-label')).toHaveText('2 years')
await page.getByTestId('plus-minus-control-plus').click()
await page.waitForLoadState('networkidle')
await expect(page.getByTestId('invoice-item-0-amount')).not.toBeEmpty()
await expect(page.getByTestId('invoice-item-1-amount')).not.toBeEmpty()
await expect(page.getByTestId('invoice-total')).not.toBeEmpty()

page.locator('button:has-text("Next")').waitFor({ state: 'visible' })
await page.locator('button:has-text("Next")').click()
await page.waitForLoadState('networkidle')
await expect(page.getByTestId('plus-minus-control-label')).toHaveText('3 years')
await expect(page.getByTestId('invoice-item-0-amount')).not.toHaveText('0.0000 ETH')
await expect(page.getByTestId('invoice-item-1-amount')).not.toHaveText('0.0000 ETH')
await expect(page.getByTestId('invoice-total')).not.toHaveText('0.0000 ETH')

await page.getByTestId('extend-names-confirm').click()
await expect(transactionModal.transactionModal).toBeVisible({ timeout: 10000 })
await transactionModal.autoComplete()

await expect(page.getByText('Your "Extend names" transaction was successful')).toBeVisible({
Expand Down Expand Up @@ -371,7 +371,7 @@ test('should be able to extend a name by a month', async ({
await test.step('should show the correct price data', async () => {
await expect(extendNamesModal.getInvoiceExtensionFee).toContainText('0.0003')
await expect(extendNamesModal.getInvoiceTransactionFee).toContainText('0.0001')
await expect(extendNamesModal.getInvoiceTotal).toContainText('0.0004')
await expect(extendNamesModal.getInvoiceTotal).toContainText(/0\.000[3|4]/)
await expect(page.getByText(/1 month .* extension/)).toBeVisible()
})

Expand Down
234 changes: 233 additions & 1 deletion e2e/specs/stateless/myNames.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { expect } from '@playwright/test'
import { testClient } from '@root/playwright/fixtures/contracts/utils/addTestContracts'
import { createAccounts } from '@root/playwright/fixtures/accounts'
import {
testClient,
walletClient,
} from '@root/playwright/fixtures/contracts/utils/addTestContracts'
import { Address, labelhash } from 'viem'

import { deleteSubname } from '@ensdomains/ensjs/wallet'

import { test } from '../../../playwright'
import { Name } from '../../../playwright/fixtures/makeName'
Expand Down Expand Up @@ -32,3 +39,228 @@ test('myNames', async ({ page, login, makeName }) => {

expect(timestamps.every((timestamp) => timestamp === timestamps[0])).toBe(true)
})

test.describe.serial('myNames', () => {
test.beforeAll(async ({ subgraph }) => {
// Move time to the future to force previous names to expire
await testClient.increaseTime({ seconds: 2 * 365 * 24 * 60 * 60 })
await testClient.mine({ blocks: 1 })
await subgraph.sync()
})

let subnamesToDelete: string[] = []
let allNames: string[] = []

test.afterAll(async () => {
console.log('cleaning up subnames')
const account = createAccounts().getAddress('user4') as Address
for (const subname of subnamesToDelete) {
const contract = subname.includes('wrapped') ? 'nameWrapper' : 'registry'
console.log('deleting subname:', subname, 'on', contract)
// eslint-disable-next-line no-await-in-loop
await deleteSubname(walletClient, {
name: subname,
account,
contract,
})
}
})

const makeSubnamesConfig = (type: 'legacy' | 'wrapped') =>
Array.from(
{ length: 10 },
(_, i) =>
({
label: `sub${i}`,
owner: 'user4',
type,
...(type === 'wrapped'
? {
fuses: {
parent: {
named: ['PARENT_CANNOT_CONTROL'],
},
},
}
: {}),
}) as any,
)

test('should display all names for expiry date ASC', async ({ page, login, makeName }) => {
const earlierName = await makeName({
label: 'earlier-wrapped',
type: 'wrapped',
owner: 'user4',
fuses: {
named: ['CANNOT_UNWRAP'],
},
subnames: makeSubnamesConfig('wrapped'),
})
const concurrentNames = await makeName([
{
label: `concurrent-legacy`,
type: 'legacy',
owner: 'user4',
subnames: makeSubnamesConfig('legacy'),
} as Name,
{
label: `concurrent-wrapped`,
type: 'wrapped',
owner: 'user4',
fuses: {
named: ['CANNOT_UNWRAP'],
},
subnames: makeSubnamesConfig('wrapped'),
},
])
const laterName = await makeName({
label: 'later-legacy-name',
type: 'legacy',
owner: 'user4',
subnames: makeSubnamesConfig('legacy'),
})

subnamesToDelete = [earlierName, ...concurrentNames, laterName].flatMap((name) =>
Array.from({ length: 10 }, (_, i) => `sub${i}.${name}`),
)
allNames = [earlierName, ...concurrentNames, laterName, ...subnamesToDelete]

await page.goto('/')
await login.connect('user4')
await page.goto('/my/names')

await expect(page.getByTestId('names-list')).toBeVisible({ timeout: 10000 })

await page.evaluate(async () => {
let previousScrollHeight = 0
let { scrollHeight } = document.body
do {
window.scrollTo(0, scrollHeight)
// eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => {
setTimeout(resolve, 1000)
})
previousScrollHeight = scrollHeight
scrollHeight = document.body.scrollHeight
} while (previousScrollHeight !== scrollHeight)
})

for (const name of allNames) {
const decryptedLocator = page.getByTestId(`name-item-${name}`)
const nameParts = name.split('.')
const label = nameParts.shift()!
const labelHash = `[${labelhash(label).replace('0x', '')}]`
const encryptedLocator = page.getByTestId(`name-item-${[labelHash, ...nameParts].join('.')}`)
// eslint-disable-next-line no-await-in-loop
await expect(decryptedLocator.or(encryptedLocator)).toBeVisible()
}
})

test('should display all names for expiry date DESC', async ({ page, login }) => {
await page.goto('/')
await login.connect('user4')
await page.goto('/my/names')

await expect(page.getByTestId('names-list')).toBeVisible({ timeout: 10000 })

await page.getByTestId('sort-desc').click()
await page.waitForTimeout(1000)

await page.evaluate(async () => {
let previousScrollHeight = 0
let { scrollHeight } = document.body
do {
window.scrollTo(0, scrollHeight)
// eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => {
setTimeout(resolve, 1000)
})
previousScrollHeight = scrollHeight
scrollHeight = document.body.scrollHeight
} while (previousScrollHeight !== scrollHeight)
})

for (const name of allNames) {
const decryptedLocator = page.getByTestId(`name-item-${name}`)
const nameParts = name.split('.')
const label = nameParts.shift()!
const labelHash = `[${labelhash(label).replace('0x', '')}]`
const encryptedLocator = page.getByTestId(`name-item-${[labelHash, ...nameParts].join('.')}`)
// eslint-disable-next-line no-await-in-loop
await expect(decryptedLocator.or(encryptedLocator)).toBeVisible()
}
})

test('should display all names for createdAt ASC', async ({ page, login }) => {
await page.goto('/')
await login.connect('user4')
await page.goto('/my/names')

await expect(page.getByTestId('names-list')).toBeVisible({ timeout: 10000 })

await page.getByTestId('select-container').getByRole('button').click()
await page.getByTestId('select-option-createdAt').click()
await page.waitForTimeout(1000)

await page.evaluate(async () => {
let previousScrollHeight = 0
let { scrollHeight } = document.body
do {
window.scrollTo(0, scrollHeight)
// eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => {
setTimeout(resolve, 1000)
})
previousScrollHeight = scrollHeight
scrollHeight = document.body.scrollHeight
} while (previousScrollHeight !== scrollHeight)
})

for (const name of allNames) {
const decryptedLocator = page.getByTestId(`name-item-${name}`)
const nameParts = name.split('.')
const label = nameParts.shift()!
const labelHash = `[${labelhash(label).replace('0x', '')}]`
const encryptedLocator = page.getByTestId(`name-item-${[labelHash, ...nameParts].join('.')}`)
// eslint-disable-next-line no-await-in-loop
await expect(decryptedLocator.or(encryptedLocator)).toBeVisible()
}
})

test('should display all names for createdAt DESC', async ({ page, login }) => {
await page.goto('/')
await login.connect('user4')
await page.goto('/my/names')

await expect(page.getByTestId('names-list')).toBeVisible({ timeout: 10000 })

await page.getByTestId('select-container').getByRole('button').click()
await page.getByTestId('select-option-createdAt').click()
await page.getByTestId('sort-desc').click()
await page.waitForTimeout(1000)

await page.evaluate(async () => {
let previousScrollHeight = 0
let { scrollHeight } = document.body
do {
window.scrollTo(0, scrollHeight)
// eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => {
setTimeout(resolve, 1000)
})
previousScrollHeight = scrollHeight
scrollHeight = document.body.scrollHeight
} while (previousScrollHeight !== scrollHeight)
})

for (const name of allNames) {
const decryptedLocator = page.getByTestId(`name-item-${name}`)
const nameParts = name.split('.')
const label = nameParts.shift()!
const labelHash = `[${labelhash(label).replace('0x', '')}]`
const encryptedLocator = page.getByTestId(`name-item-${[labelHash, ...nameParts].join('.')}`)
// eslint-disable-next-line no-await-in-loop
await expect(decryptedLocator.or(encryptedLocator)).toBeVisible()
}
})
})
Loading

0 comments on commit 5bdb6c5

Please sign in to comment.