@truedat/dq 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/dq",
3
- "version": "8.3.2",
3
+ "version": "8.3.3",
4
4
  "description": "Truedat Web Data Quality Module",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -53,7 +53,7 @@
53
53
  "@testing-library/jest-dom": "^6.6.3",
54
54
  "@testing-library/react": "^16.3.0",
55
55
  "@testing-library/user-event": "^14.6.1",
56
- "@truedat/test": "8.3.2",
56
+ "@truedat/test": "8.3.3",
57
57
  "identity-obj-proxy": "^3.0.0",
58
58
  "jest": "^29.7.0",
59
59
  "redux-saga-test-plan": "^4.0.6"
@@ -86,5 +86,5 @@
86
86
  "semantic-ui-react": "^3.0.0-beta.2",
87
87
  "swr": "^2.3.3"
88
88
  },
89
- "gitHead": "ed0c289882710d6df3483692fab5833747130cbf"
89
+ "gitHead": "4659d78d53d18027bcfb8f8cdb221378e78d7ef6"
90
90
  }
@@ -105,6 +105,7 @@ export const Subscription = ({
105
105
  }) => {
106
106
  const [subscriptionField, setSubscription] = useState(searchSubscription);
107
107
  const [resourceTypeId, setResourceTypeId] = useState();
108
+ const [isOpen, setIsOpen] = useState(false);
108
109
 
109
110
  useEffect(() => {
110
111
  setSubscription(searchSubscription);
@@ -143,6 +144,7 @@ export const Subscription = ({
143
144
  _.prop("id")(subscriptionField)
144
145
  ? updateSubscription(payload)
145
146
  : createSubscription(payload);
147
+ setIsOpen(false);
146
148
  };
147
149
 
148
150
  const resourceName = (resource, resourceType) => {
@@ -182,7 +184,10 @@ export const Subscription = ({
182
184
  },
183
185
  ...resourceTypeId,
184
186
  };
185
- _.prop("id")(subscriptionField) && deleteSubscription(payload);
187
+ if (_.prop("id")(subscriptionField)) {
188
+ deleteSubscription(payload);
189
+ setIsOpen(false);
190
+ }
186
191
  };
187
192
 
188
193
  const handleChange = (e, { name, value }) => {
@@ -200,6 +205,9 @@ export const Subscription = ({
200
205
  position="bottom right"
201
206
  basic
202
207
  flowing
208
+ open={isOpen}
209
+ onOpen={() => setIsOpen(true)}
210
+ onClose={() => setIsOpen(false)}
203
211
  trigger={
204
212
  <Button
205
213
  basic
@@ -64,11 +64,18 @@ describe("<Subscription />", () => {
64
64
  };
65
65
  const subscriptionUpdating = false;
66
66
 
67
+ const createSubscription = jest.fn();
68
+ const updateSubscription = jest.fn();
69
+ const deleteSubscription = jest.fn();
70
+
67
71
  const props = {
68
72
  resource: rule,
69
73
  resourceType: "rule",
70
74
  searchSubscription,
71
75
  subscriptionUpdating,
76
+ createSubscription,
77
+ updateSubscription,
78
+ deleteSubscription,
72
79
  };
73
80
 
74
81
  it("matches the latest snapshot", async () => {
@@ -76,4 +83,23 @@ describe("<Subscription />", () => {
76
83
  await waitForLoad(rendered);
77
84
  expect(rendered.container).toMatchSnapshot();
78
85
  });
86
+
87
+ it("closes the popup after saving the subscription", async () => {
88
+ const rendered = render(<Subscription {...props} />);
89
+ await waitForLoad(rendered);
90
+
91
+ const user = userEvent.setup({ delay: null });
92
+
93
+ // abre el popup haciendo click en el botón de suscripción
94
+ await user.click(rendered.getByRole("button"));
95
+
96
+ // click en guardar
97
+ const saveButton = await rendered.findByText(/actions.save/i);
98
+ await user.click(saveButton);
99
+
100
+ // el popup se cierra (contenido ya no está en el DOM)
101
+ await waitFor(() =>
102
+ expect(rendered.queryByText(/actions.save/i)).not.toBeInTheDocument()
103
+ );
104
+ });
79
105
  });