Skip to content

Commit

Permalink
namewrapper e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sugh01 committed Sep 8, 2024
1 parent d9f2f11 commit 6a3088a
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 3 deletions.
179 changes: 179 additions & 0 deletions e2e/specs/stateless/wrapName.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,182 @@ test('should calculate needed steps without localstorage', async ({
await profilePage.goto(subname)
await expect(profilePage.record('text', 'description')).toHaveText('test')
})

test('Wrapped, emancipated, 2LD', async ({ login, makeName, makePageObject }) => {
const name = await makeName({
label: 'wrapped',
type: 'wrapped',
owner: 'user',
})

const morePage = makePageObject('MorePage')
await morePage.goto(name)

await login.connect()

await expect(morePage.wrapButton).not.toBeVisible()
await expect(morePage.unwrapButton).toBeVisible()
await expect(morePage.nameWrapperStatus).toContainText('Wrapped')
await expect(morePage.pccStatus).toContainText('Not parent-controllable')
await expect(morePage.nameWrapperCheckIcon).toBeVisible()
await expect(morePage.npcIcon).toBeVisible()
})

test('Wrapped, locked, 2LD', async ({ login, makeName, makePageObject }) => {
const name = await makeName({
label: 'wrapped',
type: 'wrapped',
owner: 'user',
fuses: {
named: ['CANNOT_UNWRAP'],
},
})

const morePage = makePageObject('MorePage')
await morePage.goto(name)

await login.connect()

await expect(morePage.wrapButton).not.toBeVisible()
await expect(morePage.unwrapButtonDisabled).toBeVisible()
await expect(morePage.nameWrapperStatus).toContainText('Wrapped')
await expect(morePage.pccStatus).toContainText('Not parent-controllable')
await expect(morePage.nameWrapperLockIcon).toBeVisible()
await expect(morePage.npcIcon).toBeVisible()
})

test('Wrapped, not-emancipated (PCC), 3LD', async ({ login, makeName, makePageObject }) => {
const name = await makeName({
label: 'wrapped',
type: 'wrapped',
owner: 'user',
subnames: [
{
label: 'test',
owner: 'user',
},
],
})

const morePage = makePageObject('MorePage')
await morePage.goto(`test.${name}`)

await login.connect()

await expect(morePage.unwrapButton).toBeVisible()
await expect(morePage.nameWrapperStatus).toContainText('Wrapped')
await expect(morePage.pccStatus).toContainText('Parent-controllable')
await expect(morePage.nameWrapperCheckIcon).toBeVisible()
await expect(morePage.nameWrapperLockIcon).not.toBeVisible()
await expect(morePage.pccIcon).toBeVisible()
await expect(morePage.nameWrapperLockIcon).not.toBeVisible()
})

test('Wrapped, emancipated(NPC), 3LD', async ({ login, makeName, makePageObject }) => {
const name = await makeName({
label: 'wrapped',
type: 'wrapped',
owner: 'user',
fuses: {
named: ['CANNOT_UNWRAP'],
},
subnames: [
{
label: 'test',
owner: 'user',
fuses: {
parent: {
named: ['PARENT_CANNOT_CONTROL'],
},
},
},
],
})

const morePage = makePageObject('MorePage')
await morePage.goto(`test.${name}`)

await login.connect()

await expect(morePage.unwrapButton).toBeVisible()
await expect(morePage.nameWrapperStatus).toContainText('Wrapped')
await expect(morePage.pccStatus).toContainText('Not parent-controllable')
await expect(morePage.nameWrapperCheckIcon).toBeVisible()
await expect(morePage.npcIcon).toBeVisible()
await expect(morePage.nameWrapperLockIcon).not.toBeVisible()
})

test('Wrapped, emancipated(NPC), Locked, 3LD', async ({ login, makeName, makePageObject }) => {
const name = await makeName({
label: 'wrapped',
type: 'wrapped',
owner: 'user',
fuses: {
named: ['CANNOT_UNWRAP'],
},
subnames: [
{
label: 'test',
owner: 'user',
fuses: {
parent: {
named: ['PARENT_CANNOT_CONTROL'],
},
child: {
named: ['CANNOT_UNWRAP'],
},
},
},
],
})

const morePage = makePageObject('MorePage')
await morePage.goto(`test.${name}`)

await login.connect()

await expect(morePage.nameWrapperStatus).toContainText('Wrapped')
await expect(morePage.pccStatus).toContainText('Not parent-controllable')
await expect(morePage.nameWrapperLockIcon).toBeVisible()
await expect(morePage.npcIcon).toBeVisible()
await expect(morePage.unwrapButtonDisabled).toBeVisible()
})

test('Wrapped, emancipated(NPC), 3LD Manager', async ({ login, makeName, makePageObject }) => {
const name = await makeName({
label: 'wrapped',
type: 'wrapped',
owner: 'user2',
fuses: {
named: ['CANNOT_UNWRAP'],
},
subnames: [
{
label: 'test',
owner: 'user',
fuses: {
parent: {
named: ['PARENT_CANNOT_CONTROL'],
},
},
},
],
})

const morePage = makePageObject('MorePage')
const transactionModal = makePageObject('TransactionModal')
await morePage.goto(`test.${name}`)

await login.connect()

await expect(morePage.unwrapButton).toBeVisible()
await expect(morePage.nameWrapperStatus).toContainText('Wrapped')
await expect(morePage.pccStatus).toContainText('Not parent-controllable')
await expect(morePage.nameWrapperCheckIcon).toBeVisible()
await expect(morePage.npcIcon).toBeVisible()
await expect(morePage.nameWrapperLockIcon).not.toBeVisible()

await morePage.unwrapButton.click()
await transactionModal.autoComplete()
await expect(morePage.wrapButton).toBeVisible()
})
15 changes: 15 additions & 0 deletions playwright/pageObjects/morePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export class MorePage {

readonly nameWrapperStatus: Locator

readonly unwrapButtonDisabled: Locator

readonly nameWrapperLockIcon: Locator

readonly nameWrapperCheckIcon: Locator

readonly npcIcon: Locator

readonly pccIcon: Locator

constructor(page: Page) {
this.page = page
this.getSendNameButton = this.page.getByTestId('send-name-button')
Expand All @@ -36,6 +46,11 @@ export class MorePage {
this.unwrapButton = this.page.getByTestId('unwrap-name-btn')
this.pccStatus = this.page.getByTestId('pcc-status')
this.nameWrapperStatus = this.page.getByTestId('namewrapper-status')
this.unwrapButtonDisabled = this.page.getByTestId('cannot-unwrap-disabled-button')
this.nameWrapperLockIcon = this.page.getByTestId('namewrapper-lock-icon')
this.nameWrapperCheckIcon = this.page.getByTestId('namewrapper-check-icon')
this.npcIcon = this.page.getByTestId('npc-icon')
this.pccIcon = this.page.getByTestId('pcc-icon')
}

async goto(name: string) {
Expand Down
10 changes: 7 additions & 3 deletions src/components/pages/profile/[name]/tabs/MoreTab/NameWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,20 @@ export const NameWrapper = ({
<TwoRows>
<Record data-testid="namewrapper-status">
{t('tabs.more.token.status.wrapped')}
{status === 'locked' ? <LockSVG data-testid="namewrapper-lock-icon" /> : <CheckSVG />}
{status === 'locked' ? (
<LockSVG data-testid="namewrapper-lock-icon" />
) : (
<CheckSVG data-testid="namewrapper-check-icon" />
)}
</Record>
<ParentControlRecord data-testid="pcc-status" $isPCC={isPCC}>
{isPCC ? (
<>
{t('tabs.more.token.pcc.not-controllable')} <CheckSVG />
{t('tabs.more.token.pcc.not-controllable')} <CheckSVG data-testid="npc-icon" />
</>
) : (
<>
{t('tabs.more.token.pcc.controllable')} <AlertSVG />
{t('tabs.more.token.pcc.controllable')} <AlertSVG data-testid="pcc-icon" />
</>
)}
</ParentControlRecord>
Expand Down

0 comments on commit 6a3088a

Please sign in to comment.