diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 15a1ee1320..5d6b14da3b 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1081,10 +1081,11 @@ fn selecting_an_item_keeps_the_direct_selected_anchors_of_others() { s.execute("select.add", &json!({"ids": [b.0]})).unwrap(); let anchors = s.active().unwrap().selection.anchors.clone(); assert!(anchors.contains_key(&a)); - log(&mut s, "app.activeDocument.pageItems[1].selected = false;"); + // Lists start with the topmost object, so `b` is `pageItems[0]`. + log(&mut s, "app.activeDocument.pageItems[0].selected = false;"); let sel = &s.active().unwrap().selection; assert_eq!((sel.objects.clone(), sel.anchors.clone()), (vec![a], anchors.clone())); - log(&mut s, "app.activeDocument.pageItems[1].selected = true;"); + log(&mut s, "app.activeDocument.pageItems[0].selected = true;"); let sel = &s.active().unwrap().selection; assert_eq!((sel.objects.clone(), sel.anchors.get(&a)), (vec![a, b], anchors.get(&a))); } @@ -1506,7 +1507,13 @@ fn document_preset_applies_only_its_given_fields() { assert_eq!(s.documents().len(), 2, "a refused preset makes no document"); // A saved preset with the built-in preset's name does not make the refused settings fit. s.execute("file.newPresets.save", &json!({"name": "Letter", "artboardLayout": "column"})).unwrap(); - let e = failure(&mut s, "var p = new DocumentPreset(); p.width = 1000000; p.numArtboards = 5; app.documents.addDocument('Print', p);"); + // With the layout unset, the built-in preset puts the five 1,000,000 pt artboards in one row, + // which does not fit, while the saved preset would put them in one column. + let e = failure( + &mut s, + "var p = new DocumentPreset(); p.width = 1000000; p.numArtboards = 5;\ + p.artboardLayout = undefined; p.artboardRowsOrCols = undefined; app.documents.addDocument('Print', p);", + ); assert!(e.contains("don't fit"), "{e}"); assert_eq!(s.documents().len(), 2, "settings the built-in preset refuses make no document"); } @@ -2181,7 +2188,7 @@ fn page_items_report_their_available_members_as_their_own() { vc.log([p.hasOwnProperty('opacity'), p.hasOwnProperty('typename'), p.hasOwnProperty('duplicate'),\ Object.prototype.hasOwnProperty.call(p, 'name'), p.propertyIsEnumerable('opacity'), d.hasOwnProperty('selection'),\ app.hasOwnProperty('activeDocument')]);\ - vc.log([p.hasOwnProperty('isIsolated'), p.hasOwnProperty('rotate'), d.hasOwnProperty('layers'),\ + vc.log([p.hasOwnProperty('isIsolated'), p.hasOwnProperty('transform'), d.hasOwnProperty('layers'),\ p.hasOwnProperty('nosuch'), p.hasOwnProperty('hasOwnProperty'), p.hasOwnProperty('constructor')]);\ vc.log([keys.indexOf('opacity') >= 0, keys.indexOf('typename') >= 0, keys.indexOf('duplicate'), keys.indexOf('isIsolated')]);", ); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index fe02779654..ddf2b6188f 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -26,12 +26,13 @@ fn rect(s: &mut Session, x: f64, y: f64, w: f64, h: f64) -> NodeId { NodeId(s.execute("shape.rectangle", &json!({"x": x, "y": y, "width": w, "height": h})).unwrap()["id"].as_u64().unwrap()) } -/// A 400 × 300 pt document with two rectangles. +/// A 400 × 300 pt document with two rectangles, `a` above `b`. Lists start with the topmost +/// object, so `a` is `pathItems[0]` and `b` is `pathItems[1]`. fn doc() -> (Session, NodeId, NodeId) { let mut s = Session::new(); s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); - let a = rect(&mut s, 10.0, 20.0, 30.0, 40.0); let b = rect(&mut s, 100.0, 100.0, 50.0, 50.0); + let a = rect(&mut s, 10.0, 20.0, 30.0, 40.0); s.execute("select.none", &json!({})).unwrap(); (s, a, b) } @@ -880,7 +881,8 @@ fn locked_paths_and_wrong_objects_are_refused() { } assert_eq!(art(&s), before); s.execute("text.create", &json!({"x": 10, "y": 250, "text": "hi"})).unwrap(); - let e = failure(&mut s, "var t = app.activeDocument.pageItems[2]; Object.getOwnPropertyDescriptor(PathItem.prototype, 'closed').get.call(t);"); + // The text is the topmost object, and lists start with the topmost object. + let e = failure(&mut s, "var t = app.activeDocument.pageItems[0]; Object.getOwnPropertyDescriptor(PathItem.prototype, 'closed').get.call(t);"); assert!(e.contains("not a PathItem"), "{e}"); let e = failure(&mut s, "Object.getOwnPropertyDescriptor(PathPoint.prototype, 'anchor').get.call({});"); assert!(e.contains("not a PathPoint"), "{e}");