kopia lustrzana https://github.com/cloudflare/wildebeest
add e2e ui test to check account posts and posts-and-replies tabs
rodzic
ffaba34966
commit
beb2cfb8f0
|
@ -40,25 +40,23 @@ export default component$(() => {
|
|||
const { accountId, statuses } = statusesLoader.use().value
|
||||
|
||||
return (
|
||||
<>
|
||||
<div data-testid="account-statuses">
|
||||
<StatusesPanel
|
||||
initialStatuses={statuses}
|
||||
fetchMoreStatuses={$(async (numOfCurrentStatuses: number) => {
|
||||
let statuses: MastodonStatus[] = []
|
||||
try {
|
||||
const response = await fetch(`/api/v1/accounts/${accountId}/statuses?offset=${numOfCurrentStatuses}`)
|
||||
if (response.ok) {
|
||||
const results = await response.text()
|
||||
statuses = JSON.parse(results)
|
||||
}
|
||||
} catch {
|
||||
/* empty */
|
||||
<div data-testid="account-posts">
|
||||
<StatusesPanel
|
||||
initialStatuses={statuses}
|
||||
fetchMoreStatuses={$(async (numOfCurrentStatuses: number) => {
|
||||
let statuses: MastodonStatus[] = []
|
||||
try {
|
||||
const response = await fetch(`/api/v1/accounts/${accountId}/statuses?offset=${numOfCurrentStatuses}`)
|
||||
if (response.ok) {
|
||||
const results = await response.text()
|
||||
statuses = JSON.parse(results)
|
||||
}
|
||||
return statuses
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
return statuses
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
|
|
@ -40,27 +40,25 @@ export default component$(() => {
|
|||
const { accountId, statuses } = statusesLoader.use().value
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div data-testid="account-statuses">
|
||||
<StatusesPanel
|
||||
initialStatuses={statuses}
|
||||
fetchMoreStatuses={$(async (numOfCurrentStatuses: number) => {
|
||||
let statuses: MastodonStatus[] = []
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/v1/accounts/${accountId}/statuses?offset=${numOfCurrentStatuses}&with-replies=true`
|
||||
)
|
||||
if (response.ok) {
|
||||
const results = await response.text()
|
||||
statuses = JSON.parse(results)
|
||||
}
|
||||
} catch {
|
||||
/* empty */
|
||||
<div data-testid="account-posts-and-replies">
|
||||
<StatusesPanel
|
||||
initialStatuses={statuses}
|
||||
fetchMoreStatuses={$(async (numOfCurrentStatuses: number) => {
|
||||
let statuses: MastodonStatus[] = []
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/v1/accounts/${accountId}/statuses?offset=${numOfCurrentStatuses}&with-replies=true`
|
||||
)
|
||||
if (response.ok) {
|
||||
const results = await response.text()
|
||||
statuses = JSON.parse(results)
|
||||
}
|
||||
return statuses
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
return statuses
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
|
|
@ -9,13 +9,11 @@ test(`Navigation via to and view of an account (with 1 post)`, async ({ page })
|
|||
await expect(page.getByTestId('account-info').getByText('Joined')).toBeVisible()
|
||||
await expect(page.getByTestId('account-info').getByTestId('stats')).toHaveText('1Posts0Following0Followers')
|
||||
|
||||
expect(await page.getByTestId('account-statuses').getByRole('article').count()).toBe(1)
|
||||
expect(await page.getByTestId('account-posts').getByRole('article').count()).toBe(1)
|
||||
await expect(
|
||||
page.getByTestId('account-statuses').getByRole('article').getByRole('img', { name: 'Avatar of Ben, just Ben' })
|
||||
page.getByTestId('account-posts').getByRole('article').getByRole('img', { name: 'Avatar of Ben, just Ben' })
|
||||
).toBeVisible()
|
||||
await expect(page.getByTestId('account-statuses').getByRole('article')).toContainText(
|
||||
'A very simple update: all good!'
|
||||
)
|
||||
await expect(page.getByTestId('account-posts').getByRole('article')).toContainText('A very simple update: all good!')
|
||||
})
|
||||
|
||||
test('Navigation to and view of an account (with 2 posts)', async ({ page }) => {
|
||||
|
@ -28,10 +26,30 @@ test('Navigation to and view of an account (with 2 posts)', async ({ page }) =>
|
|||
await expect(page.getByTestId('account-info').getByText('Joined')).toBeVisible()
|
||||
await expect(page.getByTestId('account-info').getByTestId('stats')).toHaveText('2Posts0Following0Followers')
|
||||
|
||||
expect(await page.getByTestId('account-statuses').getByRole('article').count()).toBe(2)
|
||||
const [post1Locator, post2Locator] = await page.getByTestId('account-statuses').getByRole('article').all()
|
||||
expect(await page.getByTestId('account-posts').getByRole('article').count()).toBe(2)
|
||||
const [post1Locator, post2Locator] = await page.getByTestId('account-posts').getByRole('article').all()
|
||||
await expect(post1Locator.getByRole('img', { name: 'Avatar of Raffa123$' })).toBeVisible()
|
||||
await expect(post1Locator).toContainText("I'm Rafael and I am a web designer")
|
||||
await expect(post2Locator.getByRole('img', { name: 'Avatar of Raffa123$' })).toBeVisible()
|
||||
await expect(post2Locator).toContainText('Hi! My name is Rafael!')
|
||||
})
|
||||
|
||||
test('View of an account with only a reply and 0 posts', async ({ page }) => {
|
||||
await page.goto('http://127.0.0.1:8788/@Penny')
|
||||
|
||||
await expect(page.getByTestId('account-posts')).toBeVisible()
|
||||
await expect(page.getByTestId('account-posts')).toHaveText('Nothing to see right now. Check back later!')
|
||||
await expect(page.getByTestId('account-posts-and-replies')).not.toBeVisible()
|
||||
|
||||
await page.getByRole('link', { name: 'Posts and replies' }).click()
|
||||
|
||||
await expect(page.getByTestId('account-posts-and-replies')).toBeVisible()
|
||||
await expect(page.getByTestId('account-posts-and-replies').getByRole('article')).toContainText('Yes you guys did it!')
|
||||
await expect(page.getByTestId('account-posts')).not.toBeVisible()
|
||||
|
||||
await page.getByRole('link', { name: 'Posts', exact: true }).click()
|
||||
|
||||
await expect(page.getByTestId('account-posts')).toBeVisible()
|
||||
await expect(page.getByTestId('account-posts')).toHaveText('Nothing to see right now. Check back later!')
|
||||
await expect(page.getByTestId('account-posts-and-replies')).not.toBeVisible()
|
||||
})
|
||||
|
|
Ładowanie…
Reference in New Issue