|
1 | 1 | import { Model } from "../../src"; |
2 | 2 | import { DataValidationPanel } from "../../src/components/side_panel/data_validation/data_validation_panel"; |
3 | 3 | import { UID } from "../../src/types"; |
4 | | -import { addDataValidation, updateLocale } from "../test_helpers/commands_helpers"; |
| 4 | +import { |
| 5 | + activateSheet, |
| 6 | + addDataValidation, |
| 7 | + createSheet, |
| 8 | + updateLocale, |
| 9 | +} from "../test_helpers/commands_helpers"; |
5 | 10 | import { FR_LOCALE } from "../test_helpers/constants"; |
6 | 11 | import { click, setInputValueAndTrigger, simulateClick } from "../test_helpers/dom_helper"; |
7 | 12 | import { |
@@ -270,6 +275,29 @@ describe("data validation sidePanel component", () => { |
270 | 275 | expect(getDataValidationRules(model, sheetId)).toMatchObject([{ id: "id1" }, { id: "id2" }]); |
271 | 276 | }); |
272 | 277 |
|
| 278 | + test("DV stays on original sheet when range is selected from another sheet and saved", async () => { |
| 279 | + createSheet(model, { sheetId: "sh2" }); |
| 280 | + |
| 281 | + await simulateClick(".o-dv-add"); |
| 282 | + await nextTick(); |
| 283 | + setInputValueAndTrigger(".o-selection-input input", "A1:A5"); |
| 284 | + await changeCriterionType("isValueInRange"); |
| 285 | + |
| 286 | + const rangeInput = fixture.querySelectorAll<HTMLInputElement>(".o-selection-input input")[1]; |
| 287 | + activateSheet(model, "sh2"); |
| 288 | + await setInputValueAndTrigger(rangeInput, "A1:A5"); |
| 289 | + await simulateClick(".o-dv-save"); |
| 290 | + |
| 291 | + expect(getDataValidationRules(model, sheetId)).toEqual([ |
| 292 | + { |
| 293 | + id: expect.any(String), |
| 294 | + criterion: { type: "isValueInRange", displayStyle: "arrow", values: ["A1:A5"] }, |
| 295 | + ranges: ["A1:A5"], |
| 296 | + }, |
| 297 | + ]); |
| 298 | + expect(getDataValidationRules(model, "sh2")).toHaveLength(0); |
| 299 | + }); |
| 300 | + |
273 | 301 | describe("Locale", () => { |
274 | 302 | test("Number preview is localized", async () => { |
275 | 303 | updateLocale(model, FR_LOCALE); |
|
0 commit comments