add playwright test for home-assistant
This commit is contained in:
parent
51cc563fe8
commit
0c64452d07
2 changed files with 60 additions and 28 deletions
|
|
@ -324,8 +324,8 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.home-assistant.preStart = lib.mkIf cfg.ldap.enable (
|
systemd.services.home-assistant.preStart =
|
||||||
let
|
(let
|
||||||
onboarding = pkgs.writeText "onboarding" ''
|
onboarding = pkgs.writeText "onboarding" ''
|
||||||
{
|
{
|
||||||
"version": 4,
|
"version": 4,
|
||||||
|
|
@ -333,24 +333,25 @@ in
|
||||||
"key": "onboarding",
|
"key": "onboarding",
|
||||||
"data": {
|
"data": {
|
||||||
"done": [
|
"done": [
|
||||||
"user",
|
${lib.optionalString cfg.ldap.enable ''"user",''}
|
||||||
"core_config"
|
"core_config",
|
||||||
|
"analytics"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
storage = "${config.services.home-assistant.configDir}";
|
storage = "${config.services.home-assistant.configDir}";
|
||||||
file = "${storage}/.storage/onboarding";
|
file = "${storage}/.storage/onboarding";
|
||||||
in
|
in ''
|
||||||
''
|
if [ ! -f ${file} ]; then
|
||||||
if ! -f ${file}; then
|
mkdir -p ''$(dirname ${file}) && cp ${onboarding} ${file}
|
||||||
mkdir -p ''$(dirname ${file}) && cp ${onboarding} ${file}
|
fi
|
||||||
fi
|
'')
|
||||||
'' + shblib.replaceSecrets {
|
+ (lib.optionalString cfg.ldap.enable (shblib.replaceSecrets {
|
||||||
userConfig = cfg.config;
|
userConfig = cfg.config;
|
||||||
resultPath = "${config.services.home-assistant.configDir}/secrets.yaml";
|
resultPath = "${config.services.home-assistant.configDir}/secrets.yaml";
|
||||||
generator = shblib.replaceSecretsGeneratorAdapter (lib.generators.toYAML {});
|
generator = shblib.replaceSecretsGeneratorAdapter (lib.generators.toYAML {});
|
||||||
});
|
}));
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass"
|
"f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass"
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
basic = { config, ... }: {
|
basic = { config, ... }: {
|
||||||
|
imports = [
|
||||||
|
testLib.baseModule
|
||||||
|
../../modules/services/home-assistant.nix
|
||||||
|
];
|
||||||
|
|
||||||
test = {
|
test = {
|
||||||
subdomain = "ha";
|
subdomain = "ha";
|
||||||
};
|
};
|
||||||
|
|
@ -33,6 +38,39 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
clientLogin = { config, ... }: {
|
||||||
|
imports = [
|
||||||
|
testLib.baseModule
|
||||||
|
testLib.clientLoginModule
|
||||||
|
];
|
||||||
|
virtualisation.memorySize = 4096;
|
||||||
|
|
||||||
|
test = {
|
||||||
|
subdomain = "ha";
|
||||||
|
};
|
||||||
|
|
||||||
|
test.login = {
|
||||||
|
startUrl = "http://${config.test.fqdn}";
|
||||||
|
testLoginWith = [
|
||||||
|
{ nextPageExpect = [
|
||||||
|
"page.get_by_role('button', name=re.compile('Create my smart home')).click()"
|
||||||
|
|
||||||
|
"expect(page.get_by_text('Create user')).to_be_visible()"
|
||||||
|
"page.get_by_label(re.compile('Name')).fill('Admin')"
|
||||||
|
"page.get_by_label(re.compile('Username')).fill('admin')"
|
||||||
|
"page.get_by_label(re.compile('Password')).fill('adminpassword')"
|
||||||
|
"page.get_by_label(re.compile('Confirm password')).fill('adminpassword')"
|
||||||
|
"page.get_by_role('button', name=re.compile('Create account')).click()"
|
||||||
|
|
||||||
|
"expect(page.get_by_text('All set')).to_be_visible()"
|
||||||
|
"page.get_by_role('button', name=re.compile('Finish')).click()"
|
||||||
|
|
||||||
|
"expect(page.get_by_text('Overview')).to_be_visible()"
|
||||||
|
]; }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
https = { config, ...}: {
|
https = { config, ...}: {
|
||||||
shb.home-assistant = {
|
shb.home-assistant = {
|
||||||
ssl = config.shb.certs.certs.selfsigned.n;
|
ssl = config.shb.certs.certs.selfsigned.n;
|
||||||
|
|
@ -107,10 +145,13 @@ in
|
||||||
basic = pkgs.testers.runNixOSTest {
|
basic = pkgs.testers.runNixOSTest {
|
||||||
name = "homeassistant_basic";
|
name = "homeassistant_basic";
|
||||||
|
|
||||||
|
nodes.client = {
|
||||||
|
imports = [
|
||||||
|
clientLogin
|
||||||
|
];
|
||||||
|
};
|
||||||
nodes.server = {
|
nodes.server = {
|
||||||
imports = [
|
imports = [
|
||||||
testLib.baseModule
|
|
||||||
../../modules/services/home-assistant.nix
|
|
||||||
basic
|
basic
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
@ -125,8 +166,6 @@ in
|
||||||
|
|
||||||
nodes.server = { config, ... }: {
|
nodes.server = { config, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
testLib.baseModule
|
|
||||||
../../modules/services/home-assistant.nix
|
|
||||||
basic
|
basic
|
||||||
(testLib.backup config.shb.home-assistant.backup)
|
(testLib.backup config.shb.home-assistant.backup)
|
||||||
];
|
];
|
||||||
|
|
@ -142,10 +181,8 @@ in
|
||||||
|
|
||||||
nodes.server = {
|
nodes.server = {
|
||||||
imports = [
|
imports = [
|
||||||
testLib.baseModule
|
|
||||||
../../modules/services/home-assistant.nix
|
|
||||||
testLib.certs
|
|
||||||
basic
|
basic
|
||||||
|
testLib.certs
|
||||||
https
|
https
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
@ -160,8 +197,6 @@ in
|
||||||
|
|
||||||
nodes.server = {
|
nodes.server = {
|
||||||
imports = [
|
imports = [
|
||||||
testLib.baseModule
|
|
||||||
../../modules/services/home-assistant.nix
|
|
||||||
basic
|
basic
|
||||||
testLib.ldap
|
testLib.ldap
|
||||||
ldap
|
ldap
|
||||||
|
|
@ -179,10 +214,8 @@ in
|
||||||
# name = "vaultwarden_sso";
|
# name = "vaultwarden_sso";
|
||||||
#
|
#
|
||||||
# nodes.server = lib.mkMerge [
|
# nodes.server = lib.mkMerge [
|
||||||
# testLib.baseModule
|
|
||||||
# ../../modules/services/home-assistant.nix
|
|
||||||
# (testLib.certs domain)
|
|
||||||
# basic
|
# basic
|
||||||
|
# (testLib.certs domain)
|
||||||
# https
|
# https
|
||||||
# ldap
|
# ldap
|
||||||
# (testLib.ldap domain pkgs')
|
# (testLib.ldap domain pkgs')
|
||||||
|
|
@ -200,8 +233,6 @@ in
|
||||||
|
|
||||||
nodes.server = {
|
nodes.server = {
|
||||||
imports = [
|
imports = [
|
||||||
testLib.baseModule
|
|
||||||
../../modules/services/home-assistant.nix
|
|
||||||
basic
|
basic
|
||||||
voice
|
voice
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue