Skip to content

Conversation

@ElizabethSamuel-MSFT
Copy link
Contributor

No description provided.

)

* Add automated testing infrastructure and fix compilation failures

## Testing Infrastructure Added

### Test Suites (3)
1. **TypeScript Compilation Tests** - Validates all snippet code compiles against Office.js type definitions
2. **Library URL Validation Tests** - Verifies all library URLs are reachable
3. **API Version Compatibility Tests** - Detects API usage incompatible with declared api_set versions

### Test Commands
- npm test              # Run all tests
- npm run test:compile  # TypeScript compilation only
- npm run test:apis     # API version validation only
- npm run test:libs     # Library URL checks only
- npm run test:watch    # Watch mode
- npm run test:coverage # With coverage
- npm run test:report   # Generate failure reports
- npm run validate      # Full validation (build + lint + tests)

### CI/CD Pipeline
- Runs on every PR to main/prod branches
- Runs on every push to main/prod branches
- Tests on Node.js versions 18.x and 20.x
- Uploads test results and coverage as artifacts

### Documentation
- TESTING.md - Complete testing infrastructure guide
- CLAUDE.md - Claude Code specific guidance for working with this repo
- COMPILATION-FAILURES.md/csv - Auto-generated test reports

## Snippet Compilation Fixes (9 snippets)

Fixed TypeScript compilation errors in the following snippets:

**Excel (4 snippets):**
- conditional-formatting-basic.yaml - Removed dead code (querySelectorAll for non-existent elements)
- data-types-basic-types.yaml - Added type assertions for complex CellValue objects
- sort-data.yaml - Removed duplicate sheet variable declaration
- chart-title-ts.yaml - Fixed string casing ("auto" → "Auto", "right" → "Right")

**Outlook (3 snippets):**
- get-set-recurrence-appointment-organizer.yaml - Fixed type annotation and added assertion
- display-new-appointment.yaml - Added type assertions for attendee arrays
- get-loaded-message-properties.yaml - Fixed Promise<void> type and property access

**Word (2 snippets):**
- manage-custom-style.yaml - Converted numbers to strings for HTMLInputElement.value
- manage-footnotes.yaml - Fixed string-to-number conversions using Number()

## Test Results

**Status: 335/335 snippets passing (100%)**

- Total snippets tested: 335
- Excel: 151 snippets
- Outlook: 90 snippets
- Word: 67 snippets
- PowerPoint: 23 snippets
- Project: 2 snippets
- OneNote: 1 snippet
- Web: 1 snippet

## Key Features

✅ **Zero maintenance** - Tests automatically discover new snippets
✅ **Instant validation** - Contributors get immediate feedback
✅ **Comprehensive coverage** - All snippets tested on every PR
✅ **Clear reporting** - Detailed failure reports with line numbers
✅ **Future-proof** - Scales to any number of snippets

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Fix CI: Add package-lock.json for npm caching

The CI workflow requires a lock file for npm cache to work.
Removed package-lock.json from .gitignore and added the generated
lock file to ensure reproducible builds and enable CI caching.

* Remove API version validation and clean up generated files

## Changes

### Removed API Version Validation System
- Deleted tests/api-version-validator.test.ts
- Deleted tests/data/api-versions.json
- Deleted tests/helpers/api-usage-parser.ts
- Removed npm run test:apis command

**Rationale:**
- Limited subset (~80 APIs of thousands available)
- Not catching any issues (0 validations in test runs)
- Maintenance burden (requires manual catalog updates)
- Redundant with TypeScript compilation (validates through type definitions)

The TypeScript compilation test already provides comprehensive API validation
by using official Office.js type definitions, which are always up-to-date.

### Updated .gitignore
- Added COMPILATION-FAILURES.md (auto-generated report)
- Added COMPILATION-FAILURES.csv (auto-generated report)
- Removed these files from version control

**Rationale:**
These are temporary test outputs that change on every run and should not
be committed to the repository.

### Updated Documentation
- Updated TESTING.md to reflect 2 test suites (was 3)
- Removed API version catalog documentation
- Updated test results to show 100% pass rate
- Simplified test commands

## Result

Cleaner, more maintainable testing infrastructure that:
- Focuses on what works (TypeScript compilation + URL validation)
- Removes maintenance burden (no manual API catalog)
- Excludes generated files from version control
- Relies on authoritative Office.js type definitions

* Fix CI: Exclude tests directory from main tsconfig

The main tsconfig.json (for config/ files) was trying to compile test files,
causing TS6059 errors about files not being under rootDir.

Added exclude array to prevent main TypeScript compilation from processing
test files. Test files are compiled separately by Jest using tsconfig.test.json.

* Update readme

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Address Copilot PR review feedback

Critical bug fixes:
- Fix Promise not resolving on error paths in get-loaded-message-properties.yaml
  (would hang async flow when API calls fail)
- Add missing semicolon in chart-title-ts.yaml (per style guidelines)
- Remove Node 18.x from CI matrix (rimraf@6+ requires Node 20+)

Code quality improvements:
- Exclude quick-test.test.ts from CI runs (local smoke test only)
- Remove dead lodash extensions infrastructure (was disabled, never used)

Not addressed (intentional):
- Type assertions (as any) are pragmatic workarounds for incomplete Office.js type definitions

* Suppress artifact upload warning for missing log files

Add if-no-files-found: ignore to upload-artifact step to suppress
warning when no .log files are present. The *.log pattern remains
as a safety net to capture npm error logs if tests fail.

Addresses PR review feedback from @ElizabethSamuel-MSFT

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Address PR feedback: Update Node version, remove unused deps, fix jQuery usage

- Update CI to use Node 24 (current LTS) instead of Node 20
- Remove jQuery dependencies (@types/jquery) - not used in any snippets
- Remove node-fetch and migrate to native fetch API with AbortController
- Fix jQuery usage in private-samples/excel/20-chart/chart-title-ts.yaml
  - Convert jQuery syntax to standard DOM API (getElementById, addEventListener)
- Keep Lodash dependencies (used by build scripts and 1 sample)
- Result: 26 packages removed from node_modules

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Address PR style feedback: Use template literals and parseInt

- Replace String() constructor with template literals in manage-custom-style.yaml
  More modern and concise syntax for converting numbers to strings
- Replace Number() with Number.parseInt() in manage-footnotes.yaml
  More semantically correct for parsing integers from string input
  Explicitly specifies radix 10 to avoid any ambiguity

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Update ES version

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ElizabethSamuel-MSFT ElizabethSamuel-MSFT merged commit 2028c47 into prod Feb 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants