Skip to content

Commit

Permalink
e2e: fix broken tests due to NEO mainlayout, Agent select and Image p…
Browse files Browse the repository at this point in the history
…arsing
  • Loading branch information
yomybaby committed Nov 19, 2024
1 parent 07b7970 commit fa64aa7
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 52 deletions.
2 changes: 1 addition & 1 deletion e2e/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
37 changes: 7 additions & 30 deletions e2e/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }),
Expand All @@ -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' }),
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion e2e/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion e2e/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
2 changes: 1 addition & 1 deletion e2e/test-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 20 additions & 18 deletions react/src/components/ResourceAllocationFormItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1213,23 +1213,25 @@ const ResourceAllocationFormItems: React.FC<
tooltip={<Trans i18nKey={'session.launcher.DescSelectAgent'} />}
>
<Flex gap={'xs'}>
<Form.Item required noStyle style={{ flex: 1 }} name="agent">
{baiClient.supports('agent-select') && (
<AgentSelect
resourceGroup={currentResourceGroup}
fetchKey={agentFetchKey}
onChange={(value, option) => {
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"
}}
></AgentSelect>
)}
</Form.Item>
<Suspense>
<Form.Item required noStyle style={{ flex: 1 }} name="agent">
{baiClient.supports('agent-select') && (
<AgentSelect
resourceGroup={currentResourceGroup}
fetchKey={agentFetchKey}
onChange={(value, option) => {
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"
}}
></AgentSelect>
)}
</Form.Item>
</Suspense>
<Form.Item noStyle>
<Button
loading={isPendingAgentList}
Expand Down
1 change: 1 addition & 0 deletions react/src/components/WebUIBreadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const WebUIBreadcrumb: React.FC<WebUIBreadcrumbProps> = (props) => {
} as React.CSSProperties,
props.style,
)}
data-testid="webui-breadcrumb"
>
<Breadcrumb
style={{
Expand Down
12 changes: 12 additions & 0 deletions react/src/pages/SessionLauncherPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,18 @@ const SessionLauncherPage = () => {
}>
}
/>
<Typography.Text
style={{ color: token.colorPrimary }}
copyable={{
text:
getImageFullName(
form.getFieldValue('environments')
?.image,
) ||
form.getFieldValue('environments')
?.version,
}}
/>
</>
)}
</Flex>
Expand Down

0 comments on commit fa64aa7

Please sign in to comment.