@sproutsocial/seeds-react-drawer 1.0.1 → 1.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.
@@ -1,21 +1,21 @@
1
1
  yarn run v1.22.22
2
2
  $ tsup --dts
3
- CLI Building entry: src/index.ts
4
- CLI Using tsconfig: tsconfig.json
5
- CLI tsup v8.0.2
6
- CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-drawer/tsup.config.ts
7
- CLI Target: es2022
8
- CLI Cleaning output folder
9
- CJS Build start
10
- ESM Build start
11
- CJS dist/index.js 9.40 KB
12
- CJS dist/index.js.map 15.31 KB
13
- CJS ⚡️ Build success in 212ms
14
- ESM dist/esm/index.js 6.90 KB
15
- ESM dist/esm/index.js.map 15.15 KB
16
- ESM ⚡️ Build success in 222ms
17
- DTS Build start
18
- DTS ⚡️ Build success in 38852ms
19
- DTS dist/index.d.ts 3.35 KB
20
- DTS dist/index.d.mts 3.35 KB
21
- Done in 49.21s.
3
+ CLI Building entry: src/index.ts
4
+ CLI Using tsconfig: tsconfig.json
5
+ CLI tsup v8.5.0
6
+ CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-drawer/tsup.config.ts
7
+ CLI Target: es2022
8
+ CLI Cleaning output folder
9
+ CJS Build start
10
+ ESM Build start
11
+ CJS dist/index.js 9.40 KB
12
+ CJS dist/index.js.map 15.31 KB
13
+ CJS ⚡️ Build success in 229ms
14
+ ESM dist/esm/index.js 6.90 KB
15
+ ESM dist/esm/index.js.map 15.15 KB
16
+ ESM ⚡️ Build success in 212ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 45262ms
19
+ DTS dist/index.d.ts 3.35 KB
20
+ DTS dist/index.d.mts 3.35 KB
21
+ Done in 54.99s.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @sproutsocial/seeds-react-drawer
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [22e1111]
8
+ - @sproutsocial/seeds-react-button@1.2.2
9
+ - @sproutsocial/seeds-react-portal@1.1.4
10
+ - @sproutsocial/seeds-react-text@1.3.2
11
+ - @sproutsocial/seeds-react-theme@3.0.1
12
+ - @sproutsocial/seeds-react-box@1.1.3
13
+ - @sproutsocial/seeds-react-icon@1.1.3
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-drawer",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Seeds React Drawer",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -18,13 +18,13 @@
18
18
  "test:watch": "jest --watch --coverage=false"
19
19
  },
20
20
  "dependencies": {
21
- "@sproutsocial/seeds-react-theme": "^2.2.0",
21
+ "@sproutsocial/seeds-react-theme": "^3.0.1",
22
22
  "@sproutsocial/seeds-react-system-props": "^3.0.1",
23
- "@sproutsocial/seeds-react-box": "^1.1.1",
24
- "@sproutsocial/seeds-react-button": "^1.2.0",
25
- "@sproutsocial/seeds-react-icon": "^1.1.1",
26
- "@sproutsocial/seeds-react-text": "^1.3.0",
27
- "@sproutsocial/seeds-react-portal": "^1.1.0",
23
+ "@sproutsocial/seeds-react-box": "^1.1.3",
24
+ "@sproutsocial/seeds-react-button": "^1.2.2",
25
+ "@sproutsocial/seeds-react-icon": "^1.1.3",
26
+ "@sproutsocial/seeds-react-text": "^1.3.2",
27
+ "@sproutsocial/seeds-react-portal": "^1.1.4",
28
28
  "@sproutsocial/seeds-motion": "^1.8.0",
29
29
  "@react-spring/web": "^9.0.0",
30
30
  "react-focus-lock": "^2.0.3"
@@ -35,7 +35,7 @@
35
35
  "@sproutsocial/eslint-config-seeds": "*",
36
36
  "react": "^18.0.0",
37
37
  "styled-components": "^5.2.3",
38
- "tsup": "^8.0.2",
38
+ "tsup": "^8.3.4",
39
39
  "typescript": "^5.6.2",
40
40
  "@sproutsocial/seeds-tsconfig": "*",
41
41
  "@sproutsocial/seeds-testing": "*",
@@ -3,8 +3,9 @@
3
3
  import React, { useState } from "react";
4
4
  import {
5
5
  render as testRender,
6
- fireEvent,
7
6
  waitFor,
7
+ screen,
8
+ act,
8
9
  } from "@sproutsocial/seeds-react-testing-library";
9
10
  import type { TypeDrawerProps } from "../DrawerTypes";
10
11
  import Drawer from "../Drawer";
@@ -18,7 +19,9 @@ const StatefulDrawer = ({
18
19
  const [isDrawerOpen, setIsDrawerOpen] = useState(isOpen || false);
19
20
 
20
21
  const onDrawerClose = () => {
21
- setIsDrawerOpen(false);
22
+ act(() => {
23
+ setIsDrawerOpen(false);
24
+ });
22
25
  onClose();
23
26
  };
24
27
 
@@ -55,53 +58,59 @@ const render = ({
55
58
  }: Partial<TypeDrawerProps>) => {
56
59
  const { baseElement } = testRender(<div id="main-content" />);
57
60
  const mainContentRef = baseElement.querySelector("#main-content");
58
- return testRender(
59
- <div>
60
- {baseElement.innerHTML}
61
- <StatefulDrawer
62
- isOpen={isOpen}
63
- direction={direction}
64
- offset={offset}
65
- onClose={onClose}
66
- closeButtonLabel={closeButtonLabel}
67
- id={id}
68
- disableCloseOnClickOutside={disableCloseOnClickOutside}
69
- // @ts-ignore - We'll come back to test updating this
70
- closeTargets={[mainContentRef]}
71
- width={width}
72
- >
73
- {children}
74
- </StatefulDrawer>
75
- </div>
76
- );
61
+ return {
62
+ ...testRender(
63
+ <div>
64
+ {baseElement.innerHTML}
65
+ <StatefulDrawer
66
+ isOpen={isOpen}
67
+ direction={direction}
68
+ offset={offset}
69
+ onClose={onClose}
70
+ closeButtonLabel={closeButtonLabel}
71
+ id={id}
72
+ disableCloseOnClickOutside={disableCloseOnClickOutside}
73
+ // @ts-ignore - We'll come back to test updating this
74
+ closeTargets={[mainContentRef]}
75
+ width={width}
76
+ >
77
+ {children}
78
+ </StatefulDrawer>
79
+ </div>
80
+ ),
81
+ };
77
82
  };
78
83
 
79
84
  describe("Drawer", () => {
80
85
  it("should not be in the document by default", () => {
81
- const { queryByText } = render({});
82
- expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
86
+ render({});
87
+ expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
83
88
  });
84
89
 
85
90
  it("should render drawer", () => {
86
- const { getByText } = render({
91
+ render({
87
92
  isOpen: true,
88
93
  });
89
- expect(getByText(/drawer content/i)).toBeInTheDocument();
94
+ expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
90
95
  });
91
96
 
92
- xit("should close drawer on header click", async () => {
93
- const { queryByText, getByText, getByLabelText } = render({
97
+ it("should close drawer on header click", async () => {
98
+ const { user } = render({
94
99
  isOpen: true,
95
100
  });
96
- expect(getByText(/drawer content/i)).toBeInTheDocument();
97
- fireEvent.click(getByLabelText("close button"));
101
+
102
+ expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
103
+ await act(async () => {
104
+ await user.click(screen.getByLabelText("close button"));
105
+ });
106
+
98
107
  await waitFor(() => {
99
- expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
108
+ expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
100
109
  });
101
110
  });
102
111
 
103
- xit("should close drawer on header click when using custom header", async () => {
104
- const { queryByText, getByText, getByLabelText } = render({
112
+ it("should close drawer on header click when using custom header", async () => {
113
+ const { user } = render({
105
114
  isOpen: true,
106
115
  children: (
107
116
  <React.Fragment>
@@ -115,74 +124,86 @@ describe("Drawer", () => {
115
124
  </React.Fragment>
116
125
  ),
117
126
  });
118
- expect(getByText(/drawer content/i)).toBeInTheDocument();
119
- fireEvent.click(getByLabelText("close button"));
127
+ expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
128
+ await act(async () => {
129
+ await user.click(screen.getByLabelText("close button"));
130
+ });
120
131
  await waitFor(() => {
121
- expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
132
+ expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
122
133
  });
123
134
  });
124
135
 
125
- xit("should close drawer on outside click", async () => {
126
- const { baseElement, queryByText, getByText } = render({
136
+ it("should close drawer on outside click", async () => {
137
+ const { user, baseElement } = render({
127
138
  isOpen: true,
128
139
  });
129
- expect(getByText(/drawer content/i)).toBeInTheDocument();
130
- fireEvent.click(baseElement.querySelector("#main-content") as Element);
140
+ expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
141
+ await act(async () => {
142
+ await user.click(baseElement.querySelector("#main-content") as Element);
143
+ });
131
144
  await waitFor(() => {
132
- expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
145
+ expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
133
146
  });
134
147
  });
135
148
 
136
149
  it("should not close drawer on outside click when disabled", async () => {
137
- const { baseElement, queryByText, getByText } = render({
150
+ const { user, baseElement } = render({
138
151
  isOpen: true,
139
152
  disableCloseOnClickOutside: true,
140
153
  });
141
- expect(getByText(/drawer content/i)).toBeInTheDocument();
142
- fireEvent.click(baseElement.querySelector("#main-content") as Element);
154
+ expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
155
+ await user.click(baseElement.querySelector("#main-content") as Element);
143
156
  await waitFor(() => {
144
157
  // eslint-disable-next-line testing-library/prefer-presence-queries
145
- expect(queryByText(/drawer content/i)).toBeInTheDocument();
158
+ expect(screen.queryByText(/drawer content/i)).toBeInTheDocument();
146
159
  });
147
160
  });
148
161
 
149
162
  it("should close drawer on esc key", async () => {
150
- const { baseElement, queryByText, getByText } = render({
163
+ const { user, baseElement } = render({
151
164
  isOpen: true,
152
165
  disableCloseOnClickOutside: true,
153
166
  });
154
- expect(getByText(/drawer content/i)).toBeInTheDocument();
155
- fireEvent.keyDown(baseElement, {
156
- key: "Escape",
167
+ expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
168
+ await act(async () => {
169
+ await user.keyboard("{Escape}");
157
170
  });
158
171
  await waitFor(() => {
159
- expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
172
+ expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
160
173
  });
161
174
  });
175
+
162
176
  it("should have dialog role", () => {
163
- const { getByRole } = render({
177
+ render({
164
178
  isOpen: true,
165
179
  });
166
- expect(getByRole("dialog")).toBeInTheDocument();
180
+ expect(screen.getByRole("dialog")).toBeInTheDocument();
167
181
  });
182
+
168
183
  it("should have focus on drawer when opened", () => {
169
- const { getByLabelText } = render({
184
+ render({
170
185
  isOpen: true,
171
186
  });
172
- expect(getByLabelText("close button")).toHaveFocus();
187
+ expect(screen.getByLabelText("close button")).toHaveFocus();
173
188
  });
189
+
174
190
  it("should have an h2 with id", () => {
175
- const { getByRole } = render({
191
+ render({
176
192
  isOpen: true,
177
193
  });
178
- expect(getByRole("heading")).toHaveAttribute("id", "drawer-1-header");
194
+ expect(screen.getByRole("heading")).toHaveAttribute(
195
+ "id",
196
+ "drawer-1-header"
197
+ );
179
198
  });
199
+
180
200
  it("should be 600px wide by default", () => {
181
- const { getByRole } = render({ isOpen: true });
182
- expect(getByRole("dialog")).toHaveStyle("width: 600px");
201
+ render({ isOpen: true });
202
+ expect(screen.getByRole("dialog")).toHaveStyle("width: 600px");
183
203
  });
204
+
184
205
  it("should customize the drawer width when provided", () => {
185
- const { getByRole } = render({ isOpen: true, width: 400 });
186
- expect(getByRole("dialog")).toHaveStyle("width: 400px");
206
+ render({ isOpen: true, width: 400 });
207
+ expect(screen.getByRole("dialog")).toHaveStyle("width: 400px");
187
208
  });
188
209
  });
package/tsconfig.json CHANGED
@@ -5,5 +5,11 @@
5
5
  "module": "esnext"
6
6
  },
7
7
  "include": ["src/**/*"],
8
- "exclude": ["node_modules", "dist", "coverage"]
8
+ "exclude": [
9
+ "node_modules",
10
+ "dist",
11
+ "coverage",
12
+ "**/*.stories.tsx",
13
+ "**/*.stories.ts"
14
+ ]
9
15
  }