|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import { ROOT_SRC } from "../util/constants"; |
| 3 | + |
| 4 | +test.describe("Navbar tabs redirection", () => { |
| 5 | + test.beforeEach(async ({ page }) => { |
| 6 | + await page.goto(`/${ROOT_SRC}`); |
| 7 | + }); |
| 8 | + test("Home", async ({ page }) => { |
| 9 | + const homeTab = page.locator("span", { hasText: "Home" }); |
| 10 | + await homeTab.click(); |
| 11 | + expect(page.url()).toContain("?page=home"); |
| 12 | + }); |
| 13 | + |
| 14 | + test("Activity", async ({ page }) => { |
| 15 | + const activityTab = page.locator("span", { hasText: "Activity" }); |
| 16 | + await activityTab.click(); |
| 17 | + expect(page.url()).toContain("?page=activity"); |
| 18 | + }); |
| 19 | + test("Projects", async ({ page }) => { |
| 20 | + const projectsTab = page.getByRole("link", { |
| 21 | + name: "Projects", |
| 22 | + exact: true, |
| 23 | + }); |
| 24 | + await projectsTab.click(); |
| 25 | + expect(page.url()).toContain("?page=projects"); |
| 26 | + }); |
| 27 | + test("Resources", async ({ page }) => { |
| 28 | + const resourcesTab = page.locator("span", { hasText: "Resources" }); |
| 29 | + await resourcesTab.click(); |
| 30 | + expect(page.url()).toContain("?page=resources"); |
| 31 | + }); |
| 32 | +}); |
| 33 | + |
| 34 | +test.describe("User is logged in", () => { |
| 35 | + test.use({ |
| 36 | + storageState: "playwright-tests/storage-states/wallet-connected.json", |
| 37 | + }); |
| 38 | + test.beforeEach(async ({ page }) => { |
| 39 | + await page.goto(`/${ROOT_SRC}`); |
| 40 | + }); |
| 41 | + test("Start project redirection for logged in users", async ({ page }) => { |
| 42 | + const startProjectButton = page.getByRole("button", { |
| 43 | + name: "Start Project", |
| 44 | + }); |
| 45 | + await expect(startProjectButton).toBeVisible(); |
| 46 | + await startProjectButton.click(); |
| 47 | + expect(page.url()).toContain("?page=projects&tab=editor"); |
| 48 | + }); |
| 49 | + test("Explore Projects redirection for logged in user", async ({ page }) => { |
| 50 | + const exploreProjectsButton = page.getByRole("button", { |
| 51 | + name: "Explore Project", |
| 52 | + }); |
| 53 | + await expect(exploreProjectsButton).toBeVisible(); |
| 54 | + await exploreProjectsButton.click(); |
| 55 | + expect(page.url()).toContain("?page=projects"); |
| 56 | + }); |
| 57 | + |
| 58 | + test("Quickstart Guide page redirection", async ({ page }) => { |
| 59 | + const quickStartGuideButton = page.getByRole("button", { |
| 60 | + name: "Quickstart Guide", |
| 61 | + }); |
| 62 | + await expect(quickStartGuideButton).toBeVisible(); |
| 63 | + await quickStartGuideButton.click(); |
| 64 | + expect(page.url()).toContain("/NEARBuilders/quickstart.near"); |
| 65 | + }); |
| 66 | + |
| 67 | + test("Workspace docs page redirection", async ({ page }) => { |
| 68 | + const workSpaceButton = page.getByRole("button", { |
| 69 | + name: "Workspace Docs", |
| 70 | + }); |
| 71 | + await page.waitForTimeout(2000); |
| 72 | + await expect(workSpaceButton).toBeVisible(); |
| 73 | + await workSpaceButton.click(); |
| 74 | + expect(page.url()).toContain("/?page=resources&tab=gettingStarted"); |
| 75 | + }); |
| 76 | + test("Activity page redirection", async ({ page }) => { |
| 77 | + const activityPageButton = page.getByRole("button", { |
| 78 | + name: "Activity", |
| 79 | + }); |
| 80 | + await expect(activityPageButton).toBeVisible(); |
| 81 | + await activityPageButton.click(); |
| 82 | + expect(page.url()).toContain("?page=activity"); |
| 83 | + }); |
| 84 | + |
| 85 | + test("Twitter redirection", async ({ page }) => { |
| 86 | + const twitterButton = page.locator("button[type=icon]").nth(3); |
| 87 | + await page.waitForTimeout(2000); |
| 88 | + await expect(twitterButton).toBeVisible(); |
| 89 | + await twitterButton.click(); |
| 90 | + expect(page.url()).toContain("twitter"); |
| 91 | + }); |
| 92 | + test("Telegram redirection", async ({ page }) => { |
| 93 | + const telegramButton = page.locator("button[type=icon]").nth(4); |
| 94 | + await page.waitForTimeout(2000); |
| 95 | + await expect(telegramButton).toBeVisible(); |
| 96 | + await telegramButton.click(); |
| 97 | + expect(page.url()).toBe("https://www.nearbuilders.com/tg-builders"); |
| 98 | + }); |
| 99 | + test("Github redirection", async ({ page }) => { |
| 100 | + const githubButton = page.locator("button[type=icon]").nth(5); |
| 101 | + await page.waitForTimeout(2000); |
| 102 | + await expect(githubButton).toBeVisible(); |
| 103 | + await githubButton.click(); |
| 104 | + expect(page.url()).toBe("https://github.com/NEARBuilders"); |
| 105 | + }); |
| 106 | +}); |
| 107 | + |
| 108 | +test.describe("User is not logged in", () => { |
| 109 | + test.use({ |
| 110 | + storageState: "playwright-tests/storage-states/wallet-not-connected.json", |
| 111 | + }); |
| 112 | + test.beforeEach(async ({ page }) => { |
| 113 | + await page.goto(`/${ROOT_SRC}`); |
| 114 | + }); |
| 115 | + test("Start project redirection for logged out users", async ({ page }) => { |
| 116 | + const startProjectButton = page.getByRole("button", { |
| 117 | + name: "Start Project", |
| 118 | + }); |
| 119 | + await expect(startProjectButton).toBeVisible(); |
| 120 | + await startProjectButton.click(); |
| 121 | + expect(page.url()).toContain("?page=projects&tab=editor"); |
| 122 | + await page.waitForTimeout(2000); |
| 123 | + const connectButton = page.getByRole("button", { name: "Connect" }); |
| 124 | + await expect(connectButton).toBeVisible(); |
| 125 | + }); |
| 126 | +}); |
0 commit comments