Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions core/components/minishop3/controllers/mgr/help.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,12 @@ public function getLanguageTopics()
*/
public function loadCustomCssJs()
{
// Vue CSS
// Config before Vue modules so mount sees ms3.config (#553).
$this->addVueConfig($this->ms3->config);

$this->addCss($this->ms3->config['assetsUrl'] . 'css/mgr/vue-dist/primeicons.min.css');
$this->addCss($this->ms3->config['assetsUrl'] . 'css/mgr/vue-dist/help.min.css');

// Vue module
$this->addVueModule($this->ms3->config['jsUrl'] . 'mgr/vue-dist/help.min.js');

// Pass config to JavaScript
$this->addHtml('<script>
ms3.config = ' . json_encode($this->ms3->config) . ';
</script>');
}

/**
Expand Down
54 changes: 54 additions & 0 deletions core/components/minishop3/tests/HelpVueEntryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* Help mgr page: Vue entry must declare `var ms3` via addVueConfig (#553).
*
* Run: php tests/HelpVueEntryTest.php
*/

declare(strict_types=1);

$fail = static function (string $message): never {
fwrite(STDERR, "FAIL: {$message}\n");
exit(1);
};

$componentRoot = dirname(__DIR__);
$repoRoot = dirname($componentRoot, 3);

$tpl = $componentRoot . '/templates/default/help.tpl';
$tplHtml = is_file($tpl) ? file_get_contents($tpl) : false;
if ($tplHtml === false || !str_contains($tplHtml, 'id="ms3-vue-help"')) {
$fail('help.tpl must contain mount #ms3-vue-help');
}

$controllerPath = $componentRoot . '/controllers/mgr/help.class.php';
$controller = file_get_contents($controllerPath);
if ($controller === false) {
$fail('cannot read help controller');
}

foreach (['help\.min\.js', 'help\.tpl', 'addVueConfig', 'getTemplateFile'] as $pattern) {
if (preg_match('#' . $pattern . '#', $controller) !== 1) {
$fail("help controller must contain /{$pattern}/");
}
}

if (preg_match('#ms3\.config\s*=#', $controller) === 1) {
$fail('help controller must not assign ms3.config without declaring ms3 (#553)');
}

$configPos = strpos($controller, 'addVueConfig');
$modulePos = strpos($controller, 'addVueModule');
if ($configPos === false || $modulePos === false || $configPos > $modulePos) {
$fail('help controller must call addVueConfig() before addVueModule()');
}

$entry = $repoRoot . '/vueManager/src/entries/help.js';
$entrySrc = is_file($entry) ? file_get_contents($entry) : false;
if ($entrySrc === false || !str_contains($entrySrc, '#ms3-vue-help')) {
$fail('help entry must mount #ms3-vue-help');
}

fwrite(STDOUT, "OK HelpVueEntryTest\n");
exit(0);