Skip to content

Commit 44a6cdd

Browse files
committed
new: dev utils package
1 parent 8102d58 commit 44a6cdd

File tree

67 files changed

+13274
-7431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+13274
-7431
lines changed

package-lock.json

+13,120-7,348
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"./packages/react",
7272
"./packages/hooks",
7373
"./packages/utils",
74+
"./packages/dev-utils",
7475
"./packages/ui/*",
7576
"./packages/common/*"
7677
],

packages/assets/css/src/scss/_utils/_tokens.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
// Do not edit directly
3-
// Generated on Mon, 16 Sep 2024 05:01:25 GMT
3+
// Generated on Wed, 23 Oct 2024 10:41:22 GMT
44

55
$accordion-border-radius-sm: 10px;
66
$advanced-banner-background: linear-gradient(90deg, #222 0%, #383323 48.96%, #514524 100%);

packages/dev-utils/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @wpmudev/sui-dev-utils
2+
3+
## 0.0.1
4+
5+
### Patch Changes
6+
7+
- Initial release

packages/dev-utils/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- ⚠️ This README has been generated from the file(s) "../../blueprint.md" ⚠️--><h1 align="center">@wpmudev/sui-utils</h1>
2+
3+
<div style="text-align: center;">
4+
<img src="https://img.shields.io/badge/Version-0.0.1-blue.svg" alt="Version"> <img src="https://img.shields.io/badge/License-GPL-orange.svg" alt="License">
5+
</div>
6+
<h2> Description </h2> WPMU DEV Shared UI React Global Functions
7+
8+
9+
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#license)
10+
11+
## ➤ License
12+
13+
Licensed under [GPL-2.0](https://opensource.org/licenses/GPL-2.0).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict"
2+
3+
describe("@wpmudev/sui-dev-utils", () => {})

packages/dev-utils/package.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "@wpmudev/sui-dev-utils",
3+
"version": "0.0.1",
4+
"description": "WPMU DEV Shared UI React Functions for Development Environment",
5+
"keywords": [],
6+
"author": "WPMU DEV (https://wpmudev.com)",
7+
"license": "GPL-2.0",
8+
"main": "src/index.ts",
9+
"directories": {
10+
"src": "src",
11+
"test": "__tests__"
12+
},
13+
"files": [
14+
"dist"
15+
],
16+
"publishConfig": {
17+
"access": "public"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/wpmudev/sui-docs.git"
22+
},
23+
"scripts": {
24+
"clean": "rm -rf dist && rm -rf lib",
25+
"build": "npx tsup",
26+
"build:dev": "npx tsup --watch",
27+
"build:fast": "tsup src",
28+
"dev": "npm build:fast -- --watch",
29+
"prepack": "clean-package",
30+
"postpack": "clean-package restore",
31+
"build:readme": "readme generate --input ../../blueprint.md"
32+
},
33+
"bugs": {
34+
"url": "https://github.com/wpmudev/sui-docs/issues"
35+
},
36+
"homepage": "https://github.com/wpmudev/sui-docs#readme",
37+
"dependencies": {
38+
"react": "^18.2.0"
39+
},
40+
"devDependencies": {
41+
"@testing-library/react": "^14.0.0",
42+
"jest-axe": "^8.0.0"
43+
},
44+
"clean-package": "../../postpack.config.json"
45+
}

packages/dev-utils/src/index.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react"
2+
import { render } from "@testing-library/react"
3+
import { axe } from "jest-axe"
4+
5+
/**
6+
* It is a utility function for performing accessibility testing on a React component.
7+
*
8+
* Note: It only runs the test if an environment variable, `SUI_A11Y_TEST`, is turned on.
9+
* If the test is on, it checks the component for accessibility issues using the Axe library.
10+
*
11+
* @param {React.ReactElement} component - The React component to be tested for accessibility.
12+
* @param {Object} config - axe configuration
13+
*/
14+
const a11yTest = async (component: React.ReactElement, config?: object) => {
15+
if (process.env.SUI_A11Y_TEST) {
16+
const { container } = render(component)
17+
const results = await axe(container, config)
18+
expect(results).toHaveNoViolations()
19+
}
20+
}
21+
22+
// Publish required function(s).
23+
export { a11yTest }

packages/dev-utils/tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
}

packages/ui/accordion/__tests__/accordion.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { fireEvent, render, screen } from "@testing-library/react"
55
import { Accordion, AccordionItem, AccordionItemBody } from "../src"
66

77
import { InfoAlt } from "@wpmudev/sui-icons"
8-
import { a11yTest } from "@wpmudev/sui-utils"
8+
import { a11yTest } from "@wpmudev/sui-dev-utils"
99

1010
describe("@wpmudev/sui-accordion", () => {
1111
// Common props for the Accordion component

packages/ui/advanced-banner/__tests__/advanced-banner.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { render, screen } from "@testing-library/react"
44

55
import { AdvancedBanner } from "../src"
66

7-
import { a11yTest } from "@wpmudev/sui-utils"
7+
import { a11yTest } from "@wpmudev/sui-dev-utils"
88

99
describe("@wpmudev/sui-advanced-banner", () => {
1010
it("render correctly", () => {

packages/ui/alert-banner/__tests__/alert-banner.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { render, screen } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55

66
import { AlertBanner } from "../src"
77

packages/ui/avatar/__tests__/avatar.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import { render, screen } from "@testing-library/react"
33
import "@testing-library/jest-dom" // This is still needed to extend Jest's expect
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { Avatar } from "../src"
66

77
describe("@wpmudev/sui-avatar", () => {

packages/ui/basic-box/__tests__/basic-box.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
3-
import { a11yTest } from "@wpmudev/sui-utils"
3+
import { a11yTest } from "@wpmudev/sui-dev-utils"
44
import { screen, render, fireEvent } from "@testing-library/react"
55
import { BasicBox } from "../src"
66

packages/ui/box/__tests__/box.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import "@testing-library/jest-dom"
33
import { render, screen } from "@testing-library/react"
44
import { Box, BoxGroup } from "../src"
5-
import { a11yTest } from "@wpmudev/sui-utils"
5+
import { a11yTest } from "@wpmudev/sui-dev-utils"
66
import { IconsNamesType } from "@wpmudev/sui-icons"
77

88
describe("@wpmudev/box", () => {

packages/ui/builder/__tests__/builder.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import "@testing-library/jest-dom"
33
import { within } from "@testing-library/dom"
44
import { screen, render, fireEvent } from "@testing-library/react"
5-
import { a11yTest } from "@wpmudev/sui-utils"
5+
import { a11yTest } from "@wpmudev/sui-dev-utils"
66
import { Builder, BuilderField, BuilderProps, BuilderWrapper } from "../src"
77

88
describe("@wpmudev/sui-builder", () => {

packages/ui/button/__tests__/button.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom" // This is still needed to extend Jest's expect
33
import { within } from "@testing-library/dom"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { render, screen } from "@testing-library/react"
66
import { Button } from "@wpmudev/sui-button"
77

packages/ui/checkbox/__tests__/checkbox.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "@testing-library/jest-dom"
44
import { screen, render, fireEvent, prettyDOM } from "@testing-library/react"
55

66
import { Checkbox, CheckboxGroup, CheckBoxGroups } from "../src"
7-
import { a11yTest } from "@wpmudev/sui-utils"
7+
import { a11yTest } from "@wpmudev/sui-dev-utils"
88

99
describe("@wpmudev/sui-checkbox", () => {
1010
// Test case for rendering Checkbox component correctly

packages/ui/code-editor/__tests__/code-editor.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { CodeEditor, CodeEditorProps } from "../src"
66

77
describe("@wpmudev/code-editor", () => {

packages/ui/code-snippet/__tests__/code-snippet.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import "@testing-library/jest-dom"
33
import { userEvent } from "@testing-library/user-event"
44
import { screen, render, fireEvent } from "@testing-library/react"
5-
import { a11yTest } from "@wpmudev/sui-utils"
5+
import { a11yTest } from "@wpmudev/sui-dev-utils"
66
import { CodeSnippet, CodeSnippetProps } from "../src"
77

88
describe("@wpmudev/sui-code-snippet", () => {

packages/ui/color-picker/__tests__/color-picker.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render, fireEvent, waitFor } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { ColorPicker, ColorPickerProps } from "../src"
66

77
describe("@wpmudev/sui-color-picker", () => {

packages/ui/config-table/__tests__/config-table.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55

66
import { ConfigTable } from "../src"
77
import { configs } from "../stories/configs"

packages/ui/dashboard-widget/__tests__/dashboard-widget.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { DashboardWidget } from "../src"
66

77
describe("@wpmudev/sui-dashboard-widget", () => {

packages/ui/date-picker/__tests__/date-picker.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render, fireEvent } from "@testing-library/react"
44
import { DatePicker, DatePickerProps } from "../src"
5-
import { a11yTest } from "@wpmudev/sui-utils"
5+
import { a11yTest } from "@wpmudev/sui-dev-utils"
66

77
describe("@wpmudev/sui-date-picker", () => {
88
const Component = (propsList: DatePickerProps) => {

packages/ui/drawer/__tests__/drawer.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render } from "@testing-library/react"
4-
// import { a11yTest } from "@wpmudev/sui-utils"
4+
// import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import {
66
Drawer,
77
DrawerHeader,
88
DrawerBody,
99
DrawerFooter,
1010
DrawerTypes,
1111
} from "../src"
12-
import { a11yTest } from "@wpmudev/sui-utils"
12+
import { a11yTest } from "@wpmudev/sui-dev-utils"
1313

1414
describe("@wpmudev/sui-drawer", () => {
1515
const Component = (propsList: DrawerTypes) => {

packages/ui/dropdown/__tests__/dropdown.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useRef } from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render, fireEvent, waitFor } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { Button } from "@wpmudev/sui-button"
66
import { Dropdown, DropdownRefProps } from "../src"
77
import { MenuGroupProps, MenuItemProps } from "../src/dropdown.types"

packages/ui/editor-toolbar/__tests__/editor-toolbar.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { ReactNode } from "react"
22
import "@testing-library/jest-dom"
33
import { render, screen } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { EditorToolbar } from "../src"
66

77
describe("@wpmudev/sui-editor-toolbar", () => {

packages/ui/empty-state/__tests__/empty-state.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { EmptyState, EmptyStateProps } from "../src"
66

77
describe("@wpmudev/sui-empty-state", () => {

packages/ui/field-list/__tests__/field-list.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { FieldList, FieldListItem } from "../src"
66

77
describe("@wpmudev/sui-field-list", () => {

packages/ui/footer/__tests__/footer.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { render, screen } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55

66
import { Footer } from "../src"
77

packages/ui/form-field/__tests__/form-field.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
3-
import { a11yTest } from "@wpmudev/sui-utils"
3+
import { a11yTest } from "@wpmudev/sui-dev-utils"
44
import { render, screen } from "@testing-library/react"
55
import { FormField } from "../src"
66

packages/ui/grid/__tests__/grid.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import "@testing-library/jest-dom"
33
import { Row, Col } from "../src"
44
import { render, screen } from "@testing-library/react"
5-
import { a11yTest } from "@wpmudev/sui-utils"
5+
import { a11yTest } from "@wpmudev/sui-dev-utils"
66

77
describe("@wpmudev/sui-grid", () => {
88
const Component = () => (

packages/ui/input/__tests__/input.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
3-
import { a11yTest } from "@wpmudev/sui-utils"
3+
import { a11yTest } from "@wpmudev/sui-dev-utils"
44
import { screen, render } from "@testing-library/react"
55

66
import { Input } from "../src"

packages/ui/integration/__tests__/integration.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { fireEvent, render, screen } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { Integration } from "../src"
66

77
describe("@wpmudev/sui-integration", () => {

packages/ui/link/__tests__/link.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { render, screen } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { Link } from "@wpmudev/sui-link"
66

77
describe("@wpmudev/sui-link", () => {

packages/ui/modal/__tests__/modal.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Fragment, useRef } from "react"
22
import "@testing-library/jest-dom"
33
import { fireEvent, render, screen } from "@testing-library/react"
44
import { Button } from "@wpmudev/sui-button"
5-
import { a11yTest } from "@wpmudev/sui-utils"
5+
import { a11yTest } from "@wpmudev/sui-dev-utils"
66

77
import {
88
Modal,

packages/ui/navigation/__tests__/navigation.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Fragment } from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { Navigation } from "../src"
66

77
describe("@wpmudev/sui-navigation", () => {

packages/ui/notification/__tests__/notification.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Fragment } from "react"
22
import "@testing-library/jest-dom"
33
import { fireEvent, render, screen } from "@testing-library/react"
44
import { Button } from "@wpmudev/sui-button"
5-
import { a11yTest } from "@wpmudev/sui-utils"
5+
import { a11yTest } from "@wpmudev/sui-dev-utils"
66
import { Notification, NotificationRenderer, NotificationProps } from "../src"
77
import { useNotifications } from "../src/use-notification"
88

packages/ui/pagination/__tests__/pagination.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import "@testing-library/jest-dom"
33
import { screen, render, fireEvent } from "@testing-library/react"
4-
import { a11yTest } from "@wpmudev/sui-utils"
4+
import { a11yTest } from "@wpmudev/sui-dev-utils"
55
import { Pagination } from "../src"
66

77
const itemList = [

0 commit comments

Comments
 (0)