feat(app): open a recorded run visit from its URL
`/runs/:id/stage/:key?visit=N` now selects that stage's N-th recorded visit in the run detail Timeline, matching the web client's stage-local visit ordering. A stage key without a visit opens the latest recorded visit, an out-of-range index clamps to the last one, and a stage with no recorded visit selects only its Graph node instead of inventing a visit. Route plumbing carries the query end to end: boot seeds the router from path and query, the parser reads path plus query, and restore keeps `?` a query separator instead of percent-encoding it. That also repairs the existing `?action=decide` and `/runs?pipeline=` URLs. The Graph node click and the stage route share one sequence-ordered resolver, so both open the same latest visit.
This commit is contained in:
@@ -49,4 +49,55 @@ void main() {
|
||||
router.closeTemplates();
|
||||
expect(router.route, AppRoute.settings);
|
||||
});
|
||||
|
||||
test('the parser keeps a query and restores it as a query', () async {
|
||||
const parser = AppRouteParser();
|
||||
final route = await parser.parseRouteInformation(
|
||||
RouteInformation(uri: Uri.parse('/runs/77/stage/plan?visit=1')),
|
||||
);
|
||||
expect(route, AppRoute.run.stage(77, 'plan', visit: 1));
|
||||
|
||||
final restored = parser.restoreRouteInformation(route).uri;
|
||||
expect(restored.path, '/runs/77/stage/plan');
|
||||
expect(restored.query, 'visit=1');
|
||||
expect(restored.toString(), '/runs/77/stage/plan?visit=1');
|
||||
// A reload or Back/Forward feeds the restored location straight back in.
|
||||
expect(AppRoute.parse(restored.toString()), route);
|
||||
});
|
||||
|
||||
test('every query route survives a restore and reparse', () {
|
||||
const parser = AppRouteParser();
|
||||
for (final route in [
|
||||
AppRoute.runsForPipeline(7),
|
||||
AppRoute.run.decide(3),
|
||||
AppRoute.run.stage(3, 'plan', visit: 0),
|
||||
AppRoute.run.stage(5, 'build ✓', visit: 4),
|
||||
]) {
|
||||
final uri = parser.restoreRouteInformation(route).uri;
|
||||
expect(uri.toString(), route.path, reason: route.path);
|
||||
expect(uri.path, isNot(contains('%3F')), reason: route.path);
|
||||
expect(AppRoute.parse(uri.toString()), route, reason: route.path);
|
||||
}
|
||||
});
|
||||
|
||||
test('a web launch keeps the path and its query', () {
|
||||
final visit = routeInformationForLocation(
|
||||
Uri.parse('https://example.test/runs/7/stage/plan?visit=2'),
|
||||
);
|
||||
expect(visit.uri.toString(), '/runs/7/stage/plan?visit=2');
|
||||
expect(visit.uri.path, '/runs/7/stage/plan');
|
||||
expect(visit.uri.query, 'visit=2');
|
||||
|
||||
final decide = routeInformationForLocation(
|
||||
Uri.parse('https://example.test/runs/9?action=decide'),
|
||||
);
|
||||
expect(decide.uri.toString(), '/runs/9?action=decide');
|
||||
|
||||
expect(
|
||||
routeInformationForLocation(
|
||||
Uri.parse('https://example.test/'),
|
||||
).uri.toString(),
|
||||
'/',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user