Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add failing tests
  • Loading branch information
philipp-spiess committed Feb 17, 2025
commit ed6deafe9065ec969abe7706e8306dd9a77bb441
26 changes: 26 additions & 0 deletions crates/oxide/tests/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,32 @@ mod scanner {
assert_eq!(candidates, vec!["content-['foo.styl']"]);
}

#[test]
fn it_should_scan_next_dynamic_folders() {
let candidates = scan_with_globs(
&[
// We know that `.styl` extensions are ignored, so they are not covered by auto content
// detection.
("app/[slug]/page.styl", "content-['[slug]']"),
("app/[...slug]/page.styl", "content-['[...slug]']"),
("app/[[...slug]]/page.styl", "content-['[[...slug]]']"),
("app/(theme)/page.styl", "content-['(theme)']"),
],
vec!["./**/*.{styl}"],
)
.1;

assert_eq!(
candidates,
vec![
"content-['(theme)']",
"content-['[slug]']",
"content-['[...slug]']",
"content-['[[...slug]]']",
],
);
}

#[test]
fn it_should_scan_absolute_paths() {
// Create a temporary working directory
Expand Down
86 changes: 86 additions & 0 deletions integrations/postcss/next.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,89 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
},
)
})

test.only(
'should scan dynamic route segments',
{
fs: {
'package.json': json`
{
"dependencies": {
"react": "^18",
"react-dom": "^18",
"next": "^14"
},
"devDependencies": {
"@tailwindcss/postcss": "workspace:^",
"tailwindcss": "workspace:^"
}
}
`,
'postcss.config.mjs': js`
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
'@tailwindcss/postcss': {},
},
}

export default config
`,
'next.config.mjs': js`
/** @type {import('next').NextConfig} */
const nextConfig = {}

export default nextConfig
`,
'app/a/[slug]/page.js': js`
export default function Page() {
return <h1 className="content-['[slug]']">Hello, Next.js!</h1>
}
`,
'app/b/[...slug]/page.js': js`
export default function Page() {
return <h1 className="content-['[...slug]']">Hello, Next.js!</h1>
}
`,
'app/c/[[...slug]]/page.js': js`
export default function Page() {
return <h1 className="content-['[[...slug]]']">Hello, Next.js!</h1>
}
`,
'app/d/(theme)/page.js': js`
export default function Page() {
return <h1 className="content-['(theme)']">Hello, Next.js!</h1>
}
`,
'app/layout.js': js`
import './globals.css'

export default function RootLayout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
`,
'app/globals.css': css`
@import 'tailwindcss/utilities' source(none);
@source './**/*.{js,ts,jsx,tsx,mdx}';
`,
},
},
async ({ fs, exec, expect }) => {
await exec('pnpm next build')

let files = await fs.glob('.next/static/css/**/*.css')
expect(files).toHaveLength(1)
let [filename] = files[0]

await fs.expectFileToContain(filename, [
candidate`content-['[slug]']`,
candidate`content-['[...slug]']`,
candidate`content-['[[...slug]]']`,
candidate`content-['(theme)']`,
])
},
)