Unverified Commit d841f8ea authored by Shu Ding's avatar Shu Ding Committed by GitHub

Move CSS tests out of the main test suite (#45765)

No changes in this PR, just move out all CSS related tests out of
app-dir/app/index.tests.ts into a separate suite.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent a97aafea
'use client'
import { useState, useEffect } from 'react'
import style from './style.module.css'
import './style.css'
export default function ClientComponentRoute() {
const [count, setCount] = useState(0)
useEffect(() => {
setCount(1)
}, [count])
return (
<>
<p className={style.red}>
hello from app/client-component-route. <b>count: {count}</b>
</p>
</>
)
}
'use client'
import { useState, useEffect } from 'react'
import styles from './style.module.css'
import './style.css'
export default function ClientNestedLayout({ children }) {
const [count, setCount] = useState(0)
useEffect(() => {
setCount(1)
}, [])
return (
<>
<h1 className={styles.red}>Client Nested. Count: {count}</h1>
<button onClick={() => setCount(count + 1)}>{count}</button>
{children}
</>
)
}
export default function ClientPage() {
return (
<>
<p>hello from app/client-nested</p>
</>
)
}
'use client'
import styles from './client-comp.module.css'
import { useEffect, useState } from 'react'
export default function ClientComp() {
const [state, setState] = useState({})
useEffect(() => {
setState({ test: 'HELLOOOO' })
}, [])
return (
<>
<p className={styles.client}>Hello</p>
{state.test}
</>
)
}
import './style.css'
import './global.css'
export default function DashboardLayout(props) {
return (
<div className="dangerous-text">
<h1 className="green">Dashboard</h1>
{props.children}
</div>
)
}
import ClientComp from './client-comp-client'
export default function DashboardPage(props) {
return (
<>
<p id="from-dashboard" className="p">
hello from app/dashboard
</p>
<p className="bold">BOLD</p>
<p className="green">this is green</p>
<ClientComp />
</>
)
}
export const runtime = 'experimental-edge'
'use client'
import styles from './style.module.css'
export default function ErrorBoundary({ error, reset }) {
return (
<>
<p id="error-boundary-message">An error occurred: {error.message}</p>
<button id="reset" onClick={() => reset()} className={styles.button}>
Try again
</button>
</>
)
}
'use client'
import { useState } from 'react'
export default function Page() {
const [clicked, setClicked] = useState(false)
if (clicked) {
throw new Error('this is a test')
}
return (
<button
id="error-trigger-button"
onClick={() => {
setClicked(true)
}}
>
Trigger Error!
</button>
)
}
import { use } from 'react'
import '../styles/global.css'
import './style.css'
export const revalidate = 0
async function getData() {
return {
world: 'world',
}
}
export default function Root({ children }) {
const { world } = use(getData())
return (
<html className="this-is-the-document-html">
<head>
<title>{`hello ${world}`}</title>
</head>
<body className="this-is-the-document-body">{children}</body>
</html>
)
}
import './style.css'
export default function Loading() {
return <h2>Loading...</h2>
}
import { use } from 'react'
const fetchCategory = async (categorySlug) => {
// artificial delay
await new Promise((resolve) => setTimeout(resolve, 3000))
return categorySlug + 'abc'
}
export default function Page({ params }) {
const category = use(fetchCategory(params.categorySlug))
return <div id="category-id">{category}</div>
}
'use client'
import { notFound } from 'next/navigation'
export default function ClientComp() {
notFound()
return <></>
}
// TODO-APP: enable when flight error serialization is implemented
import ClientComp from './client-component'
import { headers } from 'next/headers'
export default function Page() {
// Opt-in to SSR.
headers()
return <ClientComp />
}
import styles from './style.module.css'
export default function NotFound() {
return (
<h1 id="not-found-component" className={styles.red}>
Not Found!
</h1>
)
}
// TODO-APP: enable when flight error serialization is implemented
import { notFound } from 'next/navigation'
export default function Page() {
notFound()
return <></>
}
import Link from 'next/link'
export default function Page() {
return (
<>
<p id="other-page">Other Page</p>
<Link href="/template/clientcomponent" id="link">
To Page
</Link>
</>
)
}
import Link from 'next/link'
export default function Page() {
return (
<>
<p id="page">Page</p>
<Link href="/template/clientcomponent/other" id="link">
To Other
</Link>
</>
)
}
'use client'
import { useState } from 'react'
import styles from './style.module.css'
export default function Template({ children }) {
const [count, setCount] = useState(0)
return (
<>
<h1>Template {count}</h1>
<button className={styles.button} onClick={() => setCount(count + 1)}>
Increment
</button>
{children}
</>
)
}
import Link from 'next/link'
export default function Page() {
return (
<>
<p id="other-page">Other Page</p>
<Link href="/template/servercomponent" id="link">
To Page
</Link>
</>
)
}
import Link from 'next/link'
export default function Page() {
return (
<>
<p id="page">Page</p>
<Link href="/template/servercomponent/other" id="link">
To Other
</Link>
</>
)
}
import styles from './style.module.css'
export default function Template({ children }) {
return (
<>
<h1 className={styles.red}>
Template <span id="performance-now">{performance.now()}</span>
</h1>
{children}
</>
)
}
This diff is collapsed.
module.exports = {
experimental: {
appDir: true,
},
}
import Link from 'next/link'
import classes from './page1.module.css'
import './page1.css'
export default function Page() {
return (
<>
<h1 className={classes.box}>Page 1</h1>
<div className="page-1">
<Link href="/css-modules/page2">Page 2</Link>
</div>
</>
)
}
import Link from 'next/link'
import classes from './page2.module.css'
import './page2.css'
export default function Page() {
return (
<>
<h1 id="page2" className={classes.box}>
Page 2
</h1>
<div className="page-2">
<Link href="/css-modules/page1">Page 1</Link>
</div>
</>
)
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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