Skip to content

Commit

Permalink
test: add experiment list test for stop row action
Browse files Browse the repository at this point in the history
This adds an experiment list test for the stop action. it also
introduces a new test fixture to allow for creating new experiments to
be cleaned up afterwards on the fly.
  • Loading branch information
ashtonG committed Oct 30, 2024
1 parent 9a30f26 commit c453c34
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
31 changes: 17 additions & 14 deletions webui/react/src/e2e/fixtures/api.project.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,25 @@ export class ApiProjectFixture extends apiFixture(ProjectsApi) {
* @param {number} id The id of the project.
*/
async deleteProject(id: number): Promise<void> {
try {
await this.api.deleteProject(id);
} catch (error) {
if (error instanceof Response && error.body) {
const bodyText = error.text();
throw new Error(
`Delete Project Request failed. Status: ${error.status} Request: ${JSON.stringify({
id,
})} Response: ${bodyText}`,
);
}
}
await expect
.poll(
async () => {
const projectResp = await this.api.deleteProject(id).catch(async function (error) {
const respBody = await streamConsumers.text(error.body);
if (error.status === 404) {
return { completed: true };
}
throw new Error(
`Delete Project Request failed. Status: ${error.status} Request: ${JSON.stringify(
id,
)} Response: ${respBody}`,
);
});
return projectResp.completed;
},
() =>
this.api
.getProject(id)
.then(() => false)
.catch((res) => res.status === 404),
{
message: `Delete Project Request failed ${JSON.stringify(id)}`,
timeout: 15_000,
Expand Down
4 changes: 2 additions & 2 deletions webui/react/src/e2e/fixtures/api.search.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ export class ApiSearchFixture extends apiFixture(InternalApi) {
entrypoint: 'echo bonjour!',
name: safeName('apisearch'),
searcher: {
max_trials: 1,
metric: 'x',
name: 'custom',
unit: 'batches',
name: 'random',
},
...config,
};
Expand Down
33 changes: 33 additions & 0 deletions webui/react/src/e2e/tests/experimentList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ test.describe('Experiment List', () => {
await waitTableStable();
await expect.soft((await row.getCellByColumnName('Name')).pwLocator).toHaveText(editedValue);
});

// await test.step('Stop', async () => {
// // what happens if the experiment is already stopped?
// });
Expand All @@ -346,6 +347,38 @@ test.describe('Experiment List', () => {
// await test.step('Hyperparameter Search', async () => {});
});

test('DataGrid Action Stop', async ({ apiSearches, newProject }) => {
const search = await apiSearches.new({}, { projectId: newProject.response.project.id });
await test.step('filter to experiment', async () => {
const tableFilter =
await projectDetailsPage.f_experimentList.tableActionBar.tableFilter.open();
await tableFilter.filterForm.filter.filterFields.columnName.selectMenuOption('ID');
await tableFilter.filterForm.filter.filterFields.operator.selectMenuOption('=');
await tableFilter.filterForm.filter.filterFields.valueNumber.pwLocator.fill(
search.id.toString(),
);

await expect(projectDetailsPage.f_experimentList.tableActionBar.count.pwLocator).toHaveText(
/^1 /,
);
await tableFilter.close();
});
await test.step('stop experiment', async () => {
const row = projectDetailsPage.f_experimentList.dataGrid.getRowByIndex(0);
await row.experimentActionDropdown.open();
await row.experimentActionDropdown.pwLocator.getByRole('menuitem', { name: 'Stop' }).click();
await expect((await row.getCellByColumnName('State')).pwLocator).toHaveText('canceled');
});
await test.step('stop menu item should be gone', async () => {
const row = projectDetailsPage.f_experimentList.dataGrid.getRowByIndex(0);
await row.experimentActionDropdown.open();
await expect(row.experimentActionDropdown.pwLocator).toBeVisible();
await expect(
row.experimentActionDropdown.pwLocator.getByRole('menuitem', { name: 'Stop' }),
).toHaveCount(0);
});
});

test('DataGrid Action Pause', async () => {
// datagrid can be slow, perhaps related to [ET-677]
projectDetailsPage._page.setDefaultTimeout(10000);
Expand Down

0 comments on commit c453c34

Please sign in to comment.