From f288411033fcd98705f7a0b1dca16a6b68c892f8 Mon Sep 17 00:00:00 2001 From: Jong Eun Lee Date: Thu, 14 Nov 2024 11:53:47 +0800 Subject: [PATCH] e2e: fix broken tests due to NEO mainlayout, Agent select and Image parsing --- e2e/agent.test.ts | 2 +- e2e/config.test.ts | 37 ++++-------------- e2e/environment.test.ts | 2 +- e2e/login.test.ts | 4 +- e2e/session-launcher.test.ts | 2 +- e2e/test-util.ts | 2 +- react/src/components/ProjectSelect.tsx | 1 - .../ResourceAllocationFormItems.tsx | 38 ++++++++++--------- react/src/components/WebUIBreadcrumb.tsx | 1 + react/src/pages/SessionLauncherPage.tsx | 12 ++++++ 10 files changed, 47 insertions(+), 54 deletions(-) diff --git a/e2e/agent.test.ts b/e2e/agent.test.ts index a6e325ef9c..dffbe52dae 100644 --- a/e2e/agent.test.ts +++ b/e2e/agent.test.ts @@ -6,7 +6,7 @@ test.beforeEach(async ({ page }) => { await loginAsAdmin(page); await page.getByRole('menuitem', { name: 'hdd Resources' }).click(); await expect( - page.getByRole('heading', { name: 'Computation Resources' }), + page.getByTestId('webui-breadcrumb').getByText('Resources'), ).toBeVisible(); }); diff --git a/e2e/config.test.ts b/e2e/config.test.ts index 768300409e..099b4178d0 100644 --- a/e2e/config.test.ts +++ b/e2e/config.test.ts @@ -44,7 +44,7 @@ test.describe.parallel('config.toml', () => { // check if the menu items are hidden await expect( - page.getByRole('menuitem', { name: 'Summary' }), + page.getByTestId('webui-breadcrumb').getByText('Summary'), ).toBeHidden(); await expect( page.getByRole('menuitem', { name: 'Sessions' }), @@ -67,7 +67,7 @@ test.describe.parallel('config.toml', () => { // check if the menu items are visible await expect( - page.getByRole('menuitem', { name: 'Summary' }), + page.getByRole('link', { name: 'Summary', exact: true }), ).toBeVisible(); await expect( page.getByRole('menuitem', { name: 'Sessions' }), @@ -97,37 +97,14 @@ test.describe.parallel('config.toml', () => { .getByRole('columnheader', { name: 'Status' }) .locator('div') .click(); - await page - .getByRole('columnheader', { name: 'Status' }) - .locator('div') - .click(); - const registryCell = await page - .locator('.ant-table-row > td:nth-child(3)') - .first(); - const registry = await registryCell.textContent(); + await page.getByRole('button', { name: 'Copy' }).first().click(); - const architectureCell = await page - .locator('.ant-table-row > td:nth-child(4)') - .first(); - const architecture = await architectureCell.textContent(); - - const namespaceCell = await page - .getByRole('cell', { name: 'community' }) - .first(); - const namespace = await namespaceCell.textContent(); - - const languageCell = await page - .getByRole('cell', { name: 'afni' }) - .first(); - const language = await languageCell.textContent(); - - const versionCell = await page - .getByRole('cell', { name: 'ubuntu18.04' }) - .first(); - const version = await versionCell.textContent(); + await context.grantPermissions(['clipboard-read', 'clipboard-write']); - const uninstalledImageString = `${registry}/${namespace}/${language}:${version}@${architecture}`; + const uninstalledImageString = await ( + await page.evaluateHandle(() => navigator.clipboard.readText()) + ).jsonValue(); await page.goto(webuiEndpoint); await page.getByLabel('power_settings_new').click(); diff --git a/e2e/environment.test.ts b/e2e/environment.test.ts index 056ee4ffff..5ba13cfac0 100644 --- a/e2e/environment.test.ts +++ b/e2e/environment.test.ts @@ -100,7 +100,7 @@ test.describe('environment ', () => { // Verify image is modified const resourceLimitControlIndex = await findColumnIndex( imageListTable, - 'Resource Limit', + 'Resource limit', ); const resource = await firstRow .locator('.ant-table-cell') diff --git a/e2e/login.test.ts b/e2e/login.test.ts index a78abc2399..2fde4efd25 100644 --- a/e2e/login.test.ts +++ b/e2e/login.test.ts @@ -20,6 +20,8 @@ test.describe('Login using the admin account', () => { test('should redirect to the Summary', async ({ page }) => { await expect(page).toHaveURL(/\/summary/); - await expect(page.getByRole('heading', { name: 'Summary' })).toBeVisible(); + await expect( + page.getByTestId('webui-breadcrumb').getByText('Summary'), + ).toBeVisible(); }); }); diff --git a/e2e/session-launcher.test.ts b/e2e/session-launcher.test.ts index 04a464f90f..b59681f334 100644 --- a/e2e/session-launcher.test.ts +++ b/e2e/session-launcher.test.ts @@ -14,7 +14,7 @@ test.describe('NEO Sessions Launcher', () => { await loginAsUser(page); }); - const sessionName = 'e2e-test-session'; + const sessionName = 'e2e-test-session' + new Date().getTime(); test('User can create session in NEO', async ({ page }) => { await createSession(page, sessionName); await deleteSession(page, sessionName); diff --git a/e2e/test-util.ts b/e2e/test-util.ts index 57e19ca808..22ce9e5498 100644 --- a/e2e/test-util.ts +++ b/e2e/test-util.ts @@ -226,7 +226,7 @@ export async function createSession(page: Page, sessionName: string) { await page .getByRole('heading', { name: 'App close' }) .getByLabel('close') - .click({ timeout: 15000 }); + .click({ timeout: 30000 }); // Verify that a cell exists to display the session name const session = page diff --git a/react/src/components/ProjectSelect.tsx b/react/src/components/ProjectSelect.tsx index 7895a66554..d7b233a8a4 100644 --- a/react/src/components/ProjectSelect.tsx +++ b/react/src/components/ProjectSelect.tsx @@ -3,7 +3,6 @@ import { useCurrentUserInfo, useCurrentUserRole } from '../hooks/backendai'; import useControllableState from '../hooks/useControllableState'; import BAISelect, { BAISelectProps } from './BAISelect'; import { ProjectSelectorQuery } from './__generated__/ProjectSelectorQuery.graphql'; -import { SelectProps } from 'antd'; import graphql from 'babel-plugin-relay/macro'; import _ from 'lodash'; import React from 'react'; diff --git a/react/src/components/ResourceAllocationFormItems.tsx b/react/src/components/ResourceAllocationFormItems.tsx index 09d0bd9747..ccdd2293ba 100644 --- a/react/src/components/ResourceAllocationFormItems.tsx +++ b/react/src/components/ResourceAllocationFormItems.tsx @@ -40,7 +40,7 @@ import { theme, } from 'antd'; import _ from 'lodash'; -import React, { useEffect, useMemo, useTransition } from 'react'; +import React, { Suspense, useEffect, useMemo, useTransition } from 'react'; import { Trans, useTranslation } from 'react-i18next'; export const AUTOMATIC_DEFAULT_SHMEM = '64m'; @@ -1213,23 +1213,25 @@ const ResourceAllocationFormItems: React.FC< tooltip={} > - - {baiClient.supports('agent-select') && ( - { - if (value !== 'auto') { - form.setFieldsValue({ - cluster_mode: 'single-node', - cluster_size: 1, - }); - } - // TODO: set cluster mode to single node and cluster size to 1 when agent value is not "auto" - }} - > - )} - + + + {baiClient.supports('agent-select') && ( + { + if (value !== 'auto') { + form.setFieldsValue({ + cluster_mode: 'single-node', + cluster_size: 1, + }); + } + // TODO: set cluster mode to single node and cluster size to 1 when agent value is not "auto" + }} + > + )} + +