Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package to test public API surface used by apps #23450

Merged
merged 7 commits into from
Jan 7, 2025

Conversation

CraigMacomber
Copy link
Contributor

Description

The actual d.ts files we let customers use can have issues that can't be detected without importing them.
Thus to test them we need tests which can import them.
Previously some of these tests randomly lived in tree-react-utils.
This change moves those tests to a new package created for this purpose, with the expectation that other tests will be added in the future.

Reviewer Guidance

The review process is outlined on this wiki page.

@Copilot Copilot bot review requested due to automatic review settings January 3, 2025 20:25
@CraigMacomber CraigMacomber requested a review from a team as a code owner January 3, 2025 20:25
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree area: examples Changes that focus on our examples dependencies Pull requests that update a dependency file base: main PRs targeted against main branch and removed area: examples Changes that focus on our examples area: dds Issues related to distributed data structures dependencies Pull requests that update a dependency file area: dds: tree labels Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 11 changed files in this pull request and generated no comments.

Files not reviewed (5)
  • examples/utils/import-testing/biome.jsonc: Language not supported
  • examples/utils/import-testing/package.json: Language not supported
  • examples/utils/import-testing/src/test/tsconfig.json: Language not supported
  • examples/utils/import-testing/tsconfig.json: Language not supported
  • examples/utils/import-testing/.eslintrc.cjs: Evaluated as low risk
Comments suppressed due to low confidence (1)

examples/utils/import-testing/src/testExports.ts:49

  • [nitpick] The ESLint rule 'unused-imports/no-unused-imports' might be a typo or misconfiguration. Consider reviewing it.
// // eslint-disable-next-line unused-imports/no-unused-imports
@github-actions github-actions bot added area: examples Changes that focus on our examples dependencies Pull requests that update a dependency file labels Jan 3, 2025
Comment on lines 14 to 16
// Due to several of our own packages' exports failing to build with "exactOptionalPropertyTypes",
// disable it to prevent that from erroring when combined with "skipLibCheck".
"exactOptionalPropertyTypes": false,
Copy link
Contributor

@jason-ha jason-ha Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you give things a shot without this?
I found that there were only a couple things that were impacting presence package when I was standing it up and I was able to make [compatible] changes to those types that allowed exactOptionalPropertyTypes to be true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently you get two errors in `../../../packages/dds/tree/lib/simple-tree/core/unhydratedFlexTree.d.ts . I believe it was more when I originally wrote these tests (in another package). I suspect there are other errors as well that just aren't in code depended on by the minimal stuff currently in this package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix it: I consider these errors to be bugs found by this package. I have added a TODO to the comment to indicate this and fixed other places which had this comment.

Comment on lines +8 to +9
// Allows writing type checking expression without having to use the results.
"noUnusedLocals": false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not actually needed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing type tests without this is very annoying, and I don't think this enforcement is useful for this package. We do use this in the tests for this package, but allowing some type testing to be inline seems like a good thing for future users of this now that it has its own package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the type tests are in the test code, right? This is for the "production" example code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this package is not an example or production code. The package itself is for testing things. It has both "test" and "non test" code only since we sometimes need to test importing reexports of our APIs (there have been cases where only that fails, and its been annoying for our customers). THis package simply lives in examples since there isn't a better place I'm aware of to put something which is allowed to depend on fluid-framework and other public API surfaces like our examples do.

Also writing type asserts in production code is rather useful (which is why the tree package also opts out of this compiler setting and uses the linter instead so we can have more fine grained control) so I don't think opting out of it here is odd.

Comment on lines 10 to 13
// Allow testing that declarations work properly
"declaration": true,
// Check that the Fluid Framework packages pass type checking.
"skipLibCheck": false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these the common settings? ... and thus don't need to be explicit/exceptional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we default to skipLibCheck: true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is the case for the "test" tsconfig files, but "production" tsconfigs default to false for skipLibCheck.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. You are correct (I tested it). I kept this in the config, and added an explication about it.

@github-actions github-actions bot added area: dev experience Improving the experience of devs building on top of fluid area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct labels Jan 7, 2025
Copy link
Contributor

github-actions bot commented Jan 7, 2025

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> [email protected] serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  170492 links
    1603 destination URLs
    1838 URLs ignored
       0 warnings
       0 errors


@CraigMacomber CraigMacomber merged commit 92b4bfb into microsoft:main Jan 7, 2025
38 checks passed
@CraigMacomber CraigMacomber deleted the import-testing branch January 7, 2025 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dev experience Improving the experience of devs building on top of fluid area: examples Changes that focus on our examples area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants