1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-30 22:21:02 +01:00

tests/firefox: add bookmark policy to profile bookmarks test

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-07-06 11:26:05 -05:00
parent 753ea0b324
commit fd9e55f5fa

View file

@ -2,6 +2,7 @@ modulePath:
{ {
config, config,
lib, lib,
pkgs,
... ...
}: }:
@ -11,12 +12,17 @@ let
firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath; firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath;
darwinPath = "Applications/${cfg.darwinAppName}.app/Contents/Resources";
in in
{ {
imports = [ firefoxMockOverlay ]; imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig ( config = lib.mkIf config.test.enableBig (
lib.setAttrByPath modulePath { {
# Required for bookmark policy to get set
home.stateVersion = "19.09";
}
// lib.setAttrByPath modulePath {
enable = true; enable = true;
profiles.bookmarks = { profiles.bookmarks = {
settings = { settings = {
@ -80,22 +86,39 @@ in
}; };
} }
// { // {
nmt.script = '' nmt.script =
bookmarksUserJs=$(normalizeStorePaths \ let
"home-files/${cfg.profilesPath}/bookmarks/user.js") libDir =
if pkgs.stdenv.hostPlatform.isDarwin then
"${cfg.finalPackage}/${darwinPath}"
else
"${cfg.finalPackage}/lib/${cfg.wrappedPackageName}";
config_file = "${libDir}/distribution/policies.json";
in
''
assertFileExists "${config_file}"
assertFileContent \ noDefaultBookmarks_actual_value="$(${lib.getExe pkgs.jq} ".policies.NoDefaultBookmarks" ${config_file})"
$bookmarksUserJs \
${./expected-bookmarks-user.js}
bookmarksFile="$(sed -n \ if [[ $noDefaultBookmarks_actual_value != "false" ]]; then
'/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \ fail "Expected '${config_file}' to set 'policies.NoDefaultBookmarks' to false"
"$TESTED/home-files/${cfg.profilesPath}/bookmarks/user.js")" fi
assertFileContent \ bookmarksUserJs=$(normalizeStorePaths \
$bookmarksFile \ "home-files/${cfg.profilesPath}/bookmarks/user.js")
${./expected-bookmarks-list.html}
''; assertFileContent \
$bookmarksUserJs \
${./expected-bookmarks-user.js}
bookmarksFile="$(sed -n \
'/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \
"$TESTED/home-files/${cfg.profilesPath}/bookmarks/user.js")"
assertFileContent \
$bookmarksFile \
${./expected-bookmarks-list.html}
'';
} }
); );
} }