Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Lysak committed Sep 12, 2024
1 parent ef52108 commit 1cd639b
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 54 deletions.
7 changes: 5 additions & 2 deletions 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.getSubmitSubnameProfileButton).toBeDisabled()
await expect(page.getByText('Contains invalid characters')).toBeVisible()
})

Expand All @@ -117,6 +117,7 @@ test('should allow creating a subname', async ({ page, makeName, login, makePage

await subnamesPage.getAddSubnameButton.click()
await subnamesPage.getAddSubnameInput.type('test')
await subnamesPage.getSubmitSubnameProfileButton.click()
await subnamesPage.getSubmitSubnameButton.click()

const transactionModal = makePageObject('TransactionModal')
Expand Down Expand Up @@ -149,6 +150,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.getSubmitSubnameProfileButton.click()
await subnamesPage.getSubmitSubnameButton.click()

const transactionModal = makePageObject('TransactionModal')
Expand Down Expand Up @@ -182,7 +184,7 @@ test('should not allow adding a subname that already exists', async ({

await subnamesPage.getAddSubnameButton.click()
await subnamesPage.getAddSubnameInput.fill('test')
await expect(subnamesPage.getSubmitSubnameButton).toBeDisabled()
await expect(subnamesPage.getSubmitSubnameProfileButton).toBeDisabled()
})

test('should allow creating an expired wrapped subname', async ({
Expand Down Expand Up @@ -225,6 +227,7 @@ test('should allow creating an expired wrapped subname', async ({
await subnamesPage.goto(name)
await subnamesPage.getAddSubnameButton.click()
await subnamesPage.getAddSubnameInput.fill('test')
await subnamesPage.getSubmitSubnameProfileButton.click()
await subnamesPage.getSubmitSubnameButton.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,18 +5,17 @@ export class SubnamesPage {
readonly page: Page

readonly getAddSubnameButton: Locator

readonly getDisabledAddSubnameButton: Locator

readonly getAddSubnameInput: Locator

readonly getSubmitSubnameButton: Locator
readonly getSubmitProfileButton: 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.getSubmitProfileButton = this.page.getByTestId('create-subname-profile-next')
this.getSubmitSubnameButton = this.page.getByTestId('create-subname-next')
}

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 1cd639b

Please sign in to comment.