Skip to content

Commit

Permalink
add grace period tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sugh01 committed Jul 17, 2024
1 parent 5424467 commit 09ebbf1
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 1 deletion.
146 changes: 146 additions & 0 deletions e2e/specs/stateless/gracePeriodNames.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/* eslint-disable no-await-in-loop */
import { expect } from '@playwright/test'

import { test } from '../../../playwright'

test('owner test', async ({ page,
login,
makePageObject,
makeName }) => {
//make 200 names
const name = await makeName({
label: 'legacy',
type: 'legacy',
owner: 'user',
duration: -24 * 60 * 60,
})

const profilePage = makePageObject('ProfilePage')
await profilePage.goto(name)
const namesPage = makePageObject('MyNamesPage')
await login.connect()
await namesPage.goto()
await expect(page.getByText(`${name}`)).toBeVisible({
timeout: 15000,
})

const namesList = []

for (let i = 0; i < 50; i++) {
namesList.push(
await makeName({
label: `legacy-${i}`,
type: 'legacy',
owner: 'user',
duration: -24 * 60 * 60,
}))
}
await namesPage.goto()
await namesPage.searchField.fill(namesList[19])
await expect(page.getByText(`${namesList[19]}`)).toBeVisible({
timeout: 15000,
})
await namesPage.goto()
await namesPage.scrollToEnd()
await expect(page.getByText(`${namesList[19]}`)).toBeVisible({
timeout: 15000,
})
})

test('manager test', async ({ page,
login,
accounts,
provider,
time,
makePageObject,
makeName }) => {
//make 200 names
const name = await makeName({
label: 'legacy',
type: 'legacy',
owner: 'user2',
manager: 'user',
duration: -24 * 60 * 60,
})

const profilePage = makePageObject('ProfilePage')
await profilePage.goto(name)
const namesPage = makePageObject('MyNamesPage')
await login.connect()
await namesPage.goto()
await expect(page.getByText(`${name}`)).toBeVisible({
timeout: 15000,
})

const namesList = []

for (let i = 0; i < 50; i++) {
namesList.push(
await makeName({
label: `legacy-${i}`,
type: 'legacy',
owner: 'user2',
manager: 'user',
duration: -24 * 60 * 60,
}))
}
await namesPage.goto()
await namesPage.searchField.fill(namesList[19])
await expect(page.getByText(`${namesList[19]}`)).toBeVisible({
timeout: 15000,
})
await namesPage.goto()
await namesPage.scrollToEnd()
await expect(page.getByText(`${namesList[19]}`)).toBeVisible({
timeout: 15000,
})
})

test('manager test expires', async ({ page,
login,
accounts,
provider,
time,
makePageObject,
makeName }) => {
//make 200 names
const name = await makeName({
label: 'legacy',
type: 'legacy',
owner: 'user2',
manager: 'user',
duration: 24 * 60 * 60,
})

const profilePage = makePageObject('ProfilePage')
await profilePage.goto(name)
const namesPage = makePageObject('MyNamesPage')
await login.connect()
await namesPage.goto()
await expect(page.getByText(`${name}`)).toBeVisible({
timeout: 15000,
})

const namesList = []

for (let i = 0; i < 50; i++) {
namesList.push(
await makeName({
label: `legacy-${i}`,
type: 'legacy',
owner: 'user2',
manager: 'user',
duration: 48 * 60 * 60,
}))
}
await namesPage.goto()
await namesPage.searchField.fill(namesList[19])
await expect(page.getByText(`${namesList[19]}`)).toBeVisible({
timeout: 15000,
})
await namesPage.goto()
await namesPage.scrollToEnd()
await expect(page.getByText(`${namesList[19]}`)).toBeVisible({
timeout: 15000,
})
})
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
testDir: './e2e/specs',
testMatch: '*.spec.ts',
retries: process.env.CI ? 2 : 0,
timeout: 120000, // add extra time for loading
timeout: 12000000, // add extra time for loading
fullyParallel: true, // required to evenly shard
workers: 1, // keep tests serial for now
reporter: [['html', { open: 'always' }]],
Expand Down
2 changes: 2 additions & 0 deletions playwright/pageObjects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { RegistrationPage } from './registrationPage'
import { SendNameModal } from './sendNameModal'
import { SubnamesPage } from './subnamePage'
import { TransactionModal } from './transactionModal'
import {MyNamesPage} from './myNamesPage'

type Dependencies = { page: Page; wallet: Web3ProviderBackend }

Expand All @@ -36,6 +37,7 @@ const pageObjects = {
TransactionModal,
RecordsPage,
AdvancedEditorModal,
MyNamesPage
}

type PageObjects = typeof pageObjects
Expand Down
26 changes: 26 additions & 0 deletions playwright/pageObjects/myNamesPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable import/no-extraneous-dependencies */

/* eslint-disable no-await-in-loop */
import { Locator, Page } from '@playwright/test'

export class MyNamesPage {
readonly page: Page

readonly searchField: Locator

constructor(page: Page) {
this.page = page
this.searchField = this.page.getByTestId('name-table-header-search')
}

async goto() {
await this.page.goto(`/my/names`)
}

async scrollToEnd() {
await this.page.evaluate(() => {
window.scrollTo(0, document.body.scrollHeight)
})
}

}

0 comments on commit 09ebbf1

Please sign in to comment.