@truedat/dq 7.13.6 → 7.13.8

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": "7.13.6",
3
+ "version": "7.13.8",
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": "7.13.6",
56
+ "@truedat/test": "7.13.8",
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": "5c369d5a90a39be6362493db19e597a91d5a907d"
89
+ "gitHead": "14e97850f4591da2e3b26dfd5192da159812a39a"
90
90
  }
@@ -115,17 +115,26 @@ ConceptRules.propTypes = {
115
115
  showExpandableColumn: PropTypes.bool,
116
116
  };
117
117
 
118
- const mapStateToProps = ({ conceptRules, concept, conceptRulesActions }) => ({
118
+ const mapStateToProps = ({
119
+ conceptRules,
119
120
  concept,
120
- conceptRules: _.flow(
121
- _.reject("deleted_at"),
122
- _.orderBy(["business_concept_id", "df_name"], ["desc", "asc"])
123
- )(conceptRules),
124
- showExpandableColumn: _.some("business_concept_name")(conceptRules),
125
- createRuleUrl: conceptRulesActions?.create
126
- ? linkTo.CONCEPT_RULES_NEW(concept)
127
- : null,
128
- visible: _.prop("status")(concept) != "deprecated",
129
- });
121
+ conceptRulesActions,
122
+ conceptPermissions = {},
123
+ }) => {
124
+ const manageQualityRule = !!_.prop("manage_quality_rule")(conceptPermissions);
125
+ return {
126
+ concept,
127
+ conceptRules: _.flow(
128
+ _.reject("deleted_at"),
129
+ _.orderBy(["business_concept_id", "df_name"], ["desc", "asc"])
130
+ )(conceptRules),
131
+ showExpandableColumn: _.some("business_concept_name")(conceptRules),
132
+ createRuleUrl: conceptRulesActions?.create
133
+ ? linkTo.CONCEPT_RULES_NEW(concept)
134
+ : null,
135
+ visible:
136
+ _.prop("status")(concept) != "deprecated" && manageQualityRule,
137
+ };
138
+ };
130
139
 
131
140
  export default connect(mapStateToProps)(ConceptRules);
@@ -1,5 +1,6 @@
1
- import { render } from "@truedat/test/render";
1
+ import { render, waitForLoad } from "@truedat/test/render";
2
2
  import { ConceptRules } from "../ConceptRules";
3
+ import { linkTo } from "@truedat/core/routes";
3
4
 
4
5
  describe("<ConceptRules />", () => {
5
6
  const createRuleUrl = "/concepts/1/versions/2/rules/new";
@@ -83,4 +84,59 @@ describe("<ConceptRules />", () => {
83
84
 
84
85
  expect(queryByText(/Create/)).toBeTruthy();
85
86
  });
87
+
88
+ it("shows create button when concept is not deprecated and user has manageQualityRule permission", async () => {
89
+ const concept = { id: "1", business_concept_id: "8", status: "current" };
90
+ const props = {
91
+ conceptRules: [],
92
+ showExpandableColumn: false,
93
+ createRuleUrl: linkTo.CONCEPT_RULES_NEW(concept),
94
+ visible: true,
95
+ };
96
+ const rendered = render(<ConceptRules {...props} />, renderOpts);
97
+ await waitForLoad(rendered);
98
+
99
+ expect(rendered.queryByText(/Create/i)).toBeInTheDocument();
100
+ });
101
+
102
+ it("does not show create button when concept is deprecated even with manageQualityRule permission", async () => {
103
+ const concept = { id: "1", business_concept_id: "8", status: "deprecated" };
104
+ const props = {
105
+ conceptRules: [],
106
+ showExpandableColumn: false,
107
+ createRuleUrl: linkTo.CONCEPT_RULES_NEW(concept),
108
+ visible: false,
109
+ };
110
+ const rendered = render(<ConceptRules {...props} />, renderOpts);
111
+ await waitForLoad(rendered);
112
+
113
+ expect(rendered.queryByText(/Create/i)).not.toBeInTheDocument();
114
+ });
115
+
116
+ it("does not show create button when user does not have manageQualityRule permission", async () => {
117
+ const concept = { id: "1", business_concept_id: "8", status: "current" };
118
+ const props = {
119
+ conceptRules: [],
120
+ showExpandableColumn: false,
121
+ createRuleUrl: linkTo.CONCEPT_RULES_NEW(concept),
122
+ visible: false,
123
+ };
124
+ const rendered = render(<ConceptRules {...props} />, renderOpts);
125
+ await waitForLoad(rendered);
126
+
127
+ expect(rendered.queryByText(/Create/i)).not.toBeInTheDocument();
128
+ });
129
+
130
+ it("does not show create button when conceptRulesActions.create is not available", async () => {
131
+ const props = {
132
+ conceptRules: [],
133
+ showExpandableColumn: false,
134
+ createRuleUrl: null,
135
+ visible: true,
136
+ };
137
+ const rendered = render(<ConceptRules {...props} />, renderOpts);
138
+ await waitForLoad(rendered);
139
+
140
+ expect(rendered.queryByText(/Create/i)).not.toBeInTheDocument();
141
+ });
86
142
  });