Skip to content

Commit

Permalink
Merge pull request #600 from ensdomains/FET1316-tests
Browse files Browse the repository at this point in the history
(test) Add few more records to test
  • Loading branch information
storywithoutend committed Nov 14, 2023
2 parents 3d64f1a + c336a75 commit df1be51
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
36 changes: 33 additions & 3 deletions e2e/specs/stateless/advancedEditor.spec.ts
Expand Up @@ -10,8 +10,16 @@ test('should be able to maintain state when returning from transaction modal to
label: 'profile',
type: 'legacy',
records: {
texts: [{ key: 'text', value: 'text' }],
coinTypes: [{ key: 'SOL', value: 'HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH' }],
texts: [
{ key: 'name', value: 'Bob' },
{ key: 'text', value: 'text' },
{ key: 'com.twitter', value: '@test' },
],
coinTypes: [
{ key: 'SOL', value: 'HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH' },
{ key: 'ETH', value: '0xbec1C7C11F2Fa9AB24b9E49122D26e721766DAF6' },
{ key: 'BTC', value: '1PzAJcFtEiXo9UGtRU6iqXQKj8NXtcC7DE' },
],
contentHash: 'ipfs://bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y',
abi: {
contentType: 1,
Expand All @@ -28,10 +36,18 @@ test('should be able to maintain state when returning from transaction modal to
await login.connect()

// Validate records
await expect(recordsPage.getRecordValue('text', 'name')).toHaveText('Bob')
await expect(recordsPage.getRecordValue('text', 'text')).toHaveText('text')
await expect(recordsPage.getRecordValue('text', 'com.twitter')).toHaveText('@test')
await expect(recordsPage.getRecordValue('address', 'sol')).toHaveText(
'HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH',
)
await expect(recordsPage.getRecordValue('address', 'eth')).toHaveText(
'0xbec1C7C11F2Fa9AB24b9E49122D26e721766DAF6',
)
await expect(recordsPage.getRecordValue('address', 'btc')).toHaveText(
'1PzAJcFtEiXo9UGtRU6iqXQKj8NXtcC7DE',
)
await expect(recordsPage.getRecordValue('contentHash')).toHaveText(
'ipfs://bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y',
)
Expand All @@ -41,39 +57,53 @@ test('should be able to maintain state when returning from transaction modal to

// Validate advanced editor
await expect(await advancedEditor.recordInput('text', 'text')).toHaveValue('text')
await expect(await advancedEditor.recordInput('text', 'name')).toHaveValue('Bob')
await expect(await advancedEditor.recordInput('text', 'com.twitter')).toHaveValue('@test')
await expect(await advancedEditor.recordInput('address', 'SOL')).toHaveValue(
'HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH',
)
await expect(await advancedEditor.recordInput('address', 'ETH')).toHaveValue(
'0xbec1C7C11F2Fa9AB24b9E49122D26e721766DAF6',
)
await expect(await advancedEditor.recordInput('address', 'BTC')).toHaveValue(
'1PzAJcFtEiXo9UGtRU6iqXQKj8NXtcC7DE',
)
await expect(await advancedEditor.recordInput('contentHash')).toHaveValue(
'ipfs://bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y',
)
await expect(await advancedEditor.recordInput('abi')).toHaveValue('"{\\"test\\":\\"test\\"}"')

await advancedEditor.recordClearButton('text', 'text').then((button) => button.click())
await advancedEditor.recordClearButton('address', 'SOL').then((button) => button.click())
await advancedEditor.recordClearButton('address', 'ETH').then((button) => button.click())
await advancedEditor.recordInput('contentHash').then((input) => input.fill(''))
await advancedEditor.recordInput('abi').then((input) => input.fill(''))

await advancedEditor.saveButton.click()

// Validate transaction display item
await expect(transactionModal.displayItem('update')).toHaveText('4 records')
await expect(transactionModal.displayItem('update')).toHaveText('5 records')

await transactionModal.backButton.click()

// Validate inputs have been rebuilt correctly
await expect(await advancedEditor.recordComponent('text', 'text')).toHaveCount(0)
await expect(await advancedEditor.recordComponent('address', 'SOL')).toHaveCount(0)
await expect(await advancedEditor.recordComponent('address', 'ETH')).toHaveCount(0)
await expect(await advancedEditor.recordInput('contentHash')).toHaveValue('')
await expect(await advancedEditor.recordInput('abi')).toHaveValue('')

await advancedEditor.saveButton.click()

// Validate transaction display item
await expect(transactionModal.displayItem('update')).toHaveText('5 records')

await transactionModal.autoComplete()

// Validate change in records
await expect(recordsPage.getRecordButton('text', 'text')).toHaveCount(0)
await expect(recordsPage.getRecordButton('address', 'sol')).toHaveCount(0)
await expect(recordsPage.getRecordButton('address', 'eth')).toHaveCount(0)
await expect(recordsPage.getRecordButton('contentHash')).toHaveCount(0)
await expect(recordsPage.getRecordButton('abi')).toHaveCount(0)
})
3 changes: 1 addition & 2 deletions src/hooks/useExpandableRecordsGroup.ts
Expand Up @@ -53,8 +53,7 @@ const useExpandableRecordsGroup = <T extends FieldValues>({
shouldDirty: returnAllFields ? Object.keys(otherValues).length > 0 : true,
})
} else {
const newValues = { ...otherValues, [key]: '' }
setValue(group, newValues as PathValue<T, Path<T>>, { shouldDirty: true })
setValue(`${group}.${key}` as Path<T>, '' as PathValue<T, Path<T>>, { shouldDirty: true })
}
}

Expand Down

0 comments on commit df1be51

Please sign in to comment.