Skip to content

Commit 8b53e30

Browse files
committed
refactor: replace hardcoded proposal type filters with dynamic values from ProposalType
1 parent 3073c1d commit 8b53e30

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

tests/govtool-frontend/playwright/lib/constants/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ export const SECURITY_RELEVANT_PARAMS_MAP: Record<string, string> = {
1111
minFeeRefScriptCostPerByte: "min_fee_ref_script_cost_per_byte",
1212
};
1313

14-
export const PROPOSAL_TYPE_FILTERS = [
15-
"Info Action",
16-
"Treasury requests",
17-
"Updates to the Constitution",
18-
];
1914
export const BOOTSTRAP_PROPOSAL_TYPE_FILTERS = ["Info Action"];
2015

2116
export const PROPOSAL_STATUS_FILTER = ["Submitted for vote", "Active proposal"];

tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { expect, Locator, Page } from "@playwright/test";
2-
import { ProposalCreateRequest, ProposedGovAction } from "@types";
2+
import { ProposalCreateRequest, ProposalType, ProposedGovAction } from "@types";
33
import environments from "lib/constants/environments";
44
import ProposalDiscussionDetailsPage from "./proposalDiscussionDetailsPage";
5-
import { PROPOSAL_TYPE_FILTERS } from "@constants/index";
65

76
export default class ProposalDiscussionPage {
87
// Buttons
@@ -111,7 +110,7 @@ export default class ProposalDiscussionPage {
111110

112111
async clickRadioButtonsByNames(names: string[]) {
113112
for (const name of names) {
114-
const testId = PROPOSAL_TYPE_FILTERS.includes(name)
113+
const testId = Object.values(ProposalType).includes(name as ProposalType)
115114
? name.toLowerCase()
116115
: name.toLowerCase().replace(/ /g, "-");
117116
await this.page.getByTestId(`${testId}-radio`).click();

tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import environments from "@constants/environments";
22
import {
33
BOOTSTRAP_PROPOSAL_TYPE_FILTERS,
44
PROPOSAL_STATUS_FILTER,
5-
PROPOSAL_TYPE_FILTERS,
65
} from "@constants/index";
76
import { faker } from "@faker-js/faker";
87
import { test } from "@fixtures/proposal";
@@ -50,7 +49,9 @@ test.describe("Filter and sort proposals", () => {
5049

5150
// proposal type filter
5251
await proposalDiscussionPage.applyAndValidateFilters(
53-
isBootStraping ? BOOTSTRAP_PROPOSAL_TYPE_FILTERS : PROPOSAL_TYPE_FILTERS,
52+
isBootStraping
53+
? BOOTSTRAP_PROPOSAL_TYPE_FILTERS
54+
: Object.values(ProposalType),
5455
proposalDiscussionPage._validateTypeFiltersInProposalCard
5556
);
5657

0 commit comments

Comments
 (0)