Skip to content

Commit

Permalink
Merge pull request #1539 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
Add tests for feedback and governance actions, fix auth and proposal issues, and remove outdated tests, chore: bumppdf-ui to v0.2.8
  • Loading branch information
pmbinapps authored Jul 10, 2024
2 parents ff22b5e + f3954ac commit 0a8ee97
Show file tree
Hide file tree
Showing 27 changed files with 2,185 additions and 533 deletions.
8 changes: 4 additions & 4 deletions govtool/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion govtool/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@emurgo/cardano-serialization-lib-asmjs": "12.0.0-alpha.29",
"@hookform/resolvers": "^3.3.1",
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
"@intersect.mbo/pdf-ui": "^0.2.7",
"@intersect.mbo/pdf-ui": "^0.2.8",
"@mui/icons-material": "^5.14.3",
"@mui/material": "^5.14.4",
"@rollup/plugin-babel": "^6.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ProposeGovActionDashboardCard = ({

navigate(
isProposalDiscussionForumEnabled
? PDF_PATHS.proposalDiscussion
? PDF_PATHS.proposalDiscussionPropose
: PATHS.createGovernanceAction,
);
}, [deposit, votingPower, isProposalDiscussionForumEnabled]);
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/consts/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export const PATHS = {
export const PDF_PATHS = {
proposalDiscussion: "/proposal_discussion",
proposalDiscussionProposal: "/proposal_discussion/:id",
proposalDiscussionPropose: "/proposal_discussion/propose",
};
8 changes: 4 additions & 4 deletions govtool/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1581,10 +1581,10 @@
resolved "https://registry.npmjs.org/@intersect.mbo/intersectmbo.org-icons-set/-/intersectmbo.org-icons-set-1.0.8.tgz"
integrity sha512-Y+5vYGlF3Smg/QscQT/4ZwsKTNm2C0GCs2czzYWrE4O4RV2YAAg9MZkQ52u8uZp3cEW0h9vr+f9W9ihhwsNHGQ==

"@intersect.mbo/pdf-ui@^0.2.7":
version "0.2.7"
resolved "https://registry.npmjs.org/@intersect.mbo/pdf-ui/-/pdf-ui-0.2.7.tgz"
integrity sha512-vYmxs2F5Grk0Np/DfcytaXiPfgP8YWUYTKoWriS1DWSUdKZgj27DYQbPIL3dRjUW6kOC7rFDdbNQR9bZJ2YVkw==
"@intersect.mbo/pdf-ui@^0.2.8":
version "0.2.8"
resolved "https://registry.npmjs.org/@intersect.mbo/pdf-ui/-/pdf-ui-0.2.8.tgz"
integrity sha512-ioksMZ3G5PJ1RCZPJb5Ui6lKz6bgSk5R5HbjTCY1+AQIDjLIlYE0+gslwqxl1NDF6pLevJUGX+TZAXJgYUd6Vg==
dependencies:
"@fontsource/poppins" "^5.0.14"
"@intersect.mbo/intersectmbo.org-icons-set" "^1.0.8"
Expand Down
49 changes: 49 additions & 0 deletions tests/govtool-frontend/playwright/lib/_mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ export const invalid = {
return " ";
},

username: () => {
const choice = faker.number.int({ min: 1, max: 6 });
if (choice === 1) {
// Contains a space, which is invalid
return faker.lorem.word() + " " + faker.lorem.word();
} else if (choice === 2) {
// Exceeds 30 characters, which is invalid
return faker.lorem.words(31).replace(/\s+/g, "");
} else if (choice === 3) {
// Starts with a period, which is invalid
return "." + faker.internet.userName();
} else if (choice === 4) {
// Starts with an underscore, which is invalid
return "_" + faker.internet.userName();
} else if (choice === 5) {
// Contains an invalid character, such as a symbol
return faker.internet.userName() + "#";
} else if (choice === 6) {
// Contains a hyphen
return faker.internet.userName() + "-";
}
},

email: () => {
const choice = faker.number.int({ min: 1, max: 3 });

Expand Down Expand Up @@ -71,3 +94,29 @@ export const invalid = {
return " ";
},
};

export const valid = {
username: () => {
let username = faker.internet.userName().toLowerCase();

// Remove any invalid characters
username = username.replace(/[^a-z0-9._]/g, "");

// Ensure the username is between 1 and 30 characters
if (username.length > 30) {
username = username.substring(0, 30);
}

// Ensure the first character is not a period or underscore
if (username.startsWith(".") || username.startsWith("_")) {
username = "a" + username.substring(1);
}

// Ensure the username is not empty after the transformations
if (username.length === 0) {
username = "user" + faker.number.int({ min: 1, max: 9999 });
}

return username;
},
};
Loading

0 comments on commit 0a8ee97

Please sign in to comment.