Commit 5de4f5a2 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

Make nonce test more reliable

parent 1a9ee198
...@@ -1719,15 +1719,12 @@ describe('app dir - basic', () => { ...@@ -1719,15 +1719,12 @@ describe('app dir - basic', () => {
expect(element.attribs.nonce).toBeTruthy() expect(element.attribs.nonce).toBeTruthy()
}) })
if (!isNextDev) { const browser = await next.browser('/script-nonce')
const browser = await next.browser('/script-nonce') await retry(async () => {
await browser.elementByCss('#get-order').click()
await retry(async () => { const order = JSON.parse(await browser.elementByCss('#order').text())
await browser.elementByCss('#get-order').click() expect(order).toEqual([2, 1])
const order = JSON.parse(await browser.elementByCss('#order').text()) })
expect(order?.length).toBe(2)
})
}
}) })
it('should pass manual `nonce`', async () => { it('should pass manual `nonce`', async () => {
...@@ -1745,15 +1742,12 @@ describe('app dir - basic', () => { ...@@ -1745,15 +1742,12 @@ describe('app dir - basic', () => {
expect(element.attribs.nonce).toBeTruthy() expect(element.attribs.nonce).toBeTruthy()
}) })
if (!isNextDev) { const browser = await next.browser('/script-manual-nonce')
const browser = await next.browser('/script-manual-nonce') await retry(async () => {
await browser.elementByCss('#get-order').click()
await retry(async () => { const order = JSON.parse(await browser.elementByCss('#order').text())
await browser.elementByCss('#get-order').click() expect(order).toEqual([2, 1])
const order = JSON.parse(await browser.elementByCss('#order').text()) })
expect(order?.length).toBe(2)
})
}
}) })
it('should pass manual `nonce` pages', async () => { it('should pass manual `nonce` pages', async () => {
...@@ -1771,14 +1765,12 @@ describe('app dir - basic', () => { ...@@ -1771,14 +1765,12 @@ describe('app dir - basic', () => {
expect(element.attribs.nonce).toBeTruthy() expect(element.attribs.nonce).toBeTruthy()
}) })
if (!isNextDev) { const browser = await next.browser('/pages-script-manual-nonce')
await retry(async () => { await retry(async () => {
const browser = await next.browser('/pages-script-manual-nonce') await browser.elementByCss('#get-order').click()
await browser.elementByCss('#get-order').click() const order = JSON.parse(await browser.elementByCss('#order').text())
const order = JSON.parse(await browser.elementByCss('#order').text()) expect(order).toEqual([2, 1])
expect(order?.length).toBe(2) })
})
}
}) })
it('should pass nonce when using next/font', async () => { it('should pass nonce when using next/font', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment