Skip to content

Commit

Permalink
Merge branch 'FET-987' of https://github.com/ensdomains/ens-app-v3 in…
Browse files Browse the repository at this point in the history
…to FET-987
  • Loading branch information
Stanislav Lysak committed Sep 4, 2024
2 parents ab55d21 + f9d6cc5 commit 253656b
Show file tree
Hide file tree
Showing 182 changed files with 8,420 additions and 3,536 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/knip.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Knip

on: [push]

jobs:
knip:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install pnpm
run: corepack enable pnpm

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- run: pnpm knip
2 changes: 1 addition & 1 deletion .github/workflows/pages-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- run: pnpm install --frozen-lockfile
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- run: pnpm install --frozen-lockfile
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- run: pnpm install --frozen-lockfile
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- run: pnpm install --frozen-lockfile
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- run: pnpm install --frozen-lockfile
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- run: pnpm install --frozen-lockfile
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ tsconfig.vitest-temp.json
/archives
/data
/test-environment
/ganache

# hardhat
/cache
/artifacts
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.18.2
20.13.1
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ artifacts
cache
coverage
data
ganache
out
subgraphs

Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"i18n-ally.localesPaths": [
"public/locales"
],
"i18n-ally.keystyle": "nested"
"i18n-ally.keystyle": "nested",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,62 @@ Our testing philosophy is user-centric, meaning we want to write out tests so th
A user generally clicks, types and swipes, and so most tests should include one of these actions. A user may also load a page in a specific state (by clicking, typing or swiping outside of the app) so sometimes we just want to check a page renders correctly. The vast majority of our tests will be of these kinds.

For deeper parts of the codebase that aren't directly related to a user interaction, such as utility functions, the user is the developer. So simply test the code in the way a developer would use it.

## Knip Configuration Guide

### 1. Install Knip:

Install Knip as a development dependency in your project:

```bash
pnpm add -D knip
```

### 2. Add a knip script to your package.json:

Add a script to your package.json for easy access to Knip:

```json
{
"scripts": {
...,
"knip": "knip",
"knip:fix": "knip --fix --allow-remove-files"
}
}
```

### 3. Create Knip Configuration File:

Create a `knip.config.ts` file at the root of your project. For more detail of configuration options, refer to the [knip.config.ts file](knip.config.ts) in the ENSDomains repository.

### 4. Run Knip:

To analyze your project, run Knip using the following command:

```bash
pnpm knip
```
Knip will exit with code `1` if any issues are found, such as unused files, dependencies, or exports that need to be removed.

### 5. Review and Remove Unused Files

After Knip completes its analysis, review the results. Manually remove any unused files that are safe to delete, or let Knip handle it automatically with the following command:

```bash
pnpm knip:fix
```

Ensure you carefully examine any files marked for removal to avoid accidentally deleting necessary code.

### 6. Run Unit Tests and E2E Tests:

After removing files, it's important to run your unit and end-to-end tests to ensure that everything is still functioning correctly:

```bash
pnpm test:coverage
```

```bash
pnpm e2e
```
11 changes: 11 additions & 0 deletions e2e/specs/stateful/dnsclaim.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ test.describe('Import DNSSEC name', () => {
await expect(page.getByTestId('status-checker-message')).toContainText('Invalid record found')
await expect(page.getByTestId('import-next-button')).toBeDisabled()
})

test('should resolve .pw domains', async ({ page, login }) => {
await page.goto('/test.pw')
await login.connect()

await page.getByTestId('onchain-radio').click()
await page.getByTestId('import-next-button').click()
await expect(page.getByTestId('import-heading')).toContainText('Enable DNSSEC')
await expect(page.getByTestId('status-checker-message')).toContainText('DNSSEC is not enabled')
await expect(page.getByTestId('import-next-button')).toBeDisabled()
})
})
42 changes: 25 additions & 17 deletions e2e/specs/stateless/extendNames.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test('should be able to register multiple names on the address page', async ({
makePageObject,
makeName,
}) => {
const names = await makeName([
// Generating names in not neccessary but we want to make sure that there are names to extend
await makeName([
{
label: 'extend-legacy',
type: 'legacy',
Expand All @@ -32,16 +33,28 @@ test('should be able to register multiple names on the address page', async ({
const transactionModal = makePageObject('TransactionModal')

await addresPage.goto(address)

await login.connect()
await page.pause()

await addresPage.selectToggle.click()

await expect(await page.locator('.name-detail-item').count()).toBeGreaterThan(0)
const nameItems = await page.locator('.name-detail-item').all()
const nameItemTestIds = await Promise.all(
nameItems.map((item) => item.getAttribute('data-testid')),
)
const extendableNameItems = nameItemTestIds
.filter((testid): testid is string => !!testid)
.map((testid) => testid.replace('name-item-', ''))
.filter((name) => {
const nameParts = name?.split('.') ?? []
return nameParts.length === 2 && nameParts[1] === 'eth'
})

const timestampDict: { [key: string]: number } = {}
for (const name of names) {
const label = name.replace('.eth', '')
await addresPage.search(label)
for (const name of extendableNameItems) {
const timestamp = await addresPage.getTimestamp(name)
timestampDict[name] = timestamp
await addresPage.getNameRow(name).click()
}
await addresPage.extendNamesButton.click()

Expand All @@ -53,16 +66,10 @@ test('should be able to register multiple names on the address page', async ({
await addresPage.extendNamesModalNextButton.click()

// check the invoice details
await expect(page.getByTestId('invoice-item-0-amount')).toContainText('0.0065')
await expect(page.getByTestId('invoice-item-1-amount')).toContainText('0.0002')
await expect(page.getByTestId('invoice-total')).toContainText('0.0067')
await page.pause()
await expect(page.getByText(`Extend ${extendableNameItems.length} Names`)).toBeVisible()
await expect(page.getByText('1 year extension', { exact: true })).toBeVisible()

// check the price comparison table
await expect(page.getByTestId('year-marker-0')).toContainText('3% gas')
await expect(page.getByTestId('year-marker-1')).toContainText('1% gas')
await expect(page.getByTestId('year-marker-2')).toContainText('1% gas')

// increment and save
await page.getByTestId('plus-minus-control-plus').click()
await page.getByTestId('plus-minus-control-plus').click()
Expand All @@ -72,11 +79,12 @@ test('should be able to register multiple names on the address page', async ({

await subgraph.sync()
await page.reload()
for (const name of names) {
await page.waitForTimeout(3000)
for (const name of extendableNameItems) {
const label = name.replace('.eth', '')
await addresPage.search(label)
await expect(addresPage.nameExpiry(name)).not.toHaveText(/12/, { timeout: 30000 })
expect(await addresPage.getTimestamp(name)).toEqual(timestampDict[name] + 31536000000 * 3)
await expect(await addresPage.getTimestamp(name)).not.toBe(timestampDict[name])
await expect(await addresPage.getTimestamp(name)).toBe(timestampDict[name] + 31536000000 * 3)
}
})

Expand Down
Loading

0 comments on commit 253656b

Please sign in to comment.