gecko-dev/browser/components/backup/tests/chrome/test_backup_settings.html
kpatenio a39846bf34 Bug 1893277 - build initial UI for turning on scheduled backups. r=backup-reviewers,firefox-desktop-core-reviewers ,fluent-reviewers,mconley
backup-settings changes:
- adds a new button in the Backup section of about:preferences / about:settings
- shows the turn on dialog after pressing the button

Turn on dialog behaviour (implemented):
- pressing the cancel will close the dialog
- pressing the confirm button will set the pref browser.backup.scheduled.enabled=true and close the dialog
- pressing the passwords checkbox will show more options

Turn on dialog behaviour (not implemented):
- requiring a password for the backup (see Bug 1895981)
- modifying the save location and showing a file picker (see Bug 1895943)

Other changes:
- tests for backup-settings and the turn on dialog
- Storybook template for the turn on dialog

Lo-fi Figma designs: https://www.figma.com/design/vNbX4c0ws0L1qr0mxpKvsW/Fx-Backup?node-id=147-4558&t=PYLY0QMN1n8GR9vW-0

Differential Revision: https://phabricator.services.mozilla.com/D209769
2024-05-17 17:36:33 +00:00

78 lines
2.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tests for the BackupSettings component</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script
src="chrome://browser/content/backup/backup-settings.mjs"
type="module"
></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script>
const { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
/**
* Tests that adding a backup-settings element to the DOM causes it to
* fire a BackupUI:InitWidget event.
*/
add_task(async function test_initWidget() {
let settings = document.createElement("backup-settings");
let content = document.getElementById("content");
let sawInitWidget = BrowserTestUtils.waitForEvent(content, "BackupUI:InitWidget");
content.appendChild(settings);
await sawInitWidget;
ok(true, "Saw BackupUI:InitWidget");
settings.remove();
});
/**
* Tests that the dialog for turning on scheduled backups can be displayed
* from settings, or hidden if cancelled.
*/
add_task(async function test_turnOnScheduledBackupsDialog() {
let settings = document.getElementById("test-backup-settings");
settings.backupServiceState = {
scheduledBackupsEnabled: false,
}
await settings.updateComplete;
let turnOnButton = settings.scheduledBackupsButtonEl;
let dialog = settings.turnOnScheduledBackupsDialogEl;
ok(turnOnButton, "Button to turn on scheduled backups should be found");
ok(!dialog.open, "Dialog should not be open");
turnOnButton.click();
await settings.updateComplete;
ok(dialog?.open, "Dialog should be open");
let turnOnScheduledBackups = dialog.querySelector("turn-on-scheduled-backups");
ok(turnOnScheduledBackups, "turn-on-scheduled-backups should be found");
let cancelButton = turnOnScheduledBackups.shadowRoot.getElementById("backup-turn-on-scheduled-cancel-button");
ok(cancelButton, "Cancel button should be found");
cancelButton.click();
await settings.updateComplete;
ok(!dialog.open, "Dialog should not be open");
});
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
<backup-settings id="test-backup-settings"></backup-settings>
</div>
<pre id="test"></pre>
</body>
</html>