@servicetitan/docs-anvil-uikit-contrib 37.0.0 → 37.0.2

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,7 +25,7 @@ Wrap your application with [`<IntlProvider>`](./API/intl-provider.mdx) or [`<Mob
25
25
 
26
26
  #### IntlProvider
27
27
 
28
- [`IntlProvider`](./API/intl-provider.mdx) is the most basic provider, and should be used if you do not use Mobx.
28
+ [`IntlProvider`](./API/intl-provider.mdx) is the most basic provider, and should be used if you do not use MobX.
29
29
 
30
30
  ```tsx
31
31
  import { IntlProvider } from '@servicetitan/intl';
@@ -44,7 +44,7 @@ return (
44
44
 
45
45
  #### MobxIntlProvider
46
46
 
47
- [`MobxIntlProvider`](./API/mobx-intl-provider.mdx) should be used if you are using Mobx, as it provides the [`IntlStore`](./API/intlstore.mdx) to access internationalization features in stores.
47
+ [`MobxIntlProvider`](./API/mobx-intl-provider.mdx) should be used if you are using MobX, as it provides the [`IntlStore`](./API/intlstore.mdx) to access internationalization features in stores.
48
48
 
49
49
  ```tsx
50
50
  import { MobxIntlProvider } from '@servicetitan/intl/mobx';
@@ -61,13 +61,17 @@ return (
61
61
  );
62
62
  ```
63
63
 
64
- :::note
65
- If you are doing work in the monolith, `MobxIntlProvider` has already been implemented for you, providing the `currency`, `locale`, and `timeZone` from available Business Units, Culture, Features, and Tenant stores. If you are instead implementing an MFE but would use the same monolith data, you should use the [`IntlProvider` from `@servicetitan/application-data/tanstack/intl`](/docs/frontend/application-data/intl-provider), which will likewise provide the `currency`, `locale`, and `timeZone` for you via monolith data stores.
66
- :::
64
+ ### Monolith
65
+
66
+ If you are doing work in the monolith, `MobxIntlProvider` has already been implemented for you, providing the `currency`, `locale`, and `timeZone` from available Business Units, Culture, Features, and Tenant stores.
67
+
68
+ If you are using `@servicetitan/intl` formatters within a Shared React Component that is used within a Knockout template (`window.sharedReactComponent`), the library's context will not be available. Wrap your component directly with a provider to ensure the context is available within the component's tree. We recommend you use [the monolith's `IntlProvider`](https://github.com/search?q=repo:servicetitan/app+%22export+const+IntlProvider%22+path:%22/packages/desktop/%22&type=code), as it already provides the `currency`, `locale`, and `timezone`.
69
+
70
+ If you are instead implementing an MFE but would use the same monolith data, you should use the [`IntlProvider` from `@servicetitan/application-data/tanstack/intl`](/docs/frontend/application-data/intl-provider), which will likewise provide the `currency`, `locale`, and `timeZone` for you via monolith data stores.
67
71
 
68
72
  ## Features
69
73
 
70
- `Format.js` and `react-intl` provide many components and utilities for handling internationalization, including caching and wrapping most of the [native `Intl` formatters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl). The following APIs are are particularly useful to us at this stage:
74
+ `Format.js` and `react-intl` provide many components and utilities for handling internationalization, including caching and wrapping most of the [native `Intl` formatters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl). The following APIs are particularly useful to us at this stage:
71
75
 
72
76
  - [Formatting currency](./currency.mdx)
73
77
  - [Formatting dates](./dates.mdx)
@@ -12,16 +12,18 @@ When it isn't practical to [mock the API service classes](/docs/frontend/testing
12
12
  ### Examples
13
13
 
14
14
  <Tabs
15
- defaultValue="jest"
16
- values={[
17
- { label: 'Jest (default)', value: 'jest' },
18
- { label: 'Vitest', value: 'vitest' },
19
- { label: 'Storybook', value: 'storybook' },
20
- ]}
15
+ defaultValue="jest"
16
+ values={[
17
+ { label: 'Jest (default)', value: 'jest' },
18
+ { label: 'Vitest', value: 'vitest' },
19
+ { label: 'Storybook', value: 'storybook' },
20
+ ]}
21
21
  >
22
22
  <TabItem value="jest">
23
23
 
24
24
  ```ts
25
+ import { MockApiCalls } from '@servicetitan/testing-library';
26
+
25
27
  describe('[admin] AppRoutes', () => {
26
28
  // Create helper to mock API calls
27
29
  const apiResponses = new MockApiCalls();
@@ -42,10 +44,10 @@ describe('[admin] AppRoutes', () => {
42
44
  </TabItem>
43
45
  <TabItem value="vitest">
44
46
 
45
- For Vitest tests, import from the `/vitest` entry point:
47
+ When using Vitest, import from the `/vitest` entry point:
46
48
 
47
49
  ```ts
48
- import { MockApiCalls } from '@servicetitan/testing-library/vitest';
50
+ import { MockApiCalls } from '@servicetitan/testing-library/vitest'; // Import from /vitest
49
51
  import { describe, it, expect, beforeEach } from 'vitest';
50
52
 
51
53
  describe('[admin] AppRoutes', () => {
@@ -72,7 +74,7 @@ describe('[admin] AppRoutes', () => {
72
74
  For use in Storybook stories or other contexts without Jest or Vitest, import from the `/mock-api-calls` entry point:
73
75
 
74
76
  ```ts
75
- import { MockApiCalls } from '@servicetitan/testing-library/mock-api-calls';
77
+ import { MockApiCalls } from '@servicetitan/testing-library/mock-api-calls'; // Import from /mock-api-calls
76
78
  import type { Meta, StoryObj } from '@storybook/react';
77
79
 
78
80
  const meta: Meta<typeof MyComponent> = {
@@ -2,17 +2,43 @@
2
2
  title: Queries
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  Testing Library includes custom [queries](https://testing-library.com/docs/queries/about) that find elements with ServiceTitan specific attributes.
6
9
 
7
10
  ## Usage
8
11
 
9
12
  To use custom queries, import them from Testing Library and merge them with the default set of queries attached to rendered components.
10
13
 
14
+ <Tabs defaultValue="jest"
15
+ values={[
16
+ { label: 'Jest (default)', value: 'jest' },
17
+ { label: 'Vitest', value: 'vitest'},
18
+ ]}>
19
+ <TabItem value="jest">
20
+
11
21
  ```ts
12
22
  import { queries, render } from '@testing-library/react'; // Import default queries
13
23
  import { queries as customQueries } from '@servicetitan/testing-library'; // Import custom queries
14
24
 
15
- // ...
25
+ const subject = () => {
26
+ return render(
27
+ <MyComponent />,
28
+ // Merge custom queries with defaults
29
+ { queries: { ...queries, ...customQueries } }
30
+ );
31
+ };
32
+ ```
33
+
34
+ </TabItem>
35
+ <TabItem value="vitest">
36
+
37
+ When using Vitest, import from the `/vitest` entry point:
38
+
39
+ ```ts
40
+ import { queries, render } from '@testing-library/react'; // Import default queries
41
+ import { queries as customQueries } from '@servicetitan/testing-library/vitest'; // Import from /vitest
16
42
 
17
43
  const subject = () => {
18
44
  return render(
@@ -23,6 +49,9 @@ const subject = () => {
23
49
  };
24
50
  ```
25
51
 
52
+ </TabItem>
53
+ </Tabs>
54
+
26
55
  ## ByAnvilComponentName
27
56
 
28
57
  > getByAnvilComponentName, queryByAnvilComponentName, getAllByAnvilComponentName, queryAllByAnvilComponentName, findByAnvilComponentName, findAllByAnvilComponentName
@@ -2,6 +2,38 @@
2
2
  title: Matchers
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
8
+ Testing library includes several [custom matchers](https://jestjs.io/docs/using-matchers).
9
+
10
+ ## Usage
11
+
12
+ To register matchers import the library into tests, or into the global setup:
13
+
14
+ <Tabs defaultValue="jest"
15
+ values={[
16
+ { label: 'Jest (default)', value: 'jest' },
17
+ { label: 'Vitest', value: 'vitest'},
18
+ ]}>
19
+ <TabItem value="jest">
20
+
21
+ ```ts
22
+ import '@servicetitan/testing-library';
23
+ ```
24
+
25
+ </TabItem>
26
+ <TabItem value="vitest">
27
+
28
+ When using Vitest, import from the `/vitest` entry point:
29
+
30
+ ```ts
31
+ import '@servicetitan/testing-library/vitest';
32
+ ```
33
+
34
+ </TabItem>
35
+ </Tabs>
36
+
5
37
  ## toBeWithinRange
6
38
 
7
39
  Checks whether a value equals another value, plus or minus the specified delta.
@@ -18,3 +18,11 @@ This library has `peerDependencies` for:
18
18
  - `@testing-library/react`: >=12.0.0
19
19
  - `@testing-library/react-hooks`: >=7.0.0 (only if using `@testing-library/react` v12)
20
20
  - `react`: >=17.0.0
21
+
22
+ ## Using with Vitest
23
+
24
+ When using Vitest, import from the `/vitest` entry point:
25
+
26
+ ```ts
27
+ import '@servicetitan/testing-library/vitest';
28
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/docs-anvil-uikit-contrib",
3
- "version": "37.0.0",
3
+ "version": "37.0.2",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,5 +16,5 @@
16
16
  "cli": {
17
17
  "webpack": false
18
18
  },
19
- "gitHead": "307168f771cf472154019492936165c9a31ed1e9"
19
+ "gitHead": "e5cc4337a19b32de0595e1f23d13029c40b350c2"
20
20
  }