Skip to content

fix(ui): keep policy rule operations in sync with server#27694

Open
nehaaprasaad wants to merge 1 commit intoopen-metadata:mainfrom
nehaaprasaad:fix/view-bas-class
Open

fix(ui): keep policy rule operations in sync with server#27694
nehaaprasaad wants to merge 1 commit intoopen-metadata:mainfrom
nehaaprasaad:fix/view-bas-class

Conversation

@nehaaprasaad
Copy link
Copy Markdown

@nehaaprasaad nehaaprasaad commented Apr 24, 2026

Describe your changes

fix : #27591

  • Align policy rule operations in the UI with server filterRedundantOperations (PolicyRuleUtils + RuleForm + policy rule pages).
  • IT: classification repro + ViewBasic-only regression.
  • Tested: yarn test PolicyRuleUtils.test.ts

Type of change

  • Bug fix

Checklist

[x] CONTRIBUTING
[x] Bug fix test (IT + unit)

@nehaaprasaad nehaaprasaad requested a review from a team as a code owner April 24, 2026 09:21
@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Comment on lines +17 to +31
describe('PolicyRuleUtils', () => {
it('keeps ViewBasic when it is the only view operation', () => {
const result = filterRedundantPolicyOperations([Operation.ViewBasic]);
expect(result).toEqual([Operation.ViewBasic]);
});

it('removes other view operations when ViewAll is present', () => {
const result = filterRedundantPolicyOperations([
Operation.Create,
Operation.ViewAll,
Operation.ViewBasic,
Operation.ViewUsage,
]);
expect(result).toEqual([Operation.Create, Operation.ViewAll]);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Quality: Unit tests missing coverage for EditAll filtering path

The PolicyRuleUtils.test.ts file only tests ViewAll/ViewBasic scenarios but has no test for the EditAll branch of filterRedundantPolicyOperations. Since the function has two independent filter paths (ViewAll and EditAll), both should be exercised to prevent regressions.

Suggested fix:

Add tests for EditAll filtering, e.g.:

it('removes other edit operations when EditAll is present', () => {
  const result = filterRedundantPolicyOperations([
    Operation.ViewBasic,
    Operation.EditAll,
    Operation.EditDescription,
    Operation.EditTags,
  ]);
  expect(result).toEqual([Operation.ViewBasic, Operation.EditAll]);
});

it('handles both ViewAll and EditAll together', () => {
  const result = filterRedundantPolicyOperations([
    Operation.ViewAll,
    Operation.ViewBasic,
    Operation.EditAll,
    Operation.EditTags,
  ]);
  expect(result).toEqual([Operation.ViewAll, Operation.EditAll]);
});

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Apr 24, 2026

Code Review 👍 Approved with suggestions 0 resolved / 1 findings

Synchronizes UI policy rule operations with server-side state for improved consistency. Add unit tests for the EditAll filtering path to ensure complete test coverage.

💡 Quality: Unit tests missing coverage for EditAll filtering path

📄 openmetadata-ui/src/main/resources/ui/src/utils/PolicyRuleUtils.test.ts:17-31

The PolicyRuleUtils.test.ts file only tests ViewAll/ViewBasic scenarios but has no test for the EditAll branch of filterRedundantPolicyOperations. Since the function has two independent filter paths (ViewAll and EditAll), both should be exercised to prevent regressions.

Suggested fix
Add tests for EditAll filtering, e.g.:

it('removes other edit operations when EditAll is present', () => {
  const result = filterRedundantPolicyOperations([
    Operation.ViewBasic,
    Operation.EditAll,
    Operation.EditDescription,
    Operation.EditTags,
  ]);
  expect(result).toEqual([Operation.ViewBasic, Operation.EditAll]);
});

it('handles both ViewAll and EditAll together', () => {
  const result = filterRedundantPolicyOperations([
    Operation.ViewAll,
    Operation.ViewBasic,
    Operation.EditAll,
    Operation.EditTags,
  ]);
  expect(result).toEqual([Operation.ViewAll, Operation.EditAll]);
});
🤖 Prompt for agents
Code Review: Synchronizes UI policy rule operations with server-side state for improved consistency. Add unit tests for the EditAll filtering path to ensure complete test coverage.

1. 💡 Quality: Unit tests missing coverage for EditAll filtering path
   Files: openmetadata-ui/src/main/resources/ui/src/utils/PolicyRuleUtils.test.ts:17-31

   The `PolicyRuleUtils.test.ts` file only tests `ViewAll`/`ViewBasic` scenarios but has no test for the `EditAll` branch of `filterRedundantPolicyOperations`. Since the function has two independent filter paths (ViewAll and EditAll), both should be exercised to prevent regressions.

   Suggested fix:
   Add tests for EditAll filtering, e.g.:
   
   it('removes other edit operations when EditAll is present', () => {
     const result = filterRedundantPolicyOperations([
       Operation.ViewBasic,
       Operation.EditAll,
       Operation.EditDescription,
       Operation.EditTags,
     ]);
     expect(result).toEqual([Operation.ViewBasic, Operation.EditAll]);
   });
   
   it('handles both ViewAll and EditAll together', () => {
     const result = filterRedundantPolicyOperations([
       Operation.ViewAll,
       Operation.ViewBasic,
       Operation.EditAll,
       Operation.EditTags,
     ]);
     expect(result).toEqual([Operation.ViewAll, Operation.EditAll]);
   });

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ViewBasic permission disappears after saving a Classification policy

1 participant