agroptima-design-system 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,3 +25,6 @@ jobs:
25
25
 
26
26
  - name: Lint
27
27
  run: npm run lint
28
+
29
+ - name: Types
30
+ run: npm run types
@@ -0,0 +1,27 @@
1
+ name: Run tests
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - synchronize
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Setup Node
18
+ uses: actions/setup-node@v3
19
+ with:
20
+ node-version: 18.x
21
+ cache: 'npm'
22
+
23
+ - name: Install dependencies
24
+ run: npm install
25
+
26
+ - name: Test
27
+ run: npm run test
package/app/.gitkeep ADDED
File without changes
package/jest.config.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { Config } from 'jest'
2
+ import nextJest from 'next/jest.js'
3
+
4
+ const createJestConfig = nextJest({
5
+ dir: './',
6
+ })
7
+
8
+ const config: Config = {
9
+ testEnvironment: 'jsdom',
10
+ clearMocks: true,
11
+ moduleNameMapper: {
12
+ '^.+\\.(svg)$': '<rootDir>/tests/svg.mock.js',
13
+ },
14
+ setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
15
+ }
16
+
17
+ export default createJestConfig(config)
package/jest.setup.ts ADDED
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroptima-design-system",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "scripts": {
5
5
  "dev": "npm run storybook",
6
6
  "storybook": "storybook dev -p 6006 --ci",
@@ -8,7 +8,9 @@
8
8
  "build-storybook": "storybook build",
9
9
  "lint": "eslint",
10
10
  "lint:fix": "eslint src --fix",
11
- "chromatic": "npx chromatic --exit-zero-on-changes"
11
+ "types": "tsc --noEmit",
12
+ "chromatic": "npx chromatic --exit-zero-on-changes",
13
+ "test": "jest"
12
14
  },
13
15
  "dependencies": {
14
16
  "@storybook/addon-designs": "^7.0.5",
@@ -28,6 +30,10 @@
28
30
  "@storybook/react": "^7.5.0",
29
31
  "@storybook/testing-library": "^0.2.2",
30
32
  "@svgr/webpack": "^8.1.0",
33
+ "@testing-library/jest-dom": "^6.4.2",
34
+ "@testing-library/react": "^14.2.2",
35
+ "@types/jest": "^29.5.12",
36
+ "@types/jest-axe": "^3.5.9",
31
37
  "@types/node": "^20.9.4",
32
38
  "@types/react": "^18.2.38",
33
39
  "@types/react-dom": "^18.2.17",
@@ -36,7 +42,11 @@
36
42
  "eslint-config-prettier": "^9.0.0",
37
43
  "eslint-plugin-prettier": "^5.0.1",
38
44
  "eslint-plugin-storybook": "^0.6.15",
45
+ "jest": "^29.7.0",
46
+ "jest-axe": "^8.0.0",
47
+ "jest-environment-jsdom": "^29.7.0",
39
48
  "storybook": "^7.6.6",
49
+ "ts-node": "^10.9.2",
40
50
  "typescript": "^5"
41
51
  },
42
52
  "description": "Agroptima design system",
@@ -5,7 +5,11 @@ import { Icon } from './Icon'
5
5
  export type Variant = 'primary'
6
6
  export type Option = { id: string; label: string }
7
7
 
8
- export interface SelectProps extends React.ComponentPropsWithoutRef<'input'> {
8
+ type InputPropsWithoutOnChange = Omit<
9
+ React.ComponentPropsWithoutRef<'input'>,
10
+ 'onChange'
11
+ >
12
+ export interface SelectProps extends InputPropsWithoutOnChange {
9
13
  placeholder?: string
10
14
  helpText?: string
11
15
  variant?: Variant
@@ -15,6 +19,7 @@ export interface SelectProps extends React.ComponentPropsWithoutRef<'input'> {
15
19
  accessibilityLabel?: string
16
20
  hideLabel?: boolean
17
21
  selected?: Option
22
+ onChange?: (value: string) => void
18
23
  }
19
24
 
20
25
  export function Select({
@@ -29,6 +34,7 @@ export function Select({
29
34
  accessibilityLabel,
30
35
  hideLabel = false,
31
36
  selected,
37
+ onChange,
32
38
  ...props
33
39
  }: SelectProps): React.JSX.Element {
34
40
  const [showOptionsList, setShowOptionsList] = useState(false)
@@ -55,7 +61,6 @@ export function Select({
55
61
  }
56
62
 
57
63
  function selectOption(option: Option) {
58
- const { onChange } = props
59
64
  setSelectedOption(option)
60
65
  setShowOptionsList(false)
61
66
 
@@ -3,6 +3,11 @@ import { Meta } from "@storybook/addon-docs";
3
3
  <Meta title="Changelog" />
4
4
  # Changelog
5
5
 
6
+ ## 0.6.1
7
+
8
+ - Fixed error type in onChange select props
9
+ - Added check types to CI
10
+
6
11
  ## 0.6.0
7
12
 
8
13
  Checkbox component is added to Storybook.
@@ -0,0 +1,29 @@
1
+ import { composeStories } from '@storybook/react'
2
+ import { act, render } from '@testing-library/react'
3
+ import { axe, toHaveNoViolations } from 'jest-axe'
4
+
5
+ import * as components from './library'
6
+
7
+ expect.extend(toHaveNoViolations)
8
+
9
+ const stories = Object.values(components).map((component) => {
10
+ return {
11
+ title: component.default.title,
12
+ stories: composeStories(component),
13
+ }
14
+ })
15
+
16
+ stories.forEach(({ title, stories }) => {
17
+ const variations = Object.entries(stories)
18
+
19
+ variations.forEach(([variationName, story]: [string, any]) => {
20
+ it(`${title} ${variationName} should be accessible`, async () => {
21
+ const { container } = render(story())
22
+
23
+ await act(async () => {
24
+ const results = await axe(container)
25
+ expect(results).toHaveNoViolations()
26
+ })
27
+ })
28
+ })
29
+ })
@@ -0,0 +1,9 @@
1
+ export * as Button from '../src/stories/Button.stories'
2
+ export * as CardsTable from '../src/stories/CardsTable.stories'
3
+ export * as CardsTableList from '../src/stories/CardsTableList.stories'
4
+ export * as Checkbox from '../src/stories/Checkbox.stories'
5
+ export * as EmptyState from '../src/stories/EmptyState.stories'
6
+ export * as IconButton from '../src/stories/IconButton.stories'
7
+ export * as Input from '../src/stories/Input.stories'
8
+ export * as Multiselect from '../src/stories/Multiselect.stories'
9
+ export * as Select from '../src/stories/Select.stories'
@@ -0,0 +1 @@
1
+ export default function () {}