From 17309ca0d06ce4d4a36501202f3413ea6715ccb0 Mon Sep 17 00:00:00 2001 From: ferrodri Date: Thu, 4 Apr 2024 20:35:00 +0200 Subject: [PATCH] refactor base url --- playwright.config.ts | 4 +++- tests/disconnected/homepage/desktop.spec.ts | 12 +++++------- tests/disconnected/homepage/metadata.spec.ts | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 7dabb9f80..14effd891 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -6,6 +6,8 @@ import { defineConfig, devices } from '@playwright/test'; */ require('dotenv').config(); +const BASE_URL = process.env.PLAYWRIGHT_TEST_BASE_URL || "http://localhost:3000"; + /** * See https://playwright.dev/docs/test-configuration. */ @@ -24,7 +26,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', + baseURL: BASE_URL, /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', diff --git a/tests/disconnected/homepage/desktop.spec.ts b/tests/disconnected/homepage/desktop.spec.ts index 19557f87a..6828b48fc 100644 --- a/tests/disconnected/homepage/desktop.spec.ts +++ b/tests/disconnected/homepage/desktop.spec.ts @@ -1,7 +1,5 @@ -import { test, expect } from "@playwright/test"; +import { test } from "@playwright/test"; -const BASE_URL = - process.env.PLAYWRIGHT_TEST_BASE_URL || "http://localhost:3000"; const validTenants = ["optimism", "ens", "etherfi", "lyra"]; const tenant: string = process.env.NEXT_PUBLIC_AGORA_INSTANCE_NAME || ""; @@ -15,14 +13,14 @@ if (!validTenants.includes(tenant)) { test.describe('homepage desktop', () => { test('connect wallet button', async ({ page }) => { - await page.goto(BASE_URL); - await page.getByText('Connect Wallet').click(); + await page.goto('/'); + await page.getByText('Connect Wallet').first().click(); await page.getByRole('button', { name: 'MetaMask' }).click(); await page.getByLabel('Close').click(); - await page.getByText('Connect Wallet').click(); + await page.getByText('Connect Wallet').first().click(); await page.getByRole('button', { name: 'Coinbase Wallet' }).click(); await page.getByLabel('Close').click(); - await page.getByText('Connect Wallet').click(); + await page.getByText('Connect Wallet').first().click(); await page.getByRole('button', { name: 'Other Wallets' }).click(); await page.getByLabel('Close').click(); }); diff --git a/tests/disconnected/homepage/metadata.spec.ts b/tests/disconnected/homepage/metadata.spec.ts index 259046933..61ff4c7ab 100644 --- a/tests/disconnected/homepage/metadata.spec.ts +++ b/tests/disconnected/homepage/metadata.spec.ts @@ -1,8 +1,8 @@ import { test, expect } from "@playwright/test"; // TODO: frh -> move all this into a fixture -const BASE_URL = - process.env.PLAYWRIGHT_TEST_BASE_URL || "http://localhost:3000"; +// TODO: frh -> typescript +// TODO: frh -> tests are failing on other browsers and connect wallet const validTenants = ["optimism", "ens", "etherfi", "lyra"]; const tenant: string = process.env.NEXT_PUBLIC_AGORA_INSTANCE_NAME || ""; @@ -16,7 +16,7 @@ if (!validTenants.includes(tenant)) { test('homepage metadata', async ({ page }) => { - await page.goto(BASE_URL); + await page.goto('/'); // TODO: frh -> WIP this should be automatically get from multitenancy and check better what each tag is for const title = await page.title();