Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: e2e add move Experiment row action test #10144

Merged
merged 10 commits into from
Oct 29, 2024
2 changes: 2 additions & 0 deletions webui/react/src/components/ExperimentMoveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const ExperimentMoveModalComponent: React.FC<Props> = ({
name="workspaceId"
rules={[{ message: 'Workspace is required', required: true }]}>
<Select
data-test="workspace"
filterOption={(input, option) =>
(option?.title?.toString() ?? '').toLowerCase().includes(input.toLowerCase())
}
Expand Down Expand Up @@ -210,6 +211,7 @@ const ExperimentMoveModalComponent: React.FC<Props> = ({
Failed: () => null, // Inform the user if this fails to load
Loaded: (loadableProjects) => (
<Select
data-test="project"
filterOption={(input, option) =>
(option?.title?.toString() ?? '').toLowerCase().includes(input.toLowerCase())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DropdownMenu } from 'e2e/models/common/hew/Dropdown';

import ExperimentEditModal from './ExperimentEditModal';
import ExperimentMoveModal from './ExperimentMoveModal';

/**
* Represents the ExperimentActionDropdown component in src/components/ExperimentActionDropdown.tsx
Expand All @@ -14,4 +15,7 @@ export class ExperimentActionDropdown extends DropdownMenu {
readonly editModal = new ExperimentEditModal({
root: this.root,
});
readonly moveModal = new ExperimentMoveModal({
root: this.root,
});
}
16 changes: 16 additions & 0 deletions webui/react/src/e2e/models/components/ExperimentMoveModal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Modal } from 'e2e/models/common/hew/Modal';
import { Select } from 'e2e/models/common/hew/Select';

/**
* Represents the ExperimentMoveModal component in src/components/ExperimentMoveModal.tsx
*/
export default class ExperimentMoveModal extends Modal {
readonly destinationWorkspace = new Select({
parent: this,
selector: '[data-test="workspace"]',
});
readonly destinationProject = new Select({
parent: this,
selector: '[data-test="project"]',
});
}
83 changes: 83 additions & 0 deletions webui/react/src/e2e/tests/experimentList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ProjectDetails } from 'e2e/models/pages/ProjectDetails';
import { detExecSync, fullPath } from 'e2e/utils/detCLI';
import { safeName } from 'e2e/utils/naming';
import { repeatWithFallback } from 'e2e/utils/polling';
import { V1Project } from 'services/api-ts-sdk';
import { ExperimentBase } from 'types';

test.describe('Experiment List', () => {
Expand Down Expand Up @@ -557,4 +558,86 @@ test.describe('Experiment List', () => {
});
});
});

test.describe('Row Actions', () => {
let destinationProject: V1Project;
let experimentId: number;

// create a new project, workspace and experiment
test.beforeAll(
async ({
backgroundApiProject,
newProject: {
response: { project },
},
}) => {
destinationProject = (
await backgroundApiProject.createProject(
project.workspaceId,
backgroundApiProject.new({ projectProps: { workspaceId: project.workspaceId } }),
)
).project;

const expId = Number(
detExecSync(
`experiment create ${fullPath('examples/tutorials/mnist_pytorch/adaptive.yaml')} --paused --project_id ${project.id}`,
).split(' ')[2],
); // returns in the format "Created experiment <exp_id>"

if (Number.isNaN(expId)) throw new Error('No experiment ID was found');

experimentId = expId;
},
);

// cleanup
test.afterAll(async ({ backgroundApiProject }) => {
if (experimentId !== undefined) {
detExecSync(`experiment kill ${experimentId}`);
detExecSync(`experiment delete ${experimentId} --y`);
}

await backgroundApiProject.deleteProject(destinationProject.id);
});

test('move experiment', async ({
newWorkspace: {
response: { workspace },
},
}) => {
if (experimentId === undefined) throw new Error('No experiment ID was found');

const newExperimentRow =
await projectDetailsPage.f_experimentList.dataGrid.getRowByColumnValue(
'ID',
experimentId.toString(),
);

const experimentActionDropdown = await newExperimentRow.experimentActionDropdown.open();

await experimentActionDropdown.menuItem('Move').pwLocator.click();
await experimentActionDropdown.moveModal.destinationWorkspace.selectMenuOption(
workspace.name,
);
await experimentActionDropdown.moveModal.destinationProject.pwLocator.waitFor({
state: 'visible',
});
await experimentActionDropdown.moveModal.destinationProject.selectMenuOption(
destinationProject.name,
);
await experimentActionDropdown.moveModal.footer.submit.pwLocator.click();
await experimentActionDropdown.moveModal.pwLocator.waitFor({ state: 'hidden' });

await newExperimentRow.pwLocator.waitFor({ state: 'hidden' });

await projectDetailsPage.gotoProject(destinationProject.id);
const grid = projectDetailsPage.f_experimentList.dataGrid;
await grid.setColumnHeight();
await grid.headRow.setColumnDefs();
const newProjectRows = await projectDetailsPage.f_experimentList.dataGrid.filterRows(() =>
Promise.resolve(true),
);
await expect(newProjectRows.length).toBe(1);
});
});
});
Loading