Skip to content

Commit

Permalink
fet-1340: Subname creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Lysak committed Sep 12, 2024
1 parent 165b7ff commit f160c30
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 59 deletions.
5 changes: 4 additions & 1 deletion e2e/specs/stateless/createSubname.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test('should not allow creating a subname with invalid characters', async ({

await subnamesPage.getAddSubnameButton.click()
await subnamesPage.getAddSubnameInput.type('invalid name')
await expect(subnamesPage.getSubmitSubnameButton).toBeDisabled()
await expect(subnamesPage.getAddSubnameButton).toBeDisabled()
await expect(page.getByText('Contains invalid characters')).toBeVisible()
})

Expand All @@ -118,6 +118,7 @@ test('should allow creating a subname', async ({ page, makeName, login, makePage
await subnamesPage.getAddSubnameButton.click()
await subnamesPage.getAddSubnameInput.type('test')
await subnamesPage.getSubmitSubnameButton.click()
await subnamesPage.getSubmitSubnameProfileButton.click()

const transactionModal = makePageObject('TransactionModal')
await transactionModal.autoComplete()
Expand Down Expand Up @@ -150,6 +151,7 @@ test('should allow creating a subnames if the user is the wrapped owner', async
await subnamesPage.getAddSubnameButton.click()
await subnamesPage.getAddSubnameInput.fill('test')
await subnamesPage.getSubmitSubnameButton.click()
await subnamesPage.getSubmitSubnameProfileButton.click()

const transactionModal = makePageObject('TransactionModal')
await transactionModal.autoComplete()
Expand Down Expand Up @@ -226,6 +228,7 @@ test('should allow creating an expired wrapped subname', async ({
await subnamesPage.getAddSubnameButton.click()
await subnamesPage.getAddSubnameInput.fill('test')
await subnamesPage.getSubmitSubnameButton.click()
await subnamesPage.getSubmitSubnameProfileButton.click()

await transactionModal.autoComplete()

Expand Down
5 changes: 2 additions & 3 deletions playwright/pageObjects/subnamePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ export class SubnamesPage {
readonly page: Page

readonly getAddSubnameButton: Locator

readonly getDisabledAddSubnameButton: Locator

readonly getAddSubnameInput: Locator

readonly getSubmitSubnameButton: Locator
readonly getSubmitSubnameProfileButton: Locator

constructor(page: Page) {
this.page = page
this.getAddSubnameButton = this.page.getByTestId('add-subname-action')
this.getDisabledAddSubnameButton = this.page.getByTestId('add-subname-disabled-button')
this.getAddSubnameInput = this.page.getByTestId('add-subname-input')
this.getSubmitSubnameButton = this.page.getByTestId('create-subname-next')
this.getSubmitSubnameProfileButton = this.page.getByTestId('create-subname-profile-next')
}

async goto(name: string) {
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@
"empty": "No subnames have been added",
"noResults": "No results",
"noMoreResults": "No more results",
"setProfile": "Set Profile",
"addSubname": {
"title": "Subnames let you create additional names from your existing name.",
"learn": "Learn about subnames",
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useProfileEditorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const useProfileEditorForm = (existingRecords: ProfileRecord[]) => {
SUPPORTED_AVUP_ENDPOINTS.some((endpoint) => avatar?.startsWith(endpoint))
)
if (avatarIsChanged) {
setValue('avatar', avatar, { shouldDirty: true, shouldTouch: true })
setValue('avatar', avatar || '', { shouldDirty: true, shouldTouch: true })
}
}

Expand Down Expand Up @@ -217,6 +217,7 @@ export const useProfileEditorForm = (existingRecords: ProfileRecord[]) => {
const getAvatar = () => getValues('avatar')

return {
isDirty: formState.isDirty,
records,
register,
trigger,
Expand Down
Loading

0 comments on commit f160c30

Please sign in to comment.