Skip to content

Commit 94336a5

Browse files
committed
test: cover reject path of settings dialogs
The backup, export-settings, and import-settings dialogs stage edits in temporary values and only persist them to settings on accept; rejecting must discard them. Only the accept paths were covered, so a regression that persisted staged edits without an accept would go unnoticed. Add a shared reject helper mirroring the existing accept helper and exercise the discard path for each dialog.
1 parent 3f7ca42 commit 94336a5

2 files changed

Lines changed: 72 additions & 3 deletions

File tree

qt/qml/io/github/mpvqc/mpvQC/App/TestHelpers.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ QtObject {
123123
root.bridge.waitForBackgroundJobs();
124124
root.testCase.wait(root.bridge.delayMs); // TODO: replace with a deterministic wait
125125
}
126+
127+
function reject(dialog: QtObject): void {
128+
dialog.rejected();
129+
dialog.close();
130+
root.bridge.waitForBackgroundJobs();
131+
root.testCase.wait(root.bridge.delayMs); // TODO: replace with a deterministic wait
132+
}
126133
}
127134

128135
readonly property var comment: QtObject {

qt/qml/io/github/mpvqc/mpvQC/App/tst_MpvqcApplicationContent_OptionsMenu.qml

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ TestCase {
8585

8686
tryVerify(() => it.settings.themeIdentifier() !== initialTheme);
8787

88-
dialog.reject();
89-
dialog.close();
90-
it.bridge.waitForBackgroundJobs();
88+
it.dialog.reject(dialog);
9189

9290
tryVerify(() => it.settings.themeIdentifier() === initialTheme);
9391
tryVerify(() => it.settings.primaryColor() === initialColor);
@@ -239,6 +237,29 @@ TestCase {
239237
tryVerify(() => it.settings.backupInterval() === newInterval);
240238
}
241239

240+
function test_backupDialog_reject_discardsSettings(): void {
241+
const control = it.makeControl();
242+
243+
const initialEnabled = it.settings.backupEnabled();
244+
const initialInterval = it.settings.backupInterval();
245+
246+
it.menu.trigger(control, "optionsMenu", "openBackupSettingsDialogMenuItem");
247+
const dialog = it.find.openedDialog(control, "backupDialog");
248+
249+
const switchRow = findChild(dialog, "backupEnabledRow");
250+
verify(switchRow, "backupEnabledRow not found");
251+
switchRow.checked = !initialEnabled;
252+
253+
const intervalRow = findChild(dialog, "backupIntervalRow");
254+
verify(intervalRow, "backupIntervalRow not found");
255+
intervalRow.value = initialInterval + 30;
256+
257+
it.dialog.reject(dialog);
258+
259+
verify(it.settings.backupEnabled() === initialEnabled, "backup enabled should be unchanged after reject");
260+
verify(it.settings.backupInterval() === initialInterval, "backup interval should be unchanged after reject");
261+
}
262+
242263
function test_exportSettingsDialog_drivesAllSettings(): void {
243264
const control = it.makeControl();
244265

@@ -276,6 +297,29 @@ TestCase {
276297
tryVerify(() => it.settings.writeHeaderSubtitles() === !initial.subtitles);
277298
}
278299

300+
function test_exportSettingsDialog_reject_discardsSettings(): void {
301+
const control = it.makeControl();
302+
303+
const initialNickname = it.settings.nickname();
304+
const initialDate = it.settings.writeHeaderDate();
305+
306+
it.menu.trigger(control, "optionsMenu", "openExportSettingsDialogMenuItem");
307+
const dialog = it.find.openedDialog(control, "exportSettingsDialog");
308+
309+
const nicknameRow = findChild(dialog, "exportNicknameRow");
310+
verify(nicknameRow, "exportNicknameRow not found");
311+
nicknameRow.input = initialNickname + "-edited";
312+
313+
const dateRow = findChild(dialog, "exportWriteDateRow");
314+
verify(dateRow, "exportWriteDateRow not found");
315+
dateRow.checked = !initialDate;
316+
317+
it.dialog.reject(dialog);
318+
319+
verify(it.settings.nickname() === initialNickname, "nickname should be unchanged after reject");
320+
verify(it.settings.writeHeaderDate() === initialDate, "write header date should be unchanged after reject");
321+
}
322+
279323
function test_importSettingsDialog_changeOption_persistsOnAccept(): void {
280324
const control = it.makeControl();
281325
const initial = it.settings.importFoundVideo();
@@ -294,6 +338,24 @@ TestCase {
294338
verify(it.settings.importFoundVideo() !== initial, "setting should differ from initial value");
295339
}
296340

341+
function test_importSettingsDialog_reject_discardsSettings(): void {
342+
const control = it.makeControl();
343+
const initial = it.settings.importFoundVideo();
344+
345+
it.menu.trigger(control, "optionsMenu", "openImportSettingsDialogMenuItem");
346+
const dialog = it.find.openedDialog(control, "importSettingsDialog");
347+
348+
const comboBox = findChild(dialog, "importFoundVideoComboBox");
349+
verify(comboBox, "importFoundVideoComboBox not found");
350+
const newIndex = comboBox.currentIndex === 0 ? comboBox.count - 1 : 0;
351+
verify(newIndex !== comboBox.currentIndex, "expected to pick a different option");
352+
comboBox.activated(newIndex);
353+
354+
it.dialog.reject(dialog);
355+
356+
verify(it.settings.importFoundVideo() === initial, "import found video should be unchanged after reject");
357+
}
358+
297359
function test_editMpvDialog_resetEditAcceptAndLinkActivation(): void {
298360
const control = it.makeControl();
299361
const sentinel = "# integration-test-mpv-marker";

0 commit comments

Comments
 (0)