Skip to content
Open
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 @@ -844,7 +844,7 @@ describe('ApiV4PolicyStudioDesignComponent', () => {
};
httpTestingController
.expectOne({
url: `${CONSTANTS_TESTING.env.v2BaseURL}/apis/${apiId}/plans?page=1&perPage=9999&statuses=PUBLISHED`,
url: `${CONSTANTS_TESTING.env.v2BaseURL}/apis/${apiId}/plans?page=1&perPage=9999&statuses=PUBLISHED,DEPRECATED`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To avoid magic strings and ensure consistency between the test and the component, it would be better to use a shared constant for the plan statuses. The test could then build the expected URL using this constant, for example statuses=${planStatuses.join(',')}. This prevents the test from breaking if the statuses in the component are changed.

method: 'GET',
})
.flush(fakeApiPlansResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ApiV4PolicyStudioDesignComponent implements OnInit, OnDestroy {
this.connectorPluginsV2Service.listEntrypointPlugins(),
this.connectorPluginsV2Service.listEndpointPlugins(),
this.apiPlanV2Service
.list(this.activatedRoute.snapshot.params.apiId, undefined, ['PUBLISHED'], undefined, undefined, 1, 9999)
.list(this.activatedRoute.snapshot.params.apiId, undefined, ['PUBLISHED', 'DEPRECATED'], undefined, undefined, 1, 9999)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve maintainability and avoid using magic strings, consider defining ['PUBLISHED', 'DEPRECATED'] as a constant. If an enum for plan statuses already exists in the codebase, it would be preferable to use it here. This would make the code more readable and easier to update in the future.

.pipe(map((apiPlansResponse) => apiPlansResponse.data)),
this.policyV2Service.list(),
this.sharedPolicyGroupsService.getSharedPolicyGroupPolicyPlugin(),
Expand Down