diff --git a/playwright-tests/tests/landing-page.spec.js b/playwright-tests/tests/landing-page.spec.js deleted file mode 100644 index f02b55d0..00000000 --- a/playwright-tests/tests/landing-page.spec.js +++ /dev/null @@ -1,128 +0,0 @@ -import { expect, test } from "@playwright/test"; -import { ROOT_SRC } from "../util/constants"; - -test.describe("Navbar tabs redirection", () => { - test.beforeEach(async ({ page }) => { - await page.goto(`/${ROOT_SRC}`); - }); - test("Home", async ({ page }) => { - const homeTab = page.locator("span", { hasText: "Home" }); - await homeTab.click(); - expect(page.url()).toContain("?page=home"); - }); - - test("Activity", async ({ page }) => { - const activityTab = page.locator("span", { hasText: "Activity" }); - await activityTab.click(); - expect(page.url()).toContain("?page=activity"); - }); - test("Projects", async ({ page }) => { - const projectsTab = page.getByRole("link", { - name: "Projects", - exact: true, - }); - await projectsTab.click(); - expect(page.url()).toContain("?page=projects"); - }); - test("Resources", async ({ page }) => { - const resourcesTab = page.locator("span", { hasText: "Resources" }); - await resourcesTab.click(); - expect(page.url()).toContain("?page=resources"); - }); -}); - -test.describe("User is logged in", () => { - test.use({ - storageState: "playwright-tests/storage-states/wallet-connected.json", - }); - test.beforeEach(async ({ page }) => { - await page.goto(`/${ROOT_SRC}`); - }); - test("Start project redirection for logged in users", async ({ page }) => { - const startProjectButton = page.getByRole("button", { - name: "Start Project", - }); - await expect(startProjectButton).toBeVisible(); - await startProjectButton.click(); - expect(page.url()).toContain("?page=projects&tab=editor"); - await page.waitForTimeout(2000); - expect(page.getByText("Create Project", { exact: true })).toBeVisible(); - }); - test("Explore Projects redirection for logged in user", async ({ page }) => { - const exploreProjectsButton = page.getByRole("button", { - name: "Explore Project", - }); - await expect(exploreProjectsButton).toBeVisible(); - await exploreProjectsButton.click(); - expect(page.url()).toContain("?page=projects"); - }); - - test("Quickstart Guide page redirection", async ({ page }) => { - const quickStartGuideButton = page.getByRole("button", { - name: "Quickstart Guide", - }); - await expect(quickStartGuideButton).toBeVisible(); - await quickStartGuideButton.click(); - expect(page.url()).toContain("/NEARBuilders/quickstart.near"); - }); - - test("Workspace docs page redirection", async ({ page }) => { - const workSpaceButton = page.getByRole("button", { - name: "Workspace Docs", - }); - await page.waitForTimeout(2000); - await expect(workSpaceButton).toBeVisible(); - await workSpaceButton.click(); - expect(page.url()).toContain("/?page=resources&tab=gettingStarted"); - }); - test("Activity page redirection", async ({ page }) => { - const activityPageButton = page.getByRole("button", { - name: "Activity", - }); - await expect(activityPageButton).toBeVisible(); - await activityPageButton.click(); - expect(page.url()).toContain("?page=activity"); - }); - - test("Twitter redirection", async ({ page }) => { - const twitterButton = page.locator("button[type=icon]").nth(3); - await page.waitForTimeout(2000); - await expect(twitterButton).toBeVisible(); - await twitterButton.click(); - expect(page.url()).toBe("https://x.com/NearBuilders"); - }); - test("Telegram redirection", async ({ page }) => { - const telegramButton = page.locator("button[type=icon]").nth(4); - await page.waitForTimeout(2000); - await expect(telegramButton).toBeVisible(); - await telegramButton.click(); - expect(page.url()).toBe("https://www.nearbuilders.com/tg-builders"); - }); - test("Github redirection", async ({ page }) => { - const githubButton = page.locator("button[type=icon]").nth(5); - await page.waitForTimeout(2000); - await expect(githubButton).toBeVisible(); - await githubButton.click(); - expect(page.url()).toBe("https://github.com/NEARBuilders"); - }); -}); - -test.describe("User is not logged in", () => { - test.use({ - storageState: "playwright-tests/storage-states/wallet-not-connected.json", - }); - test.beforeEach(async ({ page }) => { - await page.goto(`/${ROOT_SRC}`); - }); - test("Start project redirection for logged out users", async ({ page }) => { - const startProjectButton = page.getByRole("button", { - name: "Start Project", - }); - await expect(startProjectButton).toBeVisible(); - await startProjectButton.click(); - expect(page.url()).toContain("?page=projects&tab=editor"); - await page.waitForTimeout(2000); - const connectButton = page.getByRole("button", { name: "Connect" }); - await expect(connectButton).toBeVisible(); - }); -}); diff --git a/playwright-tests/tests/navbar.spec.js b/playwright-tests/tests/navbar.spec.js new file mode 100644 index 00000000..340d404d --- /dev/null +++ b/playwright-tests/tests/navbar.spec.js @@ -0,0 +1,80 @@ +import { expect, test } from "@playwright/test"; +import { ROOT_SRC } from "../util/constants"; + +test.describe("Navbar", () => { + test.use({ + storageState: "playwright-tests/storage-states/wallet-connected.json", + }); + test.beforeEach(async ({ page }) => { + await page.goto(`/${ROOT_SRC}`); + }); + + test("Notifications", async ({ page }) => { + const notificationsButton = page.locator("i.bi.bi-bell").nth(0); + await page.waitForTimeout(1000); + await notificationsButton.click(); + await expect(page).toHaveURL(/.*\?page=notifications/); + }); + + test("View source", async ({ page }) => { + const btn = page.locator("i.bi.bi-three-dots"); + await page.waitForTimeout(1000); + await expect(btn).toBeVisible(); + await btn.click(); + const viewSourceOption = page.getByText("View source", { exact: true }); + await page.waitForTimeout(1000); + await expect(viewSourceOption).toBeVisible(); + await viewSourceOption.click(); + await expect(page).toHaveURL( + /.*\?page=inspect&widgetPath=builddao.testnet\/widget\/page.home.Index/, + ); + await page.waitForTimeout(2000); + expect( + page.locator("a.btn.btn-sm.btn-outline-secondary.border-0").nth(0), + ).toHaveText("Source"); + }); + + test("Edit Code", async ({ page }) => { + const btn1 = page.locator("i.bi.bi-three-dots"); + await page.waitForTimeout(1000); + await expect(btn1).toBeVisible(); + await btn1.click(); + const editCodeOption = page.getByText("Edit code", { exact: true }); + await page.waitForTimeout(1000); + await expect(editCodeOption).toBeVisible(); + await editCodeOption.click(); + await expect(page).toHaveURL(/.*\/edit\//); + }); + test("Network Button -Mainet", async ({ page }) => { + const networkButton = page.getByText("Network", { exact: true }); + await page.waitForTimeout(1000); + await expect(networkButton).toBeVisible(); + await networkButton.click(); + const mainetOption = page.getByText("Mainnet", { exact: true }); + await page.waitForTimeout(1000); + await expect(mainetOption).toBeVisible(); + await mainetOption.click(); + await page.waitForTimeout(1000); + if (page.url().includes(ROOT_SRC)) { + expect(page.url()).toContain("/builddao.near/widget/Index"); + } else { + expect(page.url()).toContain("https://www.nearbuilders.org/"); + } + }); + test("Network Button -Testnet", async ({ page }) => { + const networkButton = page.getByText("Network", { exact: true }); + await page.waitForTimeout(1000); + await expect(networkButton).toBeVisible(); + await networkButton.click(); + const testnetOption = page.getByText("Testnet", { exact: true }); + await page.waitForTimeout(1000); + await expect(testnetOption).toBeVisible(); + await testnetOption.click(); + await page.waitForTimeout(1000); + if (page.url().includes(ROOT_SRC)) { + expect(page.url()).toContain(`/${ROOT_SRC}`); + } else { + expect(page.url()).toContain("https://test.nearbuilders.org/"); + } + }); +});