MCPcopy
hub / github.com/vercel/next.js / runTests

Function runTests

test/integration/rewrites-manual-href-as/test/index.test.ts:19–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17let app
18
19const runTests = () => {
20 it('should allow manual href/as on index page', async () => {
21 const browser = await webdriver(appPort, '/')
22
23 expect(await browser.elementByCss('#index').text()).toBe('index page')
24 expect(await browser.hasElementByCssSelector('#modal')).toBeFalsy()
25 await browser.eval('window.beforeNav = 1')
26
27 await browser.elementByCss('#to-modal').click()
28
29 expect(await browser.elementByCss('#index').text()).toBe('index page')
30 expect(await browser.hasElementByCssSelector('#modal')).toBeTruthy()
31 expect(await browser.eval('window.beforeNav')).toBe(1)
32 expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({
33 imageId: '123',
34 })
35
36 await browser
37 .elementByCss('#to-preview')
38 .click()
39 .waitForElementByCss('#preview')
40
41 expect(await browser.elementByCss('#preview').text()).toBe('preview page')
42 expect(await browser.eval('window.beforeNav')).toBe(1)
43 expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({
44 slug: '123',
45 })
46
47 await browser.back()
48
49 await browser
50 .elementByCss('#to-another')
51 .click()
52 .waitForElementByCss('#another')
53
54 expect(await browser.elementByCss('#another').text()).toBe('another page')
55 expect(await browser.eval('window.beforeNav')).toBe(1)
56 expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({})
57
58 await browser.back()
59
60 await browser.elementByCss('#to-rewrite-me').click()
61
62 expect(await browser.elementByCss('#another').text()).toBe('another page')
63 expect(await browser.eval('window.beforeNav')).toBe(1)
64 expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({})
65
66 await browser.back()
67
68 await browser
69 .elementByCss('#to-index-as-rewrite')
70 .click()
71 .waitForElementByCss('#index')
72
73 expect(await browser.elementByCss('#index').text()).toBe('index page')
74 expect(await browser.eval('window.beforeNav')).toBe(1)
75 expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({})
76 })

Callers 1

index.test.tsFile · 0.70

Calls 12

checkFunction · 0.90
webdriverFunction · 0.85
elementByCssMethod · 0.80
evalMethod · 0.80
clickMethod · 0.80
waitForElementByCssMethod · 0.80
textMethod · 0.65
backMethod · 0.65
itFunction · 0.50
expectFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected