mirror of
https://github.com/gromlab-ru/svg-sprites.git
synced 2026-07-22 04:40:17 +03:00
test: добавить площадку интеграционного тестирования
- добавлены consumer fixtures для React и Next.js - добавлены typecheck, production build и браузерные smoke-тесты - добавлена интеграционная проверка в CI
This commit is contained in:
11
integration/apps/next-app-turbopack/app/layout.tsx
Normal file
11
integration/apps/next-app-turbopack/app/layout.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
import './style.css'
|
||||
|
||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
18
integration/apps/next-app-turbopack/app/page.tsx
Normal file
18
integration/apps/next-app-turbopack/app/page.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { IconsIcon } from '../src/sprite'
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<main>
|
||||
<h1>Next.js App Router + Turbopack</h1>
|
||||
<IconsIcon
|
||||
data-testid="icon"
|
||||
data-app="next-app-turbopack"
|
||||
icon="check"
|
||||
aria-label="Check icon"
|
||||
width={64}
|
||||
height={64}
|
||||
style={{ '--icon-color-1': '#16a34a' }}
|
||||
/>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
10
integration/apps/next-app-turbopack/app/style.css
Normal file
10
integration/apps/next-app-turbopack/app/style.css
Normal file
@@ -0,0 +1,10 @@
|
||||
:root {
|
||||
font-family: system-ui, sans-serif;
|
||||
color: #172033;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 40px;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { IconsIcon, iconsIconNames } from './src/sprite'
|
||||
import type { IconsIconName, IconsIconProps, IconsIconStyle } from './src/sprite'
|
||||
import { IconsIcon as GeneratedIconsIcon } from './src/sprite/.svg-sprite/react/react-component.js'
|
||||
import type { IconsIconName as GeneratedIconName } from './src/sprite/.svg-sprite/icon-data.js'
|
||||
import { iconsIconNames as generatedIconNames } from './src/sprite/.svg-sprite/icon-data.js'
|
||||
|
||||
const iconName: IconsIconName = iconsIconNames[0]
|
||||
const generatedIconName: GeneratedIconName = generatedIconNames[0]
|
||||
const allIconNames: readonly IconsIconName[] = iconsIconNames
|
||||
const style: IconsIconStyle = { '--icon-color-1': '#16a34a' }
|
||||
const props: IconsIconProps = { icon: iconName, style }
|
||||
|
||||
void allIconNames
|
||||
void <IconsIcon {...props} />
|
||||
void <GeneratedIconsIcon icon={generatedIconName} />
|
||||
|
||||
// @ts-expect-error Unknown icon names must be rejected by generated declarations.
|
||||
void <IconsIcon icon="missing" />
|
||||
6
integration/apps/next-app-turbopack/next-env.d.ts
vendored
Normal file
6
integration/apps/next-app-turbopack/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
import "./.next/types/routes.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
10
integration/apps/next-app-turbopack/next.config.mjs
Normal file
10
integration/apps/next-app-turbopack/next.config.mjs
Normal file
@@ -0,0 +1,10 @@
|
||||
import path from 'node:path'
|
||||
|
||||
const integrationRoot = path.resolve(import.meta.dirname, '../..')
|
||||
|
||||
export default {
|
||||
outputFileTracingRoot: integrationRoot,
|
||||
turbopack: {
|
||||
root: integrationRoot,
|
||||
},
|
||||
}
|
||||
24
integration/apps/next-app-turbopack/package.json
Normal file
24
integration/apps/next-app-turbopack/package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@svg-sprites-fixtures/next-app-turbopack",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"sprites": "svg-sprites src/sprite/svg-sprite.config.ts",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"build": "npm run sprites && next build --turbopack",
|
||||
"dev": "npm run sprites && next dev --turbopack",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "16.2.10",
|
||||
"react": "19.2.5",
|
||||
"react-dom": "19.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gromlab/svg-sprites": "file:../../..",
|
||||
"@types/node": "24.12.0",
|
||||
"@types/react": "19.2.17",
|
||||
"@types/react-dom": "19.2.3",
|
||||
"typescript": "6.0.2"
|
||||
}
|
||||
}
|
||||
2
integration/apps/next-app-turbopack/src/sprite/.gitignore
vendored
Normal file
2
integration/apps/next-app-turbopack/src/sprite/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# @generated by @gromlab/svg-sprites. Do not edit.
|
||||
/.svg-sprite/
|
||||
1
integration/apps/next-app-turbopack/src/sprite/index.ts
Normal file
1
integration/apps/next-app-turbopack/src/sprite/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './.svg-sprite'
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineSpriteConfig } from '@gromlab/svg-sprites'
|
||||
|
||||
export default defineSpriteConfig({
|
||||
mode: 'next@app/turbopack',
|
||||
name: 'icons',
|
||||
inputFiles: ['../../../../fixtures/icons/check.svg'],
|
||||
generatedNotice: false,
|
||||
})
|
||||
36
integration/apps/next-app-turbopack/tsconfig.json
Normal file
36
integration/apps/next-app-turbopack/tsconfig.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"DOM.Iterable",
|
||||
"ES2022"
|
||||
],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"incremental": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
".next/types/**/*.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/dev/types/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user