Skip to content

Commit

Permalink
Deployment button and page test (#533)
Browse files Browse the repository at this point in the history
* Deployment button and page test

* fix formatting

* adds admin connected role

---------

Co-authored-by: Spandan Datta <[email protected]>
Co-authored-by: Elliot Braem <[email protected]>
  • Loading branch information
3 people authored Apr 17, 2024
1 parent d404ef7 commit c344c95
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
27 changes: 27 additions & 0 deletions playwright-tests/storage-states/admin-connected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"cookies": [],
"origins": [
{
"origin": "http://localhost:8080",
"localStorage": [
{
"name": "near-wallet-selector:selectedWalletId",
"value": "\"my-near-wallet\""
},
{
"name": "near_app_wallet_auth_key",
"value": "{\"accountId\":\"lachlan.near\"}"
},
{
"name": "near-social-vm:v01::accountId:",
"value": "lachlan.near"
},
{
"name": "flags",
"value": "{\"bosLoaderUrl\":\"http://127.0.0.1:3030\"}"
}
]
}
],
"sessionStorage": []
}
37 changes: 31 additions & 6 deletions playwright-tests/tests/pots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
import { test, expect } from "@playwright/test";
import { ROOT_SRC, DEFAULT_POT_ID } from "../util/constants";

test.beforeEach(async ({ page }) => {
await page.goto(`${ROOT_SRC}?tab=pots`);
});

test("clicking pot card should go to pot page", async ({ page }) => {
await page.goto(`${ROOT_SRC}?tab=pots`);
const potCard = await page.getByText("NEAR Retroactive Builders");

await Promise.all([potCard.click(), page.waitForLoadState("load")]);
Expand All @@ -19,8 +16,36 @@ test("clicking pot card should go to pot page", async ({ page }) => {
expect(url).toContain(`?tab=pot&potId=${DEFAULT_POT_ID}`);
});

test("clicking deploy button should go to deploypot page", async ({ page }) => {
// TODO:
test.describe("User is not logged in", () => {
test.use({
storageState: "playwright-tests/storage-states/wallet-not-connected.json",
});

test("deploy button should not be visible", async ({ page }) => {
await page.goto(`${ROOT_SRC}?tab=pots`);

// Check if the deploy button is not visible
const deployButton = await page.$('a:has-text("Deploy Pot")');

// Assert that the deploy button is not visible
expect(deployButton).toBeNull();
});
});

test.describe("Admin is logged in", () => {
test.use({
storageState: "playwright-tests/storage-states/admin-connected.json",
});

test("deploy button should go to deploypot page", async ({ page }) => {
await page.goto(`${ROOT_SRC}?tab=pots`);

const deployButton = await page.getByRole("link", { name: "Deploy Pot" });

await Promise.all([deployButton.click(), page.waitForLoadState("load")]);

expect(page.url()).toContain("?tab=deploypot");
});
});

test("clicking learn more button should...", async ({ page }) => {
Expand Down

0 comments on commit c344c95

Please sign in to comment.