Skip to content

Commit

Permalink
firefox: organize tests by submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
kira-bruneau committed Oct 2, 2024
1 parent 437ec62 commit 681e848
Show file tree
Hide file tree
Showing 15 changed files with 285 additions and 224 deletions.
15 changes: 10 additions & 5 deletions tests/modules/programs/firefox/firefox.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
let name = "firefox";

in builtins.mapAttrs (test: module: import module [ "programs" name ]) {
"${name}-profile-settings" = ./profile-settings.nix;
"${name}-state-version-19_09" = ./state-version-19_09.nix;
"${name}-deprecated-native-messenger" = ./deprecated-native-messenger.nix;
"${name}-duplicate-profile-ids" = ./duplicate-profile-ids.nix;
"${name}-duplicate-container-ids" = ./duplicate-container-ids.nix;
"${name}-container-id-out-of-range" = ./container-id-out-of-range.nix;
"${name}-policies" = ./policies.nix;
"${name}-profiles-bookmarks" = ./profiles/bookmarks;
"${name}-profiles-containers" = ./profiles/containers;
"${name}-profiles-containers-duplicate-ids" =
./profiles/containers/duplicate-ids.nix;
"${name}-profiles-containers-id-out-of-range" =
./profiles/containers/id-out-of-range.nix;
"${name}-profiles-duplicate-ids" = ./profiles/duplicate-ids.nix;
"${name}-profiles-search" = ./profiles/search;
"${name}-profiles-settings" = ./profiles/settings;
"${name}-state-version-19_09" = ./state-version-19_09.nix;
}
215 changes: 0 additions & 215 deletions tests/modules/programs/firefox/profile-settings.nix

This file was deleted.

84 changes: 84 additions & 0 deletions tests/modules/programs/firefox/profiles/bookmarks/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
modulePath:
{ config, lib, pkgs, ... }:

with lib;

let

cfg = getAttrFromPath modulePath config;

firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath;

in {
imports = [ firefoxMockOverlay ];

config = mkIf config.test.enableBig (setAttrByPath modulePath {
enable = true;
profiles.bookmarks = {
settings = { "general.smoothScroll" = false; };
bookmarks = [
{
toolbar = true;
bookmarks = [{
name = "Home Manager";
url = "https://wiki.nixos.org/wiki/Home_Manager";
}];
}
{
name = "wikipedia";
tags = [ "wiki" ];
keyword = "wiki";
url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
}
{
name = "kernel.org";
url = "https://www.kernel.org";
}
{
name = "Nix sites";
bookmarks = [
{
name = "homepage";
url = "https://nixos.org/";
}
{
name = "wiki";
tags = [ "wiki" "nix" ];
url = "https://wiki.nixos.org/";
}
{
name = "Nix sites";
bookmarks = [
{
name = "homepage";
url = "https://nixos.org/";
}
{
name = "wiki";
url = "https://wiki.nixos.org/";
}
];
}
];
}
];
};
} // {
nmt.script = ''
bookmarksUserJs=$(normalizeStorePaths \
home-files/${cfg.configPath}/bookmarks/user.js)
assertFileContent \
$bookmarksUserJs \
${./expected-bookmarks-user.js}
bookmarksFile="$(sed -n \
'/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \
$TESTED/home-files/${cfg.configPath}/bookmarks/user.js)"
assertFileContent \
$bookmarksFile \
${./expected-bookmarks.html}
'';
});
}
32 changes: 32 additions & 0 deletions tests/modules/programs/firefox/profiles/containers/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
modulePath:
{ config, lib, pkgs, ... }:

with lib;

let

cfg = getAttrFromPath modulePath config;

firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath;

in {
imports = [ firefoxMockOverlay ];

config = mkIf config.test.enableBig (setAttrByPath modulePath {
enable = true;
profiles.containers = {
containers = {
"shopping" = {
icon = "circle";
color = "yellow";
};
};
};
} // {
nmt.script = ''
assertFileContent \
home-files/${cfg.configPath}/containers/containers.json \
${./expected-containers.json}
'';
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let

cfg = getAttrFromPath modulePath config;

firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath;

in {
imports = [ firefoxMockOverlay ];
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"identities":[{"color":"yellow","icon":"circle","name":"shopping","public":true,"userContextId":6},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.thumbnail","public":false,"userContextId":4294967294},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.webextStorageLocal","public":false,"userContextId":4294967295}],"lastUserContextId":6,"version":4}
{"identities":[{"color":"yellow","icon":"circle","name":"shopping","public":true,"userContextId":0},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.thumbnail","public":false,"userContextId":4294967294},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.webextStorageLocal","public":false,"userContextId":4294967295}],"lastUserContextId":0,"version":4}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;

let

firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath;

in {
imports = [ firefoxMockOverlay ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let

cfg = getAttrFromPath modulePath config;

firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
firefoxMockOverlay = import ../setup-firefox-mock-overlay.nix modulePath;

in {
imports = [ firefoxMockOverlay ];
Expand Down
Loading

0 comments on commit 681e848

Please sign in to comment.