Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Teams and owner fields are not being passed in the policy API call. #17880

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,42 @@ test.describe('Policy page should work properly', () => {
).not.toBeVisible();
});
});

test('Policy should have associated rules and teams', async ({ page }) => {
const policyResponsePromise = page.waitForResponse(
'/api/v1/policies/name/OrganizationPolicy?fields=owners%2Clocation%2Cteams%2Croles'
);

await page
.getByRole('link', {
name: DEFAULT_POLICIES.organizationPolicy,
exact: true,
})
.click();

await policyResponsePromise;

// validate rules tab

await expect(
page.getByText('OrganizationPolicy-NoOwner-Rule')
).toBeVisible();

await expect(page.getByText('OrganizationPolicy-Owner-Rule')).toBeVisible();

// validate roles tab
await page.getByRole('tab', { name: 'Roles', exact: true }).click();

await expect(
page.getByRole('tabpanel', { name: 'Roles', exact: true })
).toBeVisible();

// validate teams tab

await page.getByRole('tab', { name: 'Teams', exact: true }).click();

await expect(
page.getByRole('link', { name: 'Organization', exact: true })
).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import { render, screen } from '@testing-library/react';
import React from 'react';
import { TabSpecificField } from '../../../enums/entity.enum';
import { getPolicyByName } from '../../../rest/rolesAPIV1';
import { POLICY_DATA } from '../PoliciesData.mock';
import AddRulePage from './AddRulePage';

Expand Down Expand Up @@ -66,6 +68,11 @@ describe('Test Add rule page Component', () => {
it('Should render the rule form fields', async () => {
render(<AddRulePage />);

expect(getPolicyByName).toHaveBeenCalledWith(
'data-consumer',
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`
);

const breadcrumb = await screen.findByTestId('breadcrumb');

const title = await screen.findByTestId('add-rule-title');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ const AddRulePage = () => {
try {
const data = await getPolicyByName(
fqn,
`${
(TabSpecificField.OWNERS,
TabSpecificField.LOCATION,
TabSpecificField.TEAMS,
TabSpecificField.ROLES)
}`
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`
);
setPolicy(data ?? ({} as Policy));
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import { render, screen } from '@testing-library/react';
import React from 'react';
import { TabSpecificField } from '../../../enums/entity.enum';
import { getPolicyByName } from '../../../rest/rolesAPIV1';
import { POLICY_DATA } from '../PoliciesData.mock';
import EditRulePage from './EditRulePage';

Expand Down Expand Up @@ -66,6 +68,11 @@ describe('Test Edit rule page Component', () => {
it('Should render the rule form fields', async () => {
render(<EditRulePage />);

expect(getPolicyByName).toHaveBeenCalledWith(
'data-consumer',
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`
);

const breadcrumb = await screen.findByTestId('breadcrumb');

const title = await screen.findByTestId('edit-rule-title');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ const EditRulePage = () => {
try {
const data = await getPolicyByName(
fqn,
`${
(TabSpecificField.OWNERS,
TabSpecificField.LOCATION,
TabSpecificField.TEAMS,
TabSpecificField.ROLES)
}`
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`
);
if (data) {
setPolicy(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import { render, screen } from '@testing-library/react';
import React from 'react';
import { TabSpecificField } from '../../../enums/entity.enum';
import { getPolicyByName } from '../../../rest/rolesAPIV1';
import { POLICY_DATA } from '../PoliciesData.mock';
import PoliciesDetailPage from './PoliciesDetailPage';

Expand Down Expand Up @@ -96,6 +98,11 @@ describe('Test Policy details page', () => {
it('Should render the policy details page component', async () => {
render(<PoliciesDetailPage />);

expect(getPolicyByName).toHaveBeenCalledWith(
'policy',
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`
);

const container = await screen.findByTestId('policy-details-container');

const breadCrumb = await screen.findByTestId('breadcrumb');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ const PoliciesDetailPage = () => {
try {
const data = await getPolicyByName(
fqn,
`${
(TabSpecificField.OWNERS,
TabSpecificField.LOCATION,
TabSpecificField.TEAMS,
TabSpecificField.ROLES)
}`
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`
);
setPolicy(data ?? ({} as Policy));
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { TabSpecificField } from '../../../enums/entity.enum';
import { getPolicies } from '../../../rest/rolesAPIV1';
import AddRolePage from './AddRolePage';

jest.mock('react-router-dom', () => ({
Expand Down Expand Up @@ -70,6 +72,13 @@ describe('Test Add Role Page', () => {
it('Should Render the Add Role page component', async () => {
render(<AddRolePage />, { wrapper: MemoryRouter });

expect(getPolicies).toHaveBeenCalledWith(
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`,
undefined,
undefined,
100
);

const container = await screen.findByTestId('add-role-container');

const breadCrumb = await screen.findByTestId('breadcrumb');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ const AddRolePage = () => {
const fetchPolicies = async () => {
try {
const data = await getPolicies(
`${
(TabSpecificField.OWNERS,
TabSpecificField.LOCATION,
TabSpecificField.TEAMS,
TabSpecificField.ROLES)
}`,
`${TabSpecificField.OWNERS},${TabSpecificField.LOCATION},${TabSpecificField.TEAMS},${TabSpecificField.ROLES}`,
undefined,
undefined,
100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ const ServiceDetailsPage: FunctionComponent = () => {
{
fields: `${TabSpecificField.OWNERS},${TabSpecificField.TAGS},${
isMetadataService ? '' : TabSpecificField.DATA_PRODUCTS
},${isMetadataService ? '' : 'domain'}`,
},${isMetadataService ? '' : TabSpecificField.DOMAIN}`,
include: Include.All,
}
);
Expand Down
Loading