@khanacademy/wonder-blocks-button 6.2.10 → 6.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @khanacademy/wonder-blocks-button
2
2
 
3
+ ## 6.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 58075352: Change testId to render the default Testing Library HTML attribute: data-testid (was data-test-id)
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [58075352]
12
+ - @khanacademy/wonder-blocks-progress-spinner@2.1.0
13
+ - @khanacademy/wonder-blocks-clickable@4.2.0
14
+ - @khanacademy/wonder-blocks-core@6.4.0
15
+ - @khanacademy/wonder-blocks-icon@4.1.0
16
+ - @khanacademy/wonder-blocks-typography@2.1.11
17
+
18
+ ## 6.2.11
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [874081aa]
23
+ - Updated dependencies [874081aa]
24
+ - Updated dependencies [a9bf603a]
25
+ - @khanacademy/wonder-blocks-theming@2.0.2
26
+ - @khanacademy/wonder-blocks-tokens@1.2.0
27
+ - @khanacademy/wonder-blocks-clickable@4.1.3
28
+ - @khanacademy/wonder-blocks-progress-spinner@2.0.29
29
+
3
30
  ## 6.2.10
4
31
 
5
32
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -273,7 +273,7 @@ const ButtonCore = React.forwardRef(function ButtonCore(props, ref) {
273
273
  const disabled = spinner || disabledProp;
274
274
  const defaultStyle = [sharedStyles.shared, disabled && sharedStyles.disabled, startIcon && sharedStyles.withStartIcon, endIcon && sharedStyles.withEndIcon, buttonStyles.default, disabled && buttonStyles.disabled, kind !== "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus), kind === "tertiary" && !pressed && focused && [buttonStyles.focus, disabled && buttonStyles.disabledFocus], size === "small" && sharedStyles.small, size === "large" && sharedStyles.large];
275
275
  const commonProps = _extends({
276
- "data-test-id": testId,
276
+ "data-testid": testId,
277
277
  id: id,
278
278
  role: "button",
279
279
  style: [defaultStyle, style]
package/dist/index.js CHANGED
@@ -296,7 +296,7 @@ const ButtonCore = React__namespace.forwardRef(function ButtonCore(props, ref) {
296
296
  const disabled = spinner || disabledProp;
297
297
  const defaultStyle = [sharedStyles.shared, disabled && sharedStyles.disabled, startIcon && sharedStyles.withStartIcon, endIcon && sharedStyles.withEndIcon, buttonStyles.default, disabled && buttonStyles.disabled, kind !== "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus), kind === "tertiary" && !pressed && focused && [buttonStyles.focus, disabled && buttonStyles.disabledFocus], size === "small" && sharedStyles.small, size === "large" && sharedStyles.large];
298
298
  const commonProps = _extends({
299
- "data-test-id": testId,
299
+ "data-testid": testId,
300
300
  id: id,
301
301
  role: "button",
302
302
  style: [defaultStyle, style]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-button",
3
- "version": "6.2.10",
3
+ "version": "6.3.0",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,13 +16,13 @@
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-clickable": "^4.1.2",
20
- "@khanacademy/wonder-blocks-core": "^6.3.1",
21
- "@khanacademy/wonder-blocks-icon": "^4.0.1",
22
- "@khanacademy/wonder-blocks-progress-spinner": "^2.0.28",
23
- "@khanacademy/wonder-blocks-theming": "^2.0.1",
24
- "@khanacademy/wonder-blocks-tokens": "^1.1.0",
25
- "@khanacademy/wonder-blocks-typography": "^2.1.10"
19
+ "@khanacademy/wonder-blocks-clickable": "^4.2.0",
20
+ "@khanacademy/wonder-blocks-core": "^6.4.0",
21
+ "@khanacademy/wonder-blocks-icon": "^4.1.0",
22
+ "@khanacademy/wonder-blocks-progress-spinner": "^2.1.0",
23
+ "@khanacademy/wonder-blocks-theming": "^2.0.2",
24
+ "@khanacademy/wonder-blocks-tokens": "^1.2.0",
25
+ "@khanacademy/wonder-blocks-typography": "^2.1.11"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "aphrodite": "^1.2.5",
@@ -3952,7 +3952,7 @@ exports[`ButtonCore kind:primary size:medium spinner:true 1`] = `
3952
3952
  }
3953
3953
  >
3954
3954
  <svg
3955
- data-test-id="button-spinner"
3955
+ data-testid="button-spinner"
3956
3956
  height={24}
3957
3957
  viewBox="0 0 24 24"
3958
3958
  width={24}
@@ -4082,7 +4082,7 @@ exports[`ButtonCore kind:primary size:small spinner:true 1`] = `
4082
4082
  }
4083
4083
  >
4084
4084
  <svg
4085
- data-test-id="button-spinner"
4085
+ data-testid="button-spinner"
4086
4086
  height={16}
4087
4087
  viewBox="0 0 16 16"
4088
4088
  width={16}
@@ -8093,7 +8093,7 @@ exports[`ButtonCore kind:secondary size:medium spinner:true 1`] = `
8093
8093
  }
8094
8094
  >
8095
8095
  <svg
8096
- data-test-id="button-spinner"
8096
+ data-testid="button-spinner"
8097
8097
  height={24}
8098
8098
  viewBox="0 0 24 24"
8099
8099
  width={24}
@@ -8228,7 +8228,7 @@ exports[`ButtonCore kind:secondary size:small spinner:true 1`] = `
8228
8228
  }
8229
8229
  >
8230
8230
  <svg
8231
- data-test-id="button-spinner"
8231
+ data-testid="button-spinner"
8232
8232
  height={16}
8233
8233
  viewBox="0 0 16 16"
8234
8234
  width={16}
@@ -12223,7 +12223,7 @@ exports[`ButtonCore kind:tertiary size:medium spinner:true 1`] = `
12223
12223
  }
12224
12224
  >
12225
12225
  <svg
12226
- data-test-id="button-spinner"
12226
+ data-testid="button-spinner"
12227
12227
  height={24}
12228
12228
  viewBox="0 0 24 24"
12229
12229
  width={24}
@@ -12354,7 +12354,7 @@ exports[`ButtonCore kind:tertiary size:small spinner:true 1`] = `
12354
12354
  }
12355
12355
  >
12356
12356
  <svg
12357
- data-test-id="button-spinner"
12357
+ data-testid="button-spinner"
12358
12358
  height={16}
12359
12359
  viewBox="0 0 16 16"
12360
12360
  width={16}
@@ -5,7 +5,7 @@
5
5
 
6
6
  import * as React from "react";
7
7
  import {render, screen} from "@testing-library/react";
8
- import userEvent from "@testing-library/user-event";
8
+ import {userEvent} from "@testing-library/user-event";
9
9
  import plus from "@phosphor-icons/core/regular/plus.svg";
10
10
 
11
11
  import {ThemeSwitcherContext} from "@khanacademy/wonder-blocks-theming";
@@ -14,7 +14,7 @@ import {color} from "@khanacademy/wonder-blocks-tokens";
14
14
  import Button from "../button";
15
15
 
16
16
  describe("button with icon", () => {
17
- test("start icon should be hidden from Screen Readers", () => {
17
+ test("start icon should be hidden from Screen Readers", async () => {
18
18
  // Arrange
19
19
  render(
20
20
  <Button testId={"button-focus-test"} startIcon={plus}>
@@ -23,13 +23,13 @@ describe("button with icon", () => {
23
23
  );
24
24
 
25
25
  // Act
26
- const icon = screen.getByTestId("button-focus-test-start-icon");
26
+ const icon = await screen.findByTestId("button-focus-test-start-icon");
27
27
 
28
28
  // Assert
29
29
  expect(icon).toHaveAttribute("aria-hidden", "true");
30
30
  });
31
31
 
32
- test("end icon should be hidden from Screen Readers", () => {
32
+ test("end icon should be hidden from Screen Readers", async () => {
33
33
  // Arrange
34
34
  render(
35
35
  <Button testId={"button-focus-test"} endIcon={plus}>
@@ -38,7 +38,7 @@ describe("button with icon", () => {
38
38
  );
39
39
 
40
40
  // Act
41
- const icon = screen.getByTestId("button-focus-test-end-icon");
41
+ const icon = await screen.findByTestId("button-focus-test-end-icon");
42
42
 
43
43
  // Assert
44
44
  expect(icon).toHaveAttribute("aria-hidden", "true");
@@ -48,7 +48,7 @@ describe("button with icon", () => {
48
48
  * Primary button
49
49
  */
50
50
 
51
- test("icon is displayed when button contains startIcon", () => {
51
+ test("icon is displayed when button contains startIcon", async () => {
52
52
  // Arrange
53
53
  render(
54
54
  <Button testId={"button-focus-test"} startIcon={plus}>
@@ -57,14 +57,14 @@ describe("button with icon", () => {
57
57
  );
58
58
 
59
59
  // Act
60
- const icon = screen.getByTestId("button-focus-test-start-icon");
60
+ const icon = await screen.findByTestId("button-focus-test-start-icon");
61
61
 
62
62
  // Assert
63
63
  expect(icon).toBeInTheDocument();
64
64
  expect(icon).toHaveAttribute("aria-hidden", "true");
65
65
  });
66
66
 
67
- test("icon is displayed when button contains endIcon", () => {
67
+ test("icon is displayed when button contains endIcon", async () => {
68
68
  // Arrange
69
69
  render(
70
70
  <Button testId={"button-focus-test"} endIcon={plus}>
@@ -73,14 +73,14 @@ describe("button with icon", () => {
73
73
  );
74
74
 
75
75
  // Act
76
- const icon = screen.getByTestId("button-focus-test-end-icon");
76
+ const icon = await screen.findByTestId("button-focus-test-end-icon");
77
77
 
78
78
  // Assert
79
79
  expect(icon).toBeInTheDocument();
80
80
  expect(icon).toHaveAttribute("aria-hidden", "true");
81
81
  });
82
82
 
83
- test("both icons are displayed when button contains startIcon and endIcon", () => {
83
+ test("both icons are displayed when button contains startIcon and endIcon", async () => {
84
84
  // Arrange
85
85
  render(
86
86
  <Button
@@ -93,8 +93,10 @@ describe("button with icon", () => {
93
93
  );
94
94
 
95
95
  // Act
96
- const startIcon = screen.getByTestId("button-focus-test-start-icon");
97
- const endIcon = screen.getByTestId("button-focus-test-end-icon");
96
+ const startIcon = await screen.findByTestId(
97
+ "button-focus-test-start-icon",
98
+ );
99
+ const endIcon = await screen.findByTestId("button-focus-test-end-icon");
98
100
 
99
101
  // Assert
100
102
  expect(startIcon).toBeInTheDocument();
@@ -105,7 +107,7 @@ describe("button with icon", () => {
105
107
  * Secondary button
106
108
  */
107
109
 
108
- test("icon is displayed when secondary button contains startIcon", () => {
110
+ test("icon is displayed when secondary button contains startIcon", async () => {
109
111
  // Arrange
110
112
  render(
111
113
  <Button
@@ -118,14 +120,14 @@ describe("button with icon", () => {
118
120
  );
119
121
 
120
122
  // Act
121
- const icon = screen.getByTestId("button-icon-test-start-icon");
123
+ const icon = await screen.findByTestId("button-icon-test-start-icon");
122
124
 
123
125
  // Assert
124
126
  expect(icon).toBeInTheDocument();
125
127
  expect(icon).toHaveAttribute("aria-hidden", "true");
126
128
  });
127
129
 
128
- test("icon is displayed when secondary button contains endIcon", () => {
130
+ test("icon is displayed when secondary button contains endIcon", async () => {
129
131
  // Arrange
130
132
  render(
131
133
  <Button kind="secondary" testId={"button-icon-test"} endIcon={plus}>
@@ -134,14 +136,14 @@ describe("button with icon", () => {
134
136
  );
135
137
 
136
138
  // Act
137
- const icon = screen.getByTestId("button-icon-test-end-icon");
139
+ const icon = await screen.findByTestId("button-icon-test-end-icon");
138
140
 
139
141
  // Assert
140
142
  expect(icon).toBeInTheDocument();
141
143
  expect(icon).toHaveAttribute("aria-hidden", "true");
142
144
  });
143
145
 
144
- test("default theme secondary button icon has no hover style", () => {
146
+ test("default theme secondary button icon has no hover style", async () => {
145
147
  // Arrange
146
148
  render(
147
149
  <Button kind="secondary" testId={"button-icon-test"} endIcon={plus}>
@@ -150,17 +152,17 @@ describe("button with icon", () => {
150
152
  );
151
153
 
152
154
  // Act
153
- const button = screen.getByTestId("button-icon-test");
154
- const iconWrapper = screen.getByTestId(
155
+ const button = await screen.findByTestId("button-icon-test");
156
+ const iconWrapper = await screen.findByTestId(
155
157
  "button-icon-test-end-icon-wrapper",
156
158
  );
157
- userEvent.hover(button);
159
+ await userEvent.hover(button);
158
160
 
159
161
  // Assert
160
162
  expect(iconWrapper).toHaveStyle(`backgroundColor: transparent`);
161
163
  });
162
164
 
163
- test("Khanmigo secondary button icon has hover style", () => {
165
+ test("Khanmigo secondary button icon has hover style", async () => {
164
166
  // Arrange
165
167
  render(
166
168
  <ThemeSwitcherContext.Provider value="khanmigo">
@@ -175,11 +177,11 @@ describe("button with icon", () => {
175
177
  );
176
178
 
177
179
  // Act
178
- const button = screen.getByTestId("button-icon-test");
179
- const iconWrapper = screen.getByTestId(
180
+ const button = await screen.findByTestId("button-icon-test");
181
+ const iconWrapper = await screen.findByTestId(
180
182
  "button-icon-test-end-icon-wrapper",
181
183
  );
182
- userEvent.hover(button);
184
+ await userEvent.hover(button);
183
185
 
184
186
  // Assert
185
187
  expect(iconWrapper).toHaveStyle(
@@ -191,7 +193,7 @@ describe("button with icon", () => {
191
193
  * Tertiary button
192
194
  */
193
195
 
194
- test("icon is displayed when tertiary button contains startIcon", () => {
196
+ test("icon is displayed when tertiary button contains startIcon", async () => {
195
197
  // Arrange
196
198
  render(
197
199
  <Button
@@ -204,14 +206,14 @@ describe("button with icon", () => {
204
206
  );
205
207
 
206
208
  // Act
207
- const icon = screen.getByTestId("button-focus-test-start-icon");
209
+ const icon = await screen.findByTestId("button-focus-test-start-icon");
208
210
 
209
211
  // Assert
210
212
  expect(icon).toBeInTheDocument();
211
213
  expect(icon).toHaveAttribute("aria-hidden", "true");
212
214
  });
213
215
 
214
- test("icon is displayed when tertiary button contains endIcon", () => {
216
+ test("icon is displayed when tertiary button contains endIcon", async () => {
215
217
  // Arrange
216
218
  render(
217
219
  <Button kind="tertiary" testId={"button-focus-test"} endIcon={plus}>
@@ -220,14 +222,14 @@ describe("button with icon", () => {
220
222
  );
221
223
 
222
224
  // Act
223
- const icon = screen.getByTestId("button-focus-test-end-icon");
225
+ const icon = await screen.findByTestId("button-focus-test-end-icon");
224
226
 
225
227
  // Assert
226
228
  expect(icon).toBeInTheDocument();
227
229
  expect(icon).toHaveAttribute("aria-hidden", "true");
228
230
  });
229
231
 
230
- test("default theme tertiary button icon has no hover style", () => {
232
+ test("default theme tertiary button icon has no hover style", async () => {
231
233
  // Arrange
232
234
  render(
233
235
  <Button kind="tertiary" testId={"button-icon-test"} endIcon={plus}>
@@ -236,17 +238,17 @@ describe("button with icon", () => {
236
238
  );
237
239
 
238
240
  // Act
239
- const button = screen.getByTestId("button-icon-test");
240
- const iconWrapper = screen.getByTestId(
241
+ const button = await screen.findByTestId("button-icon-test");
242
+ const iconWrapper = await screen.findByTestId(
241
243
  "button-icon-test-end-icon-wrapper",
242
244
  );
243
- userEvent.hover(button);
245
+ await userEvent.hover(button);
244
246
 
245
247
  // Assert
246
248
  expect(iconWrapper).toHaveStyle(`backgroundColor: transparent`);
247
249
  });
248
250
 
249
- test("Khanmigo tertiary button icon has hover style", () => {
251
+ test("Khanmigo tertiary button icon has hover style", async () => {
250
252
  // Arrange
251
253
  render(
252
254
  <ThemeSwitcherContext.Provider value="khanmigo">
@@ -261,11 +263,11 @@ describe("button with icon", () => {
261
263
  );
262
264
 
263
265
  // Act
264
- const button = screen.getByTestId("button-icon-test");
265
- const iconWrapper = screen.getByTestId(
266
+ const button = await screen.findByTestId("button-icon-test");
267
+ const iconWrapper = await screen.findByTestId(
266
268
  "button-icon-test-end-icon-wrapper",
267
269
  );
268
- userEvent.hover(button);
270
+ await userEvent.hover(button);
269
271
 
270
272
  // Assert
271
273
  expect(iconWrapper).toHaveStyle(