From e245489fa809a19e07bc7d4b34d8dd0341a4e713 Mon Sep 17 00:00:00 2001 From: nicolethoen Date: Tue, 12 May 2026 10:19:05 -0400 Subject: [PATCH] fix: improve agent readiness of repo --- .github/workflows/build-lint-test.yml | 1 + .github/workflows/check-pr.yml | 23 ++++++++++ AGENTS.md | 43 +++++++++++++++++++ README.md | 13 +++++- jest.config.js | 9 +++- jest.setup-after-env.js | 1 + package.json | 41 +++++++++--------- .../src/Feedback/FeedbackModal.test.tsx | 28 ++++++++++++ packages/module/src/locales/Locale.test.ts | 9 ++++ packages/module/tsconfig.json | 3 +- 10 files changed, 146 insertions(+), 25 deletions(-) create mode 100644 AGENTS.md create mode 100644 jest.setup-after-env.js create mode 100644 packages/module/src/Feedback/FeedbackModal.test.tsx create mode 100644 packages/module/src/locales/Locale.test.ts diff --git a/.github/workflows/build-lint-test.yml b/.github/workflows/build-lint-test.yml index 44c4e31..967dd9a 100644 --- a/.github/workflows/build-lint-test.yml +++ b/.github/workflows/build-lint-test.yml @@ -1,4 +1,5 @@ name: build-lint-test +# PR workflows are path-scoped in check-pr.yml so CI does not run for unrelated-only changes. on: workflow_call: jobs: diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 2941006..9b480e0 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -4,6 +4,29 @@ on: branches: - main - v6 + paths: + - 'packages/**' + - 'scripts/**' + - 'fed-mini-modules.js' + - '.gitignore' + - 'renovate.json' + - 'LICENSE' + - 'package.json' + - 'yarn.lock' + - 'jest.config.js' + - 'jest.setup.js' + - 'jest.setup-after-env.js' + - 'styleMock.js' + - 'babel.config.js' + - '.eslintrc.json' + - '.eslintrc-md.json' + - '.eslintignore' + - '.prettierrc.json' + - '.prettierignore' + - '.husky/**' + - '.github/workflows/**' + - 'AGENTS.md' + - 'README.md' jobs: call-build-lint-test-workflow: uses: ./.github/workflows/build-lint-test.yml diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..43617fe --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,43 @@ +# Agent and contributor context + +This repository is a **Yarn v1 workspace** with a single published package. + +## Layout + +| Path | Package / role | +|------|----------------| +| Repo root | `@patternfly/react-user-feedback-root` — shared tooling (ESLint, Prettier, Jest, Babel), CI entrypoints, and workspace scripts. | +| `packages/module/` | `@patternfly/react-user-feedback` — the extension source, TypeScript build, PatternFly docs (examples + generated assets), and `semantic-release` config. | + +Generated or framework-owned files under `packages/module/patternfly-docs/generated/` should be treated as build output unless you are intentionally updating the docs pipeline. + +## Commands (run from repo root) + +| Task | Command | +|------|---------| +| Install | `yarn install` | +| Build library (`dist/`) | `yarn build` (delegates to `yarn workspace @patternfly/react-user-feedback build`) | +| Dev server (docs + examples) | `yarn start` | +| Unit tests (Jest + RTL) | `yarn test` | +| Lint (JS/TS + Markdown) | `yarn lint` | +| Docs production build | `yarn build:docs` | +| Serve built docs | `yarn serve:docs` | +| A11y tests | `yarn build:docs && yarn serve:docs` (separate shell) then `yarn test:a11y` | + +**Node:** CI uses Node 20. The root `package.json` includes a `packageManager` field for Yarn 1.22.x. + +## CI scope (path filters) + +`.github/workflows/check-pr.yml` limits `build-lint-test` to pull requests that touch **listed paths** (see that file for the exact set). Examples that **do** trigger CI include `packages/**`, root Jest/Babel/ESLint config, `package.json`, `yarn.lock`, `.gitignore`, `renovate.json`, `agentready-checklist-report-*.md`, `LICENSE`, workflows, `README.md`, and `AGENTS.md`. + +**Not every root file is listed.** If your PR only changes paths outside the filter (for example a new root dotfile or doc not yet added to the list), the PR check may **not** run automatically. To get a green check: touch any listed path (e.g. add a trivial comment to `AGENTS.md`—prefer updating `check-pr.yml` if the omission was an oversight), or ask a maintainer to run the workflow. When extending the list, prefer explicit paths over broad `**` globs so unrelated edits do not spam CI. + +When the workflow runs, jobs use a **full** `yarn build` (single publishable package—no Turborepo/Nx graph). Scoping is intentionally **path-based on the PR** rather than per-task “affected” builds. + +## Release + +`packages/module/release.config.js` configures **semantic-release** for npm publishing. Commit messages follow [Angular / semantic-release conventions](https://github.com/semantic-release/semantic-release). + +## External guidelines + +- [PatternFly AI-assisted development / contributing](https://github.com/patternfly/.github/blob/main/CONTRIBUTING.md) diff --git a/README.md b/README.md index 7c78820..1e7a9bb 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,17 @@ This project is a [PatternFly](https://github.com/patternfly/patternfly-react) React extension that products can use to collect feedback from users. To view examples of this extension’s use, [view its documentation on PatternFly](https://www.patternfly.org/v4/extensions/user-feedback). +## Repository layout (Yarn workspaces) + +This repo uses **[Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)** (`package.json` → `"workspaces": ["packages/*"]`). + +| Location | NPM name | Purpose | +|----------|-----------|---------| +| Repository root | `@patternfly/react-user-feedback-root` | Workspace root: shared lint/test/build tooling and scripts that delegate into packages. | +| `packages/module/` | `@patternfly/react-user-feedback` | Library source, `dist/` build output, PatternFly docs site for examples, and release configuration. | + +Most product code and docs examples live under **`packages/module/`**. For agent-oriented notes (commands, CI behavior, boundaries), see **[`AGENTS.md`](./AGENTS.md)**. + ## Installing dependencies [Yarn](https://yarnpkg.com/) is used to develop and build user feedback. To install dependencies for this project, use the `yarn install` terminal command: @@ -12,7 +23,7 @@ yarn install ## Building the extension -Once dependencies are installed, you can build user feedback locally using the `yard build` terminal command: +Once dependencies are installed, you can build user feedback locally using the `yarn build` terminal command (runs the workspace package build): ``` yarn build diff --git a/jest.config.js b/jest.config.js index 5e55518..b68d201 100644 --- a/jest.config.js +++ b/jest.config.js @@ -10,9 +10,14 @@ module.exports = { transform: { '^.+\\.[jt]sx?$': 'babel-jest' }, + // Transpile @patternfly/* ESM in node_modules; extend the (?!...) group if another + // dependency ships untranspiled ESM that Jest must transform. + transformIgnorePatterns: ['/node_modules/(?!(@patternfly)/)'], moduleNameMapper: { - '\\.(css|less)$': '/styleMock.js' + '\\.(css|less)$': '/styleMock.js', + '\\.svg$': '/styleMock.js' }, testEnvironment: 'jsdom', - setupFiles: ['./jest.setup.js'] + setupFiles: ['./jest.setup.js'], + setupFilesAfterEnv: ['./jest.setup-after-env.js'] }; diff --git a/jest.setup-after-env.js b/jest.setup-after-env.js new file mode 100644 index 0000000..0932648 --- /dev/null +++ b/jest.setup-after-env.js @@ -0,0 +1 @@ +require('@testing-library/jest-dom'); diff --git a/package.json b/package.json index 8b63082..dcf978d 100644 --- a/package.json +++ b/package.json @@ -17,48 +17,47 @@ "lint:js": "node --max-old-space-size=4096 node_modules/.bin/eslint packages --ext js,jsx,ts,tsx --cache", "lint:md": "yarn eslint packages --ext md --no-eslintrc --config .eslintrc-md.json --cache", "lint": "yarn lint:js && yarn lint:md", - "test": "echo 'Disabled JEST testing'", - "_test": "TZ=EST jest packages", + "test": "TZ=EST jest packages/module --maxWorkers=2", "test:a11y": "yarn workspace @patternfly/react-user-feedback test:a11y", "serve:a11y": "yarn workspace @patternfly/react-user-feedback serve:a11y", "prepare": "husky install" }, "devDependencies": { - "babel-jest": "^29.2.2", "@babel/core": "^7.19.6", "@babel/preset-env": "^7.19.4", - "@babel/preset-react": "^7.18.6", "@babel/preset-flow": "^7.18.6", + "@babel/preset-react": "^7.18.6", "@babel/preset-typescript": "^7.18.6", - "react": "^18", - "react-dom": "^18", - "typescript": "^4.7.4", - "@typescript-eslint/eslint-plugin": "^5.42.0", - "@typescript-eslint/parser": "^5.42.0", + "@testing-library/dom": "9.0.0", + "@testing-library/jest-dom": "5.16.5", + "@testing-library/react": "^13.4.0", + "@testing-library/user-event": "14.4.3", "@types/react": "^18", "@types/react-dom": "^18", + "@typescript-eslint/eslint-plugin": "^5.42.0", + "@typescript-eslint/parser": "^5.42.0", + "babel-jest": "^29.2.2", "concurrently": "^5.3.0", "eslint": "^8.0.1", + "eslint-config-prettier": "8.5.0", + "eslint-config-standard-with-typescript": "^23.0.0", "eslint-plugin-import": "^2.25.2", "eslint-plugin-markdown": "^1.0.2", - "eslint-plugin-prettier": "^3.1.4", - "eslint-plugin-react": "^7.21.4", - "eslint-config-standard-with-typescript": "^23.0.0", "eslint-plugin-n": "^15.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-promise": "^6.0.0", + "eslint-plugin-react": "^7.21.4", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-config-prettier": "8.5.0", - "prettier": "2.7.1", - "jest": "^29.2.2", "husky": "^8.0.3", - "@testing-library/react": "^13.4.0", - "@testing-library/user-event": "14.4.3", - "@testing-library/jest-dom": "5.16.5", - "@testing-library/dom": "9.0.0", - "jest-environment-jsdom": "^29.2.2", + "jest": "^29.2.2", "jest-canvas-mock": "^2.4.0", + "jest-environment-jsdom": "^29.2.2", + "prettier": "2.7.1", + "react": "^18", + "react-dom": "^18", + "rimraf": "^2.6.2", "serve": "^14.1.2", - "rimraf": "^2.6.2" + "typescript": "^4.7.4" }, "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/packages/module/src/Feedback/FeedbackModal.test.tsx b/packages/module/src/Feedback/FeedbackModal.test.tsx new file mode 100644 index 0000000..8a5ce0a --- /dev/null +++ b/packages/module/src/Feedback/FeedbackModal.test.tsx @@ -0,0 +1,28 @@ +import { render, screen } from '@testing-library/react'; +import { FeedbackModal } from './FeedbackModal'; + +describe('FeedbackModal', () => { + it('does not expose a dialog in the accessibility tree when closed', () => { + const onClose = jest.fn(); + render( + + ); + expect(screen.queryByRole('dialog', { name: 'Feedback modal' })).not.toBeInTheDocument(); + }); + + it('exposes the feedback modal to assistive technologies when open', () => { + const onClose = jest.fn(); + render( + + ); + expect(screen.getByRole('dialog', { name: 'Feedback modal' })).toBeInTheDocument(); + }); +}); diff --git a/packages/module/src/locales/Locale.test.ts b/packages/module/src/locales/Locale.test.ts new file mode 100644 index 0000000..3709845 --- /dev/null +++ b/packages/module/src/locales/Locale.test.ts @@ -0,0 +1,9 @@ +import { defaultFeedback } from './Locale'; + +describe('defaultFeedback', () => { + it('includes core UI strings for the feedback flow', () => { + expect(defaultFeedback.shareFeedback).toBeTruthy(); + expect(defaultFeedback.close).toBeTruthy(); + expect(defaultFeedback.tellAboutExperience).toBeTruthy(); + }); +}); diff --git a/packages/module/tsconfig.json b/packages/module/tsconfig.json index edf4265..01e451b 100644 --- a/packages/module/tsconfig.json +++ b/packages/module/tsconfig.json @@ -68,5 +68,6 @@ "skipLibCheck": true /* Skip type checking of declaration files. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ }, - "include": ["src/@types/assets.d.ts", "./src/*", "./src/**/*", "../../index.d.ts"] + "include": ["src/@types/assets.d.ts", "./src/*", "./src/**/*", "../../index.d.ts"], + "exclude": ["**/*.test.ts", "**/*.test.tsx", "**/__tests__/**"] }