fix(scenarios): preselect default environment when opening run modal
- choose the scenario's default environment when the run modal opens on the scenario detail page, instead of in a load effect that raced with loading the scenario and could fall back to the first environment - set the run to a final status directly in the status filter test so the scheduler can't change it mid-test - bump version to 1.19.2
This commit is contained in:
1 parent
68415f805b
commit
e586ab9bd9
5 files changed
+47
-39
No files matched your search
@@ -2,6 +2,15 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 1.19.2 - 2026-09-30
|
||||
|
||||
Changes since 1.19.1:
|
||||
|
||||
### Fixed
|
||||
|
||||
- Running a scenario from its detail page could preselect the first environment in the list instead of the scenario's default environment, depending on whether the environment list or the scenario loaded first. The default environment is now chosen when the run modal opens.
|
||||
- Made the run status filter test deterministic; it could fail when the scheduler picked up the test's pending run mid-test.
|
||||
|
||||
## 1.19.1 - 2026-09-30
|
||||
|
||||
Changes since 1.19.0:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useState, useCallback, SubmitEvent } from 'react';
|
||||
import { useEffect, useState, useCallback, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
@@ -85,7 +85,6 @@ export function ScenarioDetailPage() {
|
||||
const traceMode = traceModeOverride ?? runDefaults?.traceMode ?? 'off';
|
||||
const [envs, setEnvs] = useState<Environment[]>([]);
|
||||
const [selectedEnvId, setSelectedEnvId] = useState('');
|
||||
const envInitRef = useRef(false);
|
||||
const [pendingDelete, setPendingDelete] = useState<
|
||||
{ type: 'scenario' } | { type: 'step'; id: string } | { type: 'credential'; id: string } | null
|
||||
>(null);
|
||||
@@ -144,14 +143,23 @@ export function ScenarioDetailPage() {
|
||||
.catch(() => {});
|
||||
}, [id, loadFiles]);
|
||||
|
||||
// Default selected env to scenario's linked environment (or first env) once both are loaded
|
||||
useEffect(() => {
|
||||
if (envInitRef.current || envs.length === 0) return;
|
||||
envInitRef.current = true;
|
||||
const openRunModal = () => {
|
||||
// Preselect the scenario's default environment (or the first one) when the
|
||||
// modal opens: by then both are loaded, and it follows default env edits
|
||||
const preferred = scenario?.environmentId ?? null;
|
||||
const exists = preferred ? envs.some((e) => e.id === preferred) : false;
|
||||
setSelectedEnvId(exists ? preferred! : envs[0].id);
|
||||
}, [scenario, envs]);
|
||||
setSelectedEnvId(exists ? preferred! : (envs[0]?.id ?? ''));
|
||||
setTraceModeOverride(null);
|
||||
setRunVersion(null);
|
||||
setRunVersions([]);
|
||||
if (id) {
|
||||
scenarios
|
||||
.versions(id)
|
||||
.then(setRunVersions)
|
||||
.catch(() => undefined);
|
||||
}
|
||||
setRunModalOpen(true);
|
||||
};
|
||||
|
||||
const reloadScenario = async () => {
|
||||
if (!id) return;
|
||||
@@ -470,21 +478,7 @@ export function ScenarioDetailPage() {
|
||||
/>
|
||||
{scenario && (
|
||||
<div className={styles.toolbarActions}>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setTraceModeOverride(null);
|
||||
setRunVersion(null);
|
||||
setRunVersions([]);
|
||||
if (id) {
|
||||
scenarios
|
||||
.versions(id)
|
||||
.then(setRunVersions)
|
||||
.catch(() => undefined);
|
||||
}
|
||||
setRunModalOpen(true);
|
||||
}}
|
||||
>
|
||||
<Button size="sm" onClick={openRunModal}>
|
||||
<Play size={14} />
|
||||
{t('scenarios.action_run')}
|
||||
</Button>
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "liqa",
|
||||
"version": "1.19.1",
|
||||
"version": "1.19.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "liqa",
|
||||
"version": "1.19.1",
|
||||
"version": "1.19.2",
|
||||
"workspaces": [
|
||||
"server",
|
||||
"client"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "liqa",
|
||||
"version": "1.19.1",
|
||||
"version": "1.19.2",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=24"
|
||||
|
||||
@@ -550,22 +550,27 @@ describe("ScenarioController", () => {
|
||||
it("filters by status", async () => {
|
||||
const sc = await createScenario();
|
||||
await createStep(sc.id, { order: 0 });
|
||||
await createRun(sc.id);
|
||||
const run = await createRun(sc.id);
|
||||
// Put the run in a final state directly: a pending run would be picked
|
||||
// up by the scheduler (@Interval) and could change status mid-test
|
||||
await app
|
||||
.get(DataSource)
|
||||
.query(`UPDATE scenario_runs SET status = 'fail' WHERE id = ?`, [
|
||||
run.id,
|
||||
]);
|
||||
|
||||
const pendingRes = await request(app.getHttpServer())
|
||||
.get(`/scenarios/${sc.id}/runs?status=pending`)
|
||||
const failRes = await request(app.getHttpServer())
|
||||
.get(`/scenarios/${sc.id}/runs?status=fail`)
|
||||
.expect(200);
|
||||
expect(failRes.body.total).toBe(1);
|
||||
expect(failRes.body.data[0].id).toBe(run.id);
|
||||
|
||||
expect(pendingRes.body.total).toBeGreaterThanOrEqual(1);
|
||||
pendingRes.body.data.forEach((r: { status: string }) =>
|
||||
expect(r.status).toBe("pending"),
|
||||
);
|
||||
|
||||
const passRes = await request(app.getHttpServer())
|
||||
.get(`/scenarios/${sc.id}/runs?status=pass`)
|
||||
.expect(200);
|
||||
|
||||
expect(passRes.body.total).toBe(0);
|
||||
for (const status of ["pending", "pass"]) {
|
||||
const res = await request(app.getHttpServer())
|
||||
.get(`/scenarios/${sc.id}/runs?status=${status}`)
|
||||
.expect(200);
|
||||
expect(res.body.total).toBe(0);
|
||||
}
|
||||
});
|
||||
|
||||
it("returns 400 for invalid status filter", async () => {
|
||||
|
||||
Reference in new issue
Block a user