From 3f60d13a1887fbab5a5c4e9fbf53c301ae3dcba4 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 2 May 2025 15:37:07 -0600 Subject: [PATCH] Fix additional tests --- web/playwright-tests/0_Question_2.test.ts | 2 +- web/playwright-tests/0_Question_3.test.ts | 3 +- web/playwright-tests/auth-utils/auth-utils.ts | 28 +++++++++++++++++-- .../auth-utils/global-setup.ts | 4 ++- web/playwright-tests/dataset-list.test.ts | 2 ++ web/playwright.config.ts | 2 +- .../SelectAxisAvailableItemsList.tsx | 1 + .../SelectAxisDropzone.tsx | 2 +- .../SelectAxisItemDragContainer.tsx | 4 +-- 9 files changed, 38 insertions(+), 10 deletions(-) diff --git a/web/playwright-tests/0_Question_2.test.ts b/web/playwright-tests/0_Question_2.test.ts index dddef5626..742571d6e 100644 --- a/web/playwright-tests/0_Question_2.test.ts +++ b/web/playwright-tests/0_Question_2.test.ts @@ -15,5 +15,5 @@ test('Question: Can you make me a line chart that showcases my sales over time? await expect(page.getByText('Reasoned')).toBeVisible(); //expect to for the text "Chart" on the page - await expect(page.getByText('Chart')).toBeVisible(); + await expect(page.getByRole('tab', { name: 'Chart' })).toBeVisible(); }); diff --git a/web/playwright-tests/0_Question_3.test.ts b/web/playwright-tests/0_Question_3.test.ts index 2115b0bc3..97840a972 100644 --- a/web/playwright-tests/0_Question_3.test.ts +++ b/web/playwright-tests/0_Question_3.test.ts @@ -13,5 +13,6 @@ test(`Question: ${question}`, async ({ page }) => { await expect(page.getByText('Reasoned')).toBeVisible(); //expect to for the text "Chart" on the page - await expect(page.getByText('Chart')).toBeVisible(); + + await expect(page.getByRole('tab', { name: 'Chart' })).toBeVisible(); }); diff --git a/web/playwright-tests/auth-utils/auth-utils.ts b/web/playwright-tests/auth-utils/auth-utils.ts index a21968504..0e01e3390 100644 --- a/web/playwright-tests/auth-utils/auth-utils.ts +++ b/web/playwright-tests/auth-utils/auth-utils.ts @@ -3,6 +3,7 @@ import * as fs from 'fs'; import * as path from 'path'; import isEmpty from 'lodash/isEmpty'; import { jwtDecode } from 'jwt-decode'; +import { expect } from '@playwright/test'; // Path to the authentication state file export const authFile = path.join(__dirname, 'auth.json'); @@ -64,21 +65,42 @@ export async function login(page: Page) { // await page.click('button[type="submit"]'); await page.getByText('Sign in').click(); + await page.getByText(`Don't already have an account?`).click(); await page.getByRole('textbox', { name: 'What is your email address?' }).fill('chad@buster.so'); await page.getByRole('textbox', { name: 'What is your email address?' }).press('Tab'); await page.getByRole('textbox', { name: 'Password' }).fill('password'); + expect(page.getByRole('textbox', { name: 'Confirm passowrd' })).not.toBeVisible(); await page.getByRole('button', { name: 'Sign in' }).click(); + console.log('Waiting for response to /auth/login'); + // Check that call to /auth/login was fired + await page.waitForResponse( + (response) => response.url().includes('/auth/login') && response.status() === 200 + ); + console.log('Response to /auth/login received'); + //expect "Invalid email or password" to not be visible + expect(page.getByText('Invalid email or password')).not.toBeVisible(); + console.log('Invalid email or password not visible'); + + await page.waitForLoadState('networkidle'); + await page.waitForLoadState('domcontentloaded'); + await page.waitForTimeout(250); + + console.log('Waiting for home page after login', page.url()); + await page.waitForURL('http://localhost:3000/app/home'); await page.waitForTimeout(350); await page.goto('http://localhost:3000/app/new-user'); await page.getByRole('button', { name: 'Get Started' }).click(); await page.getByRole('textbox', { name: 'What is your full name' }).dblclick(); await page.getByRole('textbox', { name: 'What is your full name' }).fill('Chad'); - - await page.waitForTimeout(50); + await page.waitForTimeout(20); await page.getByRole('button', { name: 'Create your account' }).click(); - await page.waitForTimeout(50); + await page.waitForTimeout(550); + await page.waitForLoadState('networkidle'); + await page.waitForLoadState('domcontentloaded'); + + console.log('Waiting for home page', page.url()); await page.waitForURL('http://localhost:3000/app/home'); // Wait for the page to be fully loaded before accessing storage diff --git a/web/playwright-tests/auth-utils/global-setup.ts b/web/playwright-tests/auth-utils/global-setup.ts index 670aa26ba..eee0eaaa7 100644 --- a/web/playwright-tests/auth-utils/global-setup.ts +++ b/web/playwright-tests/auth-utils/global-setup.ts @@ -67,7 +67,9 @@ async function globalSetup(config: FullConfig) { } } else { await login(page).catch((error) => { - throw new Error(`Error during global setup: Failed to login - ${error}`); + throw new Error( + `Error during global setup: Failed to login with no valid auth - ${error}` + ); }); } diff --git a/web/playwright-tests/dataset-list.test.ts b/web/playwright-tests/dataset-list.test.ts index 2bc697b28..ab8661bf7 100644 --- a/web/playwright-tests/dataset-list.test.ts +++ b/web/playwright-tests/dataset-list.test.ts @@ -5,6 +5,8 @@ test.describe.serial('Dataset tests', () => { test('Can navigate to a dataset chart from the dataset list', async ({ page }) => { await page.goto('http://localhost:3000/app/home'); await page.getByRole('link', { name: 'Datasets' }).click(); + //wait for url to change + await page.waitForURL((url) => url.toString().includes('datasets')); await expect( page diff --git a/web/playwright.config.ts b/web/playwright.config.ts index 4b8ab28db..bb13d906f 100644 --- a/web/playwright.config.ts +++ b/web/playwright.config.ts @@ -82,7 +82,7 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: process.env.CI ? 'make start-fast' : 'make dev', + command: process.env.PLAYWRIGHT_START_COMMAND || 'make start-fast', url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, timeout: 60 * 1000 * 6, diff --git a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisDragContainer/SelectAxisAvailableItemsList.tsx b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisDragContainer/SelectAxisAvailableItemsList.tsx index c62d70a35..0927c4d7d 100644 --- a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisDragContainer/SelectAxisAvailableItemsList.tsx +++ b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisDragContainer/SelectAxisAvailableItemsList.tsx @@ -34,6 +34,7 @@ export const AvailableItemsList: React.FC = ({ className="mb-4 h-full" ref={setNodeRef}>
0; return ( -
+