#!/usr/local/cpanel/3rdparty/bin/perl -w

#                                      Copyright 2025 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

package t::medium::Cpanel::Config::ConfigObj::Driver::Xovi::META;

use cPstrict;

use Test::More tests => 5 + 1;    # +1NoWarnings  # +1logger

use Test::Cpanel::Policy;

use Test::Deep;
use Test::MockModule qw/strict/;
use Test::MockFile   qw/strict/;
use Test::NoWarnings;

use parent qw(
  Cpanel::TestObj
);

use Cpanel::Config::ConfigObj::Driver::Xovi::META ();

my $expected;
my $results;

my $mock_cid = Test::MockModule->new("Cpanel::License::CompanyID");
$mock_cid->redefine(
    get_company_id => sub {
        1;
    }
);

my $mock_feature_file = Test::MockFile->file( '/usr/local/cpanel/whostmgr/addonfeatures/xovi', '' );

my $mock_config = Test::MockFile->file( '/var/cpanel/plugins/xovi/lifecycle.jsonc', <<~ 'EOF');
{
    "install": {
        "condition": {
            "company-id": [ 1 ]
        }
    }
}
EOF

is( Cpanel::Config::ConfigObj::Driver::Xovi::META::meta_version,    1,                                          "meta_version () is correct" );
is( Cpanel::Config::ConfigObj::Driver::Xovi::META::get_driver_name, "xovi",                                     "get_driver_name () is correct" );
is( Cpanel::Config::ConfigObj::Driver::Xovi::META::config_path,     '/var/cpanel/plugins/xovi/lifecycle.jsonc', "config_path () is correct" );

$expected = {
    'is_recommended'       => 0,
    'is_spotlight_feature' => 1,
};
cmp_deeply( Cpanel::Config::ConfigObj::Driver::Xovi::META::showcase(), $expected, "showcase returns expected hash" ) or diag explain Cpanel::Config::ConfigObj::Driver::Xovi::META::showcase();

$expected = {
    'vendor' => 'WebPros International, LLC',
    'url'    => 'https://go.cpanel.net/search-engine-optimization',
    'name'   => {
        'short'  => "Search Engine Optimization for cPanel",
        'driver' => 'xovi',
        'long'   => "Search Engine Optimization for cPanel",
    },
    'since'    => 'cPanel® 11.118',
    'abstract' => "cPanel's new Search Engine Optimization feature enables users to increase their websites' visibility, track keyword performance, and identify problems that could decrease traffic. This intuitive feature requires no prior SEO experience, providing easy solutions with step-by-step explanations.",
    'version'  => '1.0',
    'readonly' => 1,
};

$results = Cpanel::Config::ConfigObj::Driver::Xovi::META::content();
cmp_deeply( $results, $expected, "content is correct" ) or diag explain $results;
1;
