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

chore: add force rebuild images toggle to github actions #1344

Merged
merged 57 commits into from
Jun 19, 2024
Merged
Changes from 37 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
faa4928
WIP Update stress tests
mesudip May 24, 2024
f69a78d
Fetch Drep and Proposal Ids for seeding
mesudip Jun 3, 2024
4aa67f8
Setup deployment for storybook
NabinKawan Jun 17, 2024
d1bdf06
Fix Storybook deployment setup
mesudip Jun 19, 2024
789a330
Configure Google tag manager in test stack
mesudip Jun 19, 2024
6d82a29
Fix SonarQube analysis
mesudip Jun 19, 2024
e13cb49
Workflow: Configure registry url and scope
mesudip Jun 19, 2024
7fcac21
Increase heap size for test run
mesudip Jun 19, 2024
3b09d37
Run SonarQube scan on test failure
mesudip Jun 19, 2024
5436aea
Merge pull request #1336 from IntersectMBO/fixes/test-stack-gtm
mesudip Jun 19, 2024
aeda2cd
Update sentry DNS variable in test stack
mesudip Jun 19, 2024
98de2a2
Merge pull request #1339 from IntersectMBO/chore/update-sentry-dns
mesudip Jun 19, 2024
0b41db6
Merge pull request #1338 from IntersectMBO/fix/sonarqube-analysis
mesudip Jun 19, 2024
b6d611c
Add placement constraint on storybook service
mesudip Jun 19, 2024
85d2f28
Merge pull request #1316 from IntersectMBO/feat/deploy-storybook
mesudip Jun 19, 2024
3dd1b06
Make user-scenarios on stress-test readable
mesudip Jun 19, 2024
f37bf63
feat: Proposal services to create,delete proposal and add poll on pro…
kneerose Jun 12, 2024
9b04367
feat: Add proposal setup and teardown
kneerose Jun 12, 2024
b489f6e
chore: Add proposal discussion and its details page
kneerose Jun 12, 2024
41a2091
chore: Add fixture of proposal discussion details page
kneerose Jun 12, 2024
c11724f
test: proposal discussion forum [WIP]
kneerose Jun 12, 2024
46e796e
chore: Make types first character capital
kneerose Jun 13, 2024
64fc37c
feat: Add proposal comment service and use it on temporary proposal c…
kneerose Jun 13, 2024
fc16116
chore: Add helper for create file
NabinKawan Jun 13, 2024
d0031e9
chore: Refactor proposal-setup to create static proposals
NabinKawan Jun 13, 2024
e04b7fa
test: Share proposed governance action and proposal discussions acces…
NabinKawan Jun 13, 2024
4a5115f
chore: Refactor proposal discussion service and creation flow
NabinKawan Jun 13, 2024
779f5a6
test: Poll voting and Proposal creation restriction
NabinKawan Jun 13, 2024
68ef3aa
chore: Remove proposal manager
kneerose Jun 13, 2024
19dfcd6
test: Sort comment and disable poll voting
kneerose Jun 13, 2024
dec2a08
fix: Base file path of mock
kneerose Jun 13, 2024
e67caf0
test: Set username
kneerose Jun 13, 2024
d546c00
chore: Add mulple proposal deletion
kneerose Jun 13, 2024
b891e62
test: Comment and reply anonymously
kneerose Jun 13, 2024
bcebe1b
chore: Setup proposal wallet
NabinKawan Jun 14, 2024
1e92c89
tempFix: Slow page loading by changing test timeout to 90 sec
NabinKawan Jun 14, 2024
c4f286a
chore: Setup/Teardown proposal using ui approach
NabinKawan Jun 14, 2024
4c5116a
test: comment and reply proposal
NabinKawan Jun 14, 2024
e7336b9
chore: Enhance fixture proposalDiscussionDetailsPage to proposal
NabinKawan Jun 14, 2024
2e3988a
tempFix: Reload after sanchonet info on login
NabinKawan Jun 14, 2024
db2dd90
test: Update anonymous username to set username in comments
NabinKawan Jun 14, 2024
140b527
chore: Mock proposal, poll for visibility testing
NabinKawan Jun 14, 2024
17ac9cc
chore: Add pollEnabled option on proposal fixture
kneerose Jun 14, 2024
42ce3c3
test: Vote and change vote functionality in proposal poll
kneerose Jun 14, 2024
815d712
test: Add and cancel poll
kneerose Jun 14, 2024
fc038b2
chore: Remove proposal teardown and setup
kneerose Jun 14, 2024
58ab129
fix: Search gov action list
kneerose Jun 14, 2024
655770e
fix: test poll proposal
NabinKawan Jun 14, 2024
2ca0cc4
chore: Refactor test username
NabinKawan Jun 14, 2024
dd464db
test: Comments visibility
NabinKawan Jun 14, 2024
4255fa3
chore: Remove unused proposal discussion services
NabinKawan Jun 19, 2024
1b147e0
chore: Fix typo in test title (6F)
NabinKawan Jun 19, 2024
d95d625
Merge pull request #1301 from IntersectMBO/feat/pdf-tests
NabinKawan Jun 19, 2024
8c337e6
Merge pull request #1149 from IntersectMBO/chore/update-stress-tests
mesudip Jun 19, 2024
4b95ff3
chore: add force rebuild images toggle to github actions
MSzalowski Jun 19, 2024
8bb1b0b
Merge pull request #1342 from IntersectMBO/chore/add-force-rebuild-im…
MSzalowski Jun 19, 2024
0b5a5ee
Merge pull request #1343 from IntersectMBO/develop
MSzalowski Jun 19, 2024
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
3 changes: 3 additions & 0 deletions tests/govtool-frontend/playwright/.env.example
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@ API_URL=http://localhost:3000/api

DOCS_URL=https://docs.sanchogov.tools


PDF_URL=https://dev.api.pdf.gov.tools

# 0 for testnet, 1 for mainnet
NETWORK_ID=0

1 change: 1 addition & 0 deletions tests/govtool-frontend/playwright/.gitignore
Original file line number Diff line number Diff line change
@@ -16,4 +16,5 @@ allure-report/
lib/_mock/registerDRepWallets.json
lib/_mock/registeredDRepWallets.json
lib/_mock/wallets.json
lib/_mock/proposals.json
./lock_logs.txt
44 changes: 44 additions & 0 deletions tests/govtool-frontend/playwright/lib/_mock/proposal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"data": {
"id": 128,
"attributes": {
"prop_likes": 0,
"prop_dislikes": 0,
"prop_comments_number": 3,
"prop_submited": false,
"prop_status_id": null,
"user_id": "52",
"createdAt": "2024-06-14T08:28:18.000Z",
"updatedAt": "2024-06-14T08:28:18.000Z",
"content": {
"id": 121,
"attributes": {
"proposal_id": "128",
"prop_rev_active": true,
"prop_abstract": "Calamitas suppono coniuratio aiunt pecto uberrime deleniti tepidus acerbitas. Nihil vitium conservo abeo tametsi odit creator basium.",
"prop_motivation": "Demonstro apparatus torrens patrocinor. Concedo campana possimus agnosco tutamen astrum conventus defendo sublime.",
"prop_rationale": "Brevis suppellex coadunatio vis. Alii terreo carbo sono utilis vicissitudo.",
"gov_action_type_id": "1",
"prop_name": "Labadie, Stehr and Rosenbaum",
"prop_receiving_address": "addr_test1qqqqqqqqqqa4kpmh",
"prop_amount": 402,
"createdAt": "2024-06-14T08:28:18.012Z",
"updatedAt": "2024-06-14T08:28:18.012Z",
"is_draft": false,
"user_id": "52",
"proposal_links": [],
"gov_action_type": {
"id": 1,
"attributes": {
"gov_action_type_name": "Info",
"createdAt": "2024-05-27T15:06:15.640Z",
"updatedAt": "2024-05-27T15:06:15.640Z"
}
}
}
},
"user_govtool_username": "Jett.Hagenes21"
}
},
"meta": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"data": [
{
"id": 139,
"attributes": {
"proposal_id": "128",
"comment_parent_id": null,
"user_id": "20",
"comment_text": "Hello",
"createdAt": "2024-06-14T13:38:35.830Z",
"updatedAt": "2024-06-14T13:38:35.830Z",
"user_govtool_username": "Anonymous",
"subcommens_number": 0
}
},
{
"id": 138,
"attributes": {
"proposal_id": "128",
"comment_parent_id": null,
"user_id": "20",
"comment_text": "Nice proposal",
"createdAt": "2024-06-14T13:38:31.279Z",
"updatedAt": "2024-06-14T13:38:31.279Z",
"user_govtool_username": "Anonymous",
"subcommens_number": 0
}
},
{
"id": 137,
"attributes": {
"proposal_id": "128",
"comment_parent_id": null,
"user_id": "20",
"comment_text": "Go Ahead",
"createdAt": "2024-06-14T13:38:27.286Z",
"updatedAt": "2024-06-14T13:38:27.286Z",
"user_govtool_username": "Anonymous",
"subcommens_number": 0
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 3
}
}
}
24 changes: 24 additions & 0 deletions tests/govtool-frontend/playwright/lib/_mock/proposalPoll.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"data": [
{
"id": 39,
"attributes": {
"proposal_id": "128",
"poll_yes": 0,
"poll_no": 0,
"poll_start_dt": "2024-06-14T08:26:34.400Z",
"is_poll_active": true,
"createdAt": "2024-06-14T08:28:20.210Z",
"updatedAt": "2024-06-14T08:28:20.210Z"
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 1,
"pageCount": 1,
"total": 1
}
}
}
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ const environments = {
frontendUrl: SERVER_HOST_URL,
apiUrl: `${SERVER_HOST_URL}/api`,
docsUrl: process.env.DOCS_URL || "https://docs.sanchogov.tools",
pdfUrl: process.env.PDF_URL || "https://dev.api.pdf.gov.tools",
networkId: parseInt(process.env.NETWORK_ID) || 0,
faucet: {
apiUrl:
Original file line number Diff line number Diff line change
@@ -16,6 +16,9 @@ export const adaHolder06Wallet = staticWallets[9];
// Does not takes part in transaction
export const user01Wallet: StaticWallet = staticWallets[5];

// Username is already set
export const proposal01Wallet: StaticWallet = staticWallets[10];

export const adaHolderWallets = [
adaHolder01Wallet,
adaHolder02Wallet,
@@ -28,3 +31,5 @@ export const adaHolderWallets = [
export const userWallets = [user01Wallet];

export const dRepWallets = [dRep01Wallet, dRep02Wallet];

export const proposalWallets = [proposal01Wallet];
37 changes: 37 additions & 0 deletions tests/govtool-frontend/playwright/lib/fixtures/proposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { proposal01Wallet } from "@constants/staticWallets";
import { test as base } from "@fixtures/walletExtension";
import { createNewPageWithWallet } from "@helpers/page";
import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage";
import ProposalDiscussionPage from "@pages/proposalDiscussionPage";

type TestOptions = {
proposalId: number;
pollEnabled: boolean;
};

export const test = base.extend<TestOptions>({
pollEnabled: [false, { option: true }],

proposalId: async ({ page, browser, pollEnabled }, use) => {
// setup
const proposalPage = await createNewPageWithWallet(browser, {
storageState: ".auth/proposal01.json",
wallet: proposal01Wallet,
});

const proposalDiscussionPage = new ProposalDiscussionPage(proposalPage);
await proposalDiscussionPage.goto();
const proposalId = await proposalDiscussionPage.createProposal();
const proposalDetailsPage = new ProposalDiscussionDetailsPage(proposalPage);

if (pollEnabled) {
await proposalDetailsPage.addPollBtn.click();
}

await use(proposalId);

// cleanup
await proposalDetailsPage.goto(proposalId);
await proposalDetailsPage.deleteProposal();
},
});
7 changes: 7 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/cardano.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { bech32 } from "bech32";

export function lovelaceToAda(lovelace: number) {
if (lovelace === 0) return 0;

return lovelace / 1e6;
}

export function generateWalletAddress() {
const randomBytes = new Uint8Array(10);
return bech32.encode("addr_test", randomBytes);
}
20 changes: 20 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { writeFile } from "fs";
const path = require("path");

const baseFilePath = path.resolve(__dirname, "../_mock");

export async function createFile(fileName: string, data?: any) {
await new Promise<void>((resolve, reject) =>
writeFile(
`${baseFilePath}/${fileName}`,
JSON.stringify(data, null, 2),
(err) => {
if (err) {
reject(err);
} else {
resolve();
}
}
)
);
}
3 changes: 3 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function extractProposalIdFromUrl(url: string) {
return parseInt(url.split("/").pop());
}
16 changes: 16 additions & 0 deletions tests/govtool-frontend/playwright/lib/pages/loginPage.ts
Original file line number Diff line number Diff line change
@@ -25,8 +25,24 @@ export default class LoginPage {

await this.connectWalletBtn.click();
await this.demosWalletBtn.click({ force: true });

/**
* TODO: Remove this
* This has been set to tackle dashboard white screen issue on initial login
*/
await this.page.reload();
/**
* TODO: Uncomment this
* Accept sanchonet info modal is not showing for now
*/
await this.acceptSanchoNetInfoBtn.click({ force: true });

/**
* TODO: Remove this
* This has been set to tackle dashboard white screen issue on initial login
*/
await this.page.reload();

const { stakeKeys, rewardAddresses } = await this.page.evaluate(
async () => {
const walletInstance: CIP30Instance | Cip95Instance =
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import environments from "@constants/environments";
import { Page, expect } from "@playwright/test";
import { CommentResponse } from "@types";

export default class ProposalDiscussionDetailsPage {
// Buttons
readonly likeBtn = this.page.getByRole("button", {
name: "proposal likes",
});
readonly dislikeBtn = this.page.getByRole("button", {
name: "proposal dislikes",
});
readonly commentBtn = this.page.getByRole("button", {
name: "Comment",
exact: true,
}); // this.page.getByTestId("comment-button");
readonly addPollBtn = this.page.getByRole("button", { name: "Add Poll" }); // BUG missing test id
readonly SubmitBtn = this.page.getByTestId("submit-button");
readonly menuBtn = this.page.getByTestId("menu-button");
readonly editProposalBtn = this.page.getByTestId("edit-proposal");
readonly deleteProposalBtn = this.page.getByTestId("delete-proposal");
readonly reviewVersionsBtn = this.page.getByTestId("review-versions");
readonly closePollBtn = this.page.getByRole("button", { name: "Close Poll" }); // BUG missing test id
readonly sortBtn = this.page
.locator("div")
.filter({ hasText: /^Comments$/ })
.getByRole("button"); // this.page.getByTestId("sort-button");
readonly proposeGovernanceAction = this.page.getByTestId("propose-GA-button");
readonly replyBtn = this.page.getByTestId("reply-button");
readonly pollYesBtn = this.page.getByRole("button", { name: "Yes" }); //BUG missing test id
readonly pollNoBtn = this.page.getByRole("button", { name: "No" }); //BUG missing test id
readonly showReplyBtn = this.page.getByTestId("show-more-reply");
readonly closePollYesBtn = this.page.getByRole("button", {
name: "Yes, close Poll",
}); // BUG missing test id
readonly changeVoteBtn = this.page.getByRole("button", {
name: "Change Vote",
});

// Indicators
readonly likesCounts = this.page.getByTestId("likes-count");
readonly dislikesCounts = this.page.getByTestId("dislikse-count");
readonly commentsCount = this.page.getByTestId("comments-count");

// Cards
readonly pollVoteCard = this.page.getByTestId("poll-vote-card");
readonly pollResultCard = this.page.getByTestId("poll-result-card");
readonly commentCard =
this.proposeGovernanceAction.getByTestId("comment-card");

//inputs
readonly commentInput = this.page.getByRole("textbox");

constructor(private readonly page: Page) {}

async goto(proposalId: number) {
await this.page.goto(
`${environments.frontendUrl}/connected/proposal_pillar/proposal_discussion/${proposalId}`
);
}

async closeUsernamePrompt() {
await this.page
.locator("div")
.filter({ hasText: /^Hey, setup your username$/ })
.getByRole("button")
.click();
}

async addComment(comment: string) {
await this.commentInput.fill(comment);
await this.page
.getByRole("button", { name: "Comment", exact: true })
.click();
}

async replyComment(reply: string) {
await this.page.getByRole("button", { name: "Reply" }).click();
await this.page.getByPlaceholder("Add comment").fill(reply);
await this.page.getByRole("button", { name: "Comment" }).nth(2).click();
}

async sortAndValidate(
order: string,
validationFn: (date1: string, date2: string) => boolean
) {
const responsePromise = this.page.waitForResponse((response) =>
response.url().includes(`&sort[createdAt]=${order}`)
);

await this.sortBtn.click();
const response = await responsePromise;

const comments: CommentResponse[] = (await response.json()).data;

// API validation
for (let i = 0; i < comments.length - 1; i++) {
const isValid = validationFn(
comments[i].attributes.updatedAt,
comments[i + 1].attributes.updatedAt
);
expect(isValid).toBe(true);
}
}

async voteOnPoll(vote: string) {
await this.page.getByRole("button", { name: `${vote}` }).click();
}

async deleteProposal() {
await this.page.waitForTimeout(2_000);

await this.page.locator("#menu-button").click();
await this.page.getByRole("menuitem", { name: "Delete Proposal" }).click();

// confirm deletion
await this.page
.getByRole("button", { name: "Yes, delete my proposal" })
.click();
}
}
Loading