Skip to content

Commit

Permalink
Merge branch 'canary' into chore/remove-fromentries-polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 30, 2021
2 parents abf6eaa + 48874f1 commit bae2bec
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default function middlewareRSCLoader(this: any) {
// locale: detectedLocale,
// defaultLocale,
// domainLocales: i18n?.domains,
dev: process.env.NODE_ENV !== 'production',
App,
Document,
buildManifest,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styles from './style.module.css'

export default function RedText({ children }) {
return <div className={styles.text}>{children}</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.text {
color: red;
}
2 changes: 2 additions & 0 deletions test/integration/react-rsc-basic/app/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import '../styles.css'

function App({ Component, pageProps }) {
return <Component {...pageProps} />
}
Expand Down
10 changes: 10 additions & 0 deletions test/integration/react-rsc-basic/app/pages/css-modules.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// CSS modules can only be imported inside client components for now.
import RedText from '../components/red/index.client'

export default function CSSM() {
return (
<RedText>
<h1>This should be in red</h1>
</RedText>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function GlobalStyle() {
return (
<div>
<h1 id="red">This should be in red</h1>
</div>
)
}
7 changes: 7 additions & 0 deletions test/integration/react-rsc-basic/app/pages/global-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function GlobalStyle() {
return (
<div>
<h1 id="red">This should be in red</h1>
</div>
)
}
3 changes: 3 additions & 0 deletions test/integration/react-rsc-basic/app/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#red {
color: red;
}
27 changes: 27 additions & 0 deletions test/integration/react-rsc-basic/test/css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-env jest */
import webdriver from 'next-webdriver'

export default function (context) {
it('should include global styles under `concurrentFeatures: true`', async () => {
const browser = await webdriver(context.appPort, '/global-styles')
const currentColor = await browser.eval(
`window.getComputedStyle(document.querySelector('#red')).color`
)
expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`)
})
it('should include global styles with `serverComponents: true`', async () => {
const browser = await webdriver(context.appPort, '/global-styles-rsc')
const currentColor = await browser.eval(
`window.getComputedStyle(document.querySelector('#red')).color`
)
expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`)
})
// TODO: fix this test
// it.skip('should include css modules with `serverComponents: true`', async () => {
// const browser = await webdriver(context.appPort, '/css-modules')
// const currentColor = await browser.eval(
// `window.getComputedStyle(document.querySelector('h1')).color`
// )
// expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`)
// })
}
37 changes: 35 additions & 2 deletions test/integration/react-rsc-basic/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
renderViaHTTP,
} from 'next-test-utils'

import css from './css'

const nodeArgs = ['-r', join(__dirname, '../../react-18/test/require-hook.js')]
const appDir = join(__dirname, '../app')
const distDir = join(__dirname, '../app/.next')
Expand Down Expand Up @@ -88,12 +90,14 @@ describe('RSC prod', () => {
const content = JSON.parse(
await fs.readFile(middlewareManifestPath, 'utf8')
)
expect(content.clientInfo).toEqual([
for (const item of [
['/', true],
['/next-api/image', true],
['/next-api/link', true],
['/routes/[dynamic]', true],
])
]) {
expect(content.clientInfo).toContainEqual(item)
}
})
runTests(context)
})
Expand All @@ -111,6 +115,35 @@ describe('RSC dev', () => {
runTests(context)
})

describe('CSS prod', () => {
const context = { appDir }

beforeAll(async () => {
context.appPort = await findPort()
await nextBuild(context.appDir)
context.server = await nextStart(context.appDir, context.appPort)
})
afterAll(async () => {
await killApp(context.server)
})

css(context)
})

describe('CSS dev', () => {
const context = { appDir }

beforeAll(async () => {
context.appPort = await findPort()
context.server = await nextDev(context.appDir, context.appPort)
})
afterAll(async () => {
await killApp(context.server)
})

css(context)
})

async function runTests(context) {
it('should render the correct html', async () => {
const homeHTML = await renderViaHTTP(context.appPort, '/')
Expand Down

0 comments on commit bae2bec

Please sign in to comment.