Skip to content

Commit

Permalink
Merge pull request #20 from GuardianUI/test-examples
Browse files Browse the repository at this point in the history
Add test examples
  • Loading branch information
lipmaneth authored May 23, 2023
2 parents 94becd1 + 2515ef6 commit 9ac37a3
Show file tree
Hide file tree
Showing 6 changed files with 344 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
.github
dist/*.test.ts
src
test-examples
CLA.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Expand Down
207 changes: 207 additions & 0 deletions test-examples/bond-example-complex.gui.ts

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions test-examples/bond-example-simple.gui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { test } from "@guardianui/test";

test.describe("Bond Protocol", () => {
test("Should create Fixed Term market", async ({ page, gui }) => {
// Initialize fork
await gui.initializeChain(1);

// Go to bond protocol
await page.goto("https://app.bondprotocol.finance/#/create");

// Mocking
await gui.setEthBalance("100000000000000000000000");
await gui.setBalance("0x6b175474e89094c44da98b954eedeac495271d0f", "100000000000000000000000");

// Select DAI as payout token
await page.waitForSelector("input[id='cm-payout-token-picker']");
await page.locator("input[id='cm-payout-token-picker']").first().click();
await page.waitForSelector("text=DAI");
await page.locator("text=DAI").first().click();

// Select DAI as output token
await page.waitForSelector("input[id='cm-quote-token-picker']");
await page.locator("input[id='cm-quote-token-picker']").first().click();
await page.waitForSelector("text=DAI");
await page.locator("text=DAI").first().click();

// Select vesting term
await page.waitForSelector("button[id='cm-vesting-picker']");
await page.locator("button[id='cm-vesting-picker']").first().click();
await page.waitForSelector("text=7 days");
await page.locator("text=7 days").first().click();

// Enter capacity
await page.waitForSelector("input[id='cm-capacity-picker']");
await page.locator("input[id='cm-capacity-picker']").first().fill("100");

// Select end date
await page.waitForSelector("input[id='cm-end-date-picker']");
await page.locator("input[id='cm-end-date-picker']").first().click();
await page.waitForSelector("input[placeholder='Enter the amount of days to run the market']");
await page.locator("input[placeholder='Enter the amount of days to run the market']").first().fill("1");
await page.locator("button:has-text('Select')").first().click();

// Open market submission modal
await page.waitForSelector("button[id='cm-pre-submit']");
await page.locator("button[id='cm-pre-submit']").first().click();

// Confirm deployment
await page.waitForSelector("button[id='cm-confirm-modal-submit-allowance']");
await gui.validateContractInteraction("button[id='cm-confirm-modal-submit-allowance']", "0x007f7735baf391e207e3aa380bb53c4bd9a5fed6");
});
});
43 changes: 43 additions & 0 deletions test-examples/olympus-example.gui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { test } from "@guardianui/test";

test.describe("Olympus", () => {
test("Should stake OHM to gOHM", async ({ page, gui }) => {
// Initialize fork
await gui.initializeChain(1);

// Navigate to site
await page.goto("https://app.olympusdao.finance/#/stake");

// Set up wallet
await gui.setEthBalance("100000000000000000000000");
await gui.setAllowance("0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5", "0xb63cac384247597756545b500253ff8e607a8020", "1000000000000000000000000");
await gui.setBalance("0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5", "1000000000000000000000000");

// Clear any info modals
let infoModalIsVisible = await page.isVisible("text=Did You Know?");
if (infoModalIsVisible) {
await page.locator("[id='root']").click({ position: {x: 0, y: 0}, force: true });
}

await page.waitForSelector("text=Connect Wallet");
await page.locator("text=Connect Wallet").first().click();
await page.waitForSelector("text=Connect Wallet");
await page.locator("text=Connect Wallet").first().click();
await page.locator("text=Metamask").first().click();
await page.locator("[id='root']").click({ position: {x: 0, y: 0}, force: true });

// Enter OHM input amount
await page.locator("[data-testid='ohm-input']").type("0.1");

// Execute stake
await page.waitForSelector("[data-testid='submit-button']");
await page.locator("[data-testid='submit-button']").click();

// Sign checkbox transaction
await page.waitForSelector("[class='PrivateSwitchBase-input css-1m9pwf3']");
await page.locator("[class='PrivateSwitchBase-input css-1m9pwf3']").click();

// Submit stake transaction
await gui.validateContractInteraction("[data-testid='submit-modal-button']", "0xb63cac384247597756545b500253ff8e607a8020");
});
});
40 changes: 40 additions & 0 deletions test-examples/ribbon-example.gui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { test } from "@guardianui/test";

test.describe("Ribbon Uni Deposit", () => {
test("Should deposit UNI into the Ribbon UNI Covered Call Vault", async ({ page, gui }) => {
// Initialize fork
await gui.initializeChain(1);

// Navigate to site
await page.goto("https://app.ribbon.finance/v2/theta-vault/T-UNI-C");

// Mocking
await gui.setEthBalance("100000000000000000000000");
await gui.setBalance("0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", "1000000000000000000000");

// Connect wallet
let needToConnect = await page.isVisible("text=Connect Wallet");
if (needToConnect) {
await page.waitForSelector("text=Connect Wallet");
await page.locator("text=Connect Wallet").first().click();
await page.locator("span:has-text('Ethereum')").click();
await page.locator("div[role='button']:has-text('Next')").click();
await page.locator("span:has-text('METAMASK')").click();
await page.locator("text=Connect WalletMETAMASKWALLET CONNECTCOINBASE WALLETConnectLearn more about walle >> div[role='button'] >> nth=3").click();
}

// Wait for site to recognize UNI balance
await page.waitForSelector("text=1,000 UNI");

// Enter UNI amount
await page.waitForSelector("input[placeholder='0']");
await page.locator("input[placeholder='0']").first().type("1");

// Click preview deposit button
await page.waitForSelector("button:has-text('Preview Deposit')");
await page.locator("button:has-text('Preview Deposit')").first().click();

// Click approve UNI button and verify contract target
await gui.validateContractInteraction("button:has-text('Approve UNI') >> visible=true", "0xDD9d1B7dEaB1A843A1B584d2CA5903B8A4735deF");
});
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src/**/*"],
"exclude": ["node_modules", "src/types"]
"exclude": ["node_modules", "src/types", "test-examples"]
}

0 comments on commit 9ac37a3

Please sign in to comment.