Skip to content

Commit

Permalink
Merge branch 'main' into fet-1613
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Sep 11, 2024
2 parents a549d25 + 1c7adff commit 27710e3
Show file tree
Hide file tree
Showing 171 changed files with 5,476 additions and 3,565 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
4 changes: 3 additions & 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 All @@ -66,6 +66,8 @@ jobs:
run: |
mkdir -p ./out/sitemaps
pnpm generate:sitemaps
env:
SITEMAP_GRAPH_KEY: ${{ secrets.SITEMAP_GRAPH_KEY }}

- name: Publish
uses: cloudflare/pages-action@v1
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
```
34 changes: 12 additions & 22 deletions e2e/specs/stateless/registerName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from '@playwright/test'
import { Web3RequestKind } from 'headless-web3-provider'
import { Hash, isHash } from 'viem'

import { ethRegistrarControllerCommitSnippet } from '@ensdomains/ensjs/contracts'
import { setPrimaryName } from '@ensdomains/ensjs/wallet'
import { Web3RequestKind } from '@ensdomains/headless-web3-provider'

// import { secondsToDateInput } from '@app/utils/date'
import { daysToSeconds, yearsToSeconds } from '@app/utils/time'
Expand All @@ -28,7 +28,6 @@ test.describe.serial('normal registration', () => {
page,
login,
accounts,
provider,
time,
makePageObject,
}) => {
Expand Down Expand Up @@ -112,7 +111,7 @@ test.describe.serial('normal registration', () => {
await expect(waitButton).toBeDisabled()
const startTimerButton = page.getByTestId('start-timer-button')
await expect(startTimerButton).not.toBeVisible()
await provider.increaseTime(60)
await testClient.increaseTime({ seconds: 60 })
await expect(page.getByTestId('finish-button')).toBeEnabled()

// should save the registration state and the transaction status
Expand Down Expand Up @@ -159,7 +158,6 @@ test.describe.serial('normal registration', () => {

test('should allow registering a non-primary name', async ({
page,
provider,
accounts,
time,
login,
Expand Down Expand Up @@ -192,7 +190,7 @@ test.describe.serial('normal registration', () => {
await page.getByTestId('next-button').click()
await transactionModal.confirm()
await expect(page.getByTestId('countdown-complete-check')).toBeVisible()
await provider.increaseTime(60)
await testClient.increaseTime({ seconds: 60 })
await page.getByTestId('finish-button').click()
await transactionModal.confirm()
await page.getByTestId('view-name').click()
Expand All @@ -205,7 +203,6 @@ test.describe.serial('normal registration', () => {
test('should allow registering a premium name', async ({
page,
login,
provider,
accounts,
makeName,
makePageObject,
Expand Down Expand Up @@ -236,7 +233,7 @@ test('should allow registering a premium name', async ({
await transactionModal.confirm()

await expect(page.getByTestId('countdown-complete-check')).toBeVisible()
await provider.increaseTime(120)
await testClient.increaseTime({ seconds: 120 })
await page.getByTestId('finish-button').click()
await transactionModal.confirm()

Expand All @@ -249,7 +246,6 @@ test('should allow registering a premium name', async ({
test('should allow registering a name and resuming from the commit toast', async ({
page,
login,
provider,
time,
makePageObject,
}) => {
Expand All @@ -266,13 +262,13 @@ test('should allow registering a name and resuming from the commit toast', async
await page.getByTestId('next-button').click()
await page.getByTestId('next-button').click()

await provider.setAutomine(false)
await testClient.setAutomine(false)

await transactionModal.confirm()

await page.getByTestId('transaction-modal-sent-button').click()
await page.goto('/')
await provider.setAutomine(true)
await testClient.setAutomine(true)

await page.getByTestId('notification-continue-button').click()
await expect(page).toHaveURL(`/${name}/register`)
Expand Down Expand Up @@ -351,7 +347,6 @@ test('should allow registering with a specific date', async ({ page, login, make
test('should allow registering a premium name with a specific date', async ({
page,
login,
provider,
accounts,
makeName,
makePageObject,
Expand Down Expand Up @@ -411,7 +406,7 @@ test('should allow registering a premium name with a specific date', async ({
await transactionModal.confirm()

await expect(page.getByTestId('countdown-complete-check')).toBeVisible()
await provider.increaseTime(120)
await testClient.increaseTime({ seconds: 120 })
await page.getByTestId('finish-button').click()
await transactionModal.confirm()

Expand All @@ -424,7 +419,6 @@ test('should allow registering a premium name with a specific date', async ({
test('should allow registering a premium name for two months', async ({
page,
login,
provider,
accounts,
makeName,
makePageObject,
Expand Down Expand Up @@ -484,7 +478,7 @@ test('should allow registering a premium name for two months', async ({
await transactionModal.confirm()

await expect(page.getByTestId('countdown-complete-check')).toBeVisible()
await provider.increaseTime(120)
await testClient.increaseTime({ seconds: 120 })
await page.getByTestId('finish-button').click()
await transactionModal.confirm()

Expand All @@ -497,7 +491,6 @@ test('should allow registering a premium name for two months', async ({
test('should not allow registering a premium name for less than 28 days', async ({
page,
login,
provider,
accounts,
makeName,
makePageObject,
Expand Down Expand Up @@ -574,7 +567,7 @@ test('should not allow registering a premium name for less than 28 days', async
await transactionModal.confirm()

await expect(page.getByTestId('countdown-complete-check')).toBeVisible()
await provider.increaseTime(120)
await testClient.increaseTime({ seconds: 120 })
await page.getByTestId('finish-button').click()
await transactionModal.confirm()

Expand All @@ -588,7 +581,6 @@ test('should allow normal registration for a month', async ({
page,
login,
accounts,
provider,
time,
makePageObject,
}) => {
Expand Down Expand Up @@ -692,7 +684,7 @@ test('should allow normal registration for a month', async ({
// should show countdown
await expect(page.getByTestId('countdown-circle')).toBeVisible()
await expect(page.getByTestId('countdown-complete-check')).toBeVisible()
await provider.increaseTime(60)
await testClient.increaseTime({ seconds: 60 })
await expect(page.getByTestId('finish-button')).toBeEnabled()

// should save the registration state and the transaction status
Expand All @@ -717,7 +709,6 @@ test('should not allow normal registration less than 28 days', async ({
page,
login,
accounts,
provider,
time,
makePageObject,
}) => {
Expand Down Expand Up @@ -832,7 +823,7 @@ test('should not allow normal registration less than 28 days', async ({
// should show countdown
await expect(page.getByTestId('countdown-circle')).toBeVisible()
await expect(page.getByTestId('countdown-complete-check')).toBeVisible()
await provider.increaseTime(60)
await testClient.increaseTime({ seconds: 60 })
await expect(page.getByTestId('finish-button')).toBeEnabled()

// should save the registration state and the transaction status
Expand All @@ -857,7 +848,6 @@ test('should be able to detect an existing commit created on a private mempool',
page,
login,
accounts,
provider,
time,
wallet,
makePageObject,
Expand Down Expand Up @@ -926,7 +916,7 @@ test('should be able to detect an existing commit created on a private mempool',
// should show countdown
await expect(page.getByTestId('countdown-circle')).toBeVisible()
await expect(page.getByTestId('countdown-circle')).toContainText(/^[0-6]?[0-9]$/)
await provider.increaseTime(60)
await testClient.increaseTime({ seconds: 60 })
await expect(page.getByTestId('countdown-complete-check')).toBeVisible({ timeout: 10000 })
})

Expand Down
2 changes: 0 additions & 2 deletions e2e/specs/stateless/setPrimary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ test.describe('profile', () => {
}) => {
test.slow()

// const reverseRegistrar = await contracts.get('ReverseRegistrar', { signer: 'user' })
// await reverseRegistrar.setName('')
await setPrimaryName(walletClient, {
name: '',
account: createAccounts().getAddress('user') as `0x${string}`,
Expand Down
2 changes: 1 addition & 1 deletion e2e/specs/stateless/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe('Transactions', () => {

await transactionMocal.authorize()

await expect(page.getByText('Test transaction')).toBeVisible()
await expect(page.getByText('Test transaction', { exact: true })).toBeVisible()

await expect(page.getByTestId('toast-desktop')).toBeVisible()
await expect(page.getByTestId('toast-desktop')).toHaveText(/Transaction Successful/)
Expand Down
Loading

0 comments on commit 27710e3

Please sign in to comment.