Skip to content

Commit

Permalink
Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed May 22, 2023
1 parent 9d2dd6f commit c738885
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import Link from 'next/link'

export default function Page() {
return <h1 id="homepage">Home</h1>
return (
<>
<h1 id="homepage">Home</h1>
<div>
<Link href="/trigger-404" id="trigger-404-link">
Navigate to trigger-404 page
</Link>
</div>
<div>
<Link href="/testabc" id="non-existent-link">
Navigate to non-existent page
</Link>
</div>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,39 @@ createNextDescribe(
.back()
.waitForElementByCss('#not-found-component')
})

it('should allow navigating to a page calling notfound', async () => {
const browser = await next.browser('/')

await browser
.elementByCss('#trigger-404-link')
.click()
.waitForElementByCss('#not-found-component')

expect(await browser.elementByCss('#not-found-component').text()).toBe(
'Not Found!'
)

await browser.back().waitForElementByCss('#homepage')

expect(await browser.elementByCss('#homepage').text()).toBe('Home')
})

it('should allow navigating to a non-existent page', async () => {
const browser = await next.browser('/')

await browser
.elementByCss('#non-existent-link')
.click()
.waitForElementByCss('#not-found-component')

expect(await browser.elementByCss('#not-found-component').text()).toBe(
'Not Found!'
)

await browser.back().waitForElementByCss('#homepage')

expect(await browser.elementByCss('#homepage').text()).toBe('Home')
})
}
)

0 comments on commit c738885

Please sign in to comment.