@truedat/bg 8.3.2 → 8.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/bg",
3
- "version": "8.3.2",
3
+ "version": "8.3.3",
4
4
  "description": "Truedat Web Business Glossary",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -48,7 +48,7 @@
48
48
  "@testing-library/jest-dom": "^6.6.3",
49
49
  "@testing-library/react": "^16.3.0",
50
50
  "@testing-library/user-event": "^14.6.1",
51
- "@truedat/test": "8.3.2",
51
+ "@truedat/test": "8.3.3",
52
52
  "identity-obj-proxy": "^3.0.0",
53
53
  "jest": "^29.7.0",
54
54
  "redux-saga-test-plan": "^4.0.6"
@@ -81,5 +81,5 @@
81
81
  "semantic-ui-react": "^3.0.0-beta.2",
82
82
  "swr": "^2.3.3"
83
83
  },
84
- "gitHead": "ed0c289882710d6df3483692fab5833747130cbf"
84
+ "gitHead": "4659d78d53d18027bcfb8f8cdb221378e78d7ef6"
85
85
  }
@@ -22,6 +22,7 @@ export const ConceptSubscription = ({
22
22
  deleteSubscription,
23
23
  }) => {
24
24
  const [subscriptionField, setSubscription] = useState(searchSubscription);
25
+ const [isOpen, setIsOpen] = useState(false);
25
26
 
26
27
  useEffect(() => {
27
28
  setSubscription(searchSubscription);
@@ -57,6 +58,7 @@ export const ConceptSubscription = ({
57
58
  _.prop("id")(subscriptionField)
58
59
  ? updateSubscription(payload)
59
60
  : createSubscription(payload);
61
+ setIsOpen(false);
60
62
  };
61
63
 
62
64
  const handleDelete = () => {
@@ -66,7 +68,10 @@ export const ConceptSubscription = ({
66
68
  resource_type: "concept",
67
69
  concept,
68
70
  };
69
- _.prop("id")(subscriptionField) && deleteSubscription(payload);
71
+ if (_.prop("id")(subscriptionField)) {
72
+ deleteSubscription(payload);
73
+ setIsOpen(false);
74
+ }
70
75
  };
71
76
 
72
77
  const handleChange = (e, { name, value }) => {
@@ -82,6 +87,9 @@ export const ConceptSubscription = ({
82
87
  basic
83
88
  flowing
84
89
  position="bottom right"
90
+ open={isOpen}
91
+ onOpen={() => setIsOpen(true)}
92
+ onClose={() => setIsOpen(false)}
85
93
  trigger={
86
94
  <Button
87
95
  basic
@@ -1,3 +1,5 @@
1
+ import userEvent from "@testing-library/user-event";
2
+ import { waitFor } from "@testing-library/react";
1
3
  import { render, waitForLoad } from "@truedat/test/render";
2
4
  import { ConceptSubscription } from "../ConceptSubscription";
3
5
 
@@ -19,10 +21,17 @@ describe("<ConceptSubscription />", () => {
19
21
  };
20
22
  const subscriptionUpdating = false;
21
23
 
24
+ const createSubscription = jest.fn();
25
+ const updateSubscription = jest.fn();
26
+ const deleteSubscription = jest.fn();
27
+
22
28
  const props = {
23
29
  concept,
24
30
  searchSubscription,
25
31
  subscriptionUpdating,
32
+ createSubscription,
33
+ updateSubscription,
34
+ deleteSubscription,
26
35
  };
27
36
 
28
37
  it("matches the latest snapshot", async () => {
@@ -30,4 +39,23 @@ describe("<ConceptSubscription />", () => {
30
39
  await waitForLoad(rendered);
31
40
  expect(rendered.container).toMatchSnapshot();
32
41
  });
42
+
43
+ it("closes the popup after saving the subscription", async () => {
44
+ const rendered = render(<ConceptSubscription {...props} />);
45
+ await waitForLoad(rendered);
46
+
47
+ const user = userEvent.setup({ delay: null });
48
+
49
+ // abre el popup haciendo click en el botón de suscripción
50
+ await user.click(rendered.getByRole("button"));
51
+
52
+ // click en guardar
53
+ const saveButton = await rendered.findByText(/actions.save/i);
54
+ await user.click(saveButton);
55
+
56
+ // el popup se cierra (contenido ya no está en el DOM)
57
+ await waitFor(() =>
58
+ expect(rendered.queryByText(/actions.save/i)).not.toBeInTheDocument()
59
+ );
60
+ });
33
61
  });