add e2e ui test to check account posts and posts-and-replies tabs

pull/294/head
Dario Piotrowicz 2023-02-15 22:34:55 +00:00
rodzic ffaba34966
commit beb2cfb8f0
3 zmienionych plików z 60 dodań i 46 usunięć

Wyświetl plik

@ -40,8 +40,7 @@ export default component$(() => {
const { accountId, statuses } = statusesLoader.use().value
return (
<>
<div data-testid="account-statuses">
<div data-testid="account-posts">
<StatusesPanel
initialStatuses={statuses}
fetchMoreStatuses={$(async (numOfCurrentStatuses: number) => {
@ -59,6 +58,5 @@ export default component$(() => {
})}
/>
</div>
</>
)
})

Wyświetl plik

@ -40,8 +40,7 @@ export default component$(() => {
const { accountId, statuses } = statusesLoader.use().value
return (
<div>
<div data-testid="account-statuses">
<div data-testid="account-posts-and-replies">
<StatusesPanel
initialStatuses={statuses}
fetchMoreStatuses={$(async (numOfCurrentStatuses: number) => {
@ -61,6 +60,5 @@ export default component$(() => {
})}
/>
</div>
</div>
)
})

Wyświetl plik

@ -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()
})