(dev = false)
| 17 | let buildId |
| 18 | |
| 19 | const navigateTest = (dev = false) => { |
| 20 | it('should navigate between pages successfully', async () => { |
| 21 | const toBuild = [ |
| 22 | '/', |
| 23 | '/another', |
| 24 | '/something', |
| 25 | '/normal', |
| 26 | '/blog/post-1', |
| 27 | '/blog/post-1/comment-1', |
| 28 | '/catchall/first', |
| 29 | ] |
| 30 | |
| 31 | await waitFor(2500) |
| 32 | |
| 33 | await Promise.all(toBuild.map((pg) => renderViaHTTP(appPort, pg))) |
| 34 | |
| 35 | const browser = await webdriver(appPort, '/') |
| 36 | let text = await browser.elementByCss('p').text() |
| 37 | expect(text).toMatch(/hello.*?world/) |
| 38 | |
| 39 | // go to /another |
| 40 | async function goFromHomeToAnother() { |
| 41 | await browser.eval('window.beforeAnother = true') |
| 42 | await browser.elementByCss('#another').click() |
| 43 | await browser.waitForElementByCss('#home') |
| 44 | text = await browser.elementByCss('p').text() |
| 45 | expect(await browser.eval('window.beforeAnother')).toBe(true) |
| 46 | expect(text).toMatch(/hello.*?world/) |
| 47 | } |
| 48 | await goFromHomeToAnother() |
| 49 | |
| 50 | // go to / |
| 51 | async function goFromAnotherToHome() { |
| 52 | await browser.eval('window.didTransition = 1') |
| 53 | await browser.elementByCss('#home').click() |
| 54 | await browser.waitForElementByCss('#another') |
| 55 | text = await browser.elementByCss('p').text() |
| 56 | expect(text).toMatch(/hello.*?world/) |
| 57 | expect(await browser.eval('window.didTransition')).toBe(1) |
| 58 | } |
| 59 | await goFromAnotherToHome() |
| 60 | |
| 61 | // Client-side SSG data caching test |
| 62 | { |
| 63 | // Let revalidation period lapse |
| 64 | await waitFor(2000) |
| 65 | |
| 66 | // Trigger revalidation (visit page) |
| 67 | await goFromHomeToAnother() |
| 68 | const snapTime = await browser.elementByCss('#anotherTime').text() |
| 69 | |
| 70 | // Wait for revalidation to finish |
| 71 | await waitFor(2000) |
| 72 | |
| 73 | // Re-visit page |
| 74 | await goFromAnotherToHome() |
| 75 | await goFromHomeToAnother() |
| 76 |
no test coverage detected