feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
This commit is contained in:
209
modules/system/tests/console/asset/npm/NpmInstallTest.php
Normal file
209
modules/system/tests/console/asset/npm/NpmInstallTest.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace System\Tests\Console\Asset\Npm;
|
||||
|
||||
use System\Classes\Asset\PackageManager;
|
||||
use System\Tests\Bootstrap\TestCase;
|
||||
use System\Tests\Console\Asset\NpmTestTrait;
|
||||
use Winter\Storm\Support\Facades\File;
|
||||
|
||||
class NpmInstallTest extends TestCase
|
||||
{
|
||||
use NpmTestTrait;
|
||||
|
||||
protected string $themePath;
|
||||
protected string $jsonPath;
|
||||
protected string $lockPath;
|
||||
protected string $backupPath;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!File::exists(base_path('node_modules'))) {
|
||||
$this->markTestSkipped('This test requires node_modules to be installed');
|
||||
}
|
||||
|
||||
// Define some helpful paths
|
||||
$this->themePath = base_path('modules/system/tests/fixtures/themes/npmtest');
|
||||
$this->jsonPath = $this->themePath . '/package.json';
|
||||
$this->lockPath = $this->themePath . '/package-lock.json';
|
||||
$this->backupPath = $this->themePath . '/package.backup.json';
|
||||
|
||||
// Add our testing theme because it won't be auto discovered
|
||||
PackageManager::instance()->registerPackage(
|
||||
'theme-npmtest',
|
||||
$this->themePath . '/vite.config.mjs',
|
||||
'vite'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ability to install a single npm package via artisan
|
||||
*/
|
||||
public function testNpmInstallSingle(): void
|
||||
{
|
||||
// Validate the package Json does not have dependencies
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayNotHasKey('dependencies', $packageJson);
|
||||
|
||||
// Validate node_modules not found
|
||||
$this->assertDirectoryDoesNotExist($this->themePath . '/node_modules');
|
||||
$this->assertFileNotExists($this->lockPath);
|
||||
|
||||
$this->withPackageJsonRestore(function () {
|
||||
// Run npm install for a single non-dev package
|
||||
$this->artisan('npm:install', [
|
||||
'package' => 'theme-npmtest',
|
||||
'npmArgs' => ['is-odd'],
|
||||
'--disable-tty' => true
|
||||
])
|
||||
->assertExitCode(0);
|
||||
|
||||
// Validate lock file was generated successfully
|
||||
$this->assertFileExists($this->lockPath);
|
||||
|
||||
// Validate the contents of package.json
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayHasKey('dependencies', $packageJson);
|
||||
$this->assertArrayHasKey('is-odd', $packageJson['dependencies']);
|
||||
|
||||
// Validate that node_modules paths exist
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules');
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules/is-odd');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ability to install multiple npm packages via artisan
|
||||
*/
|
||||
public function testNpmInstallMultiple(): void
|
||||
{
|
||||
// Validate the package Json does not have dependencies
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayNotHasKey('dependencies', $packageJson);
|
||||
|
||||
// Validate node_modules not found
|
||||
$this->assertDirectoryDoesNotExist($this->themePath . '/node_modules');
|
||||
$this->assertFileNotExists($this->lockPath);
|
||||
|
||||
$this->withPackageJsonRestore(function () {
|
||||
// Run npm install for multiple non-dev packages
|
||||
$this->artisan('npm:install', [
|
||||
'package' => 'theme-npmtest',
|
||||
'npmArgs' => ['is-odd', 'is-even'],
|
||||
'--disable-tty' => true
|
||||
])
|
||||
->assertExitCode(0);
|
||||
|
||||
// Validate lock file was generated successfully
|
||||
$this->assertFileExists($this->lockPath);
|
||||
|
||||
// Validate the contents of package.json
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayHasKey('dependencies', $packageJson);
|
||||
$this->assertArrayHasKey('is-odd', $packageJson['dependencies']);
|
||||
$this->assertArrayHasKey('is-even', $packageJson['dependencies']);
|
||||
|
||||
// Validate that node_modules paths exist
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules');
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules/is-odd');
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules/is-even');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the ability to install a single dev npm package via artisan
|
||||
*/
|
||||
public function testNpmInstallSingleDev(): void
|
||||
{
|
||||
// Validate the package Json does not have dependencies
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayNotHasKey('devDependencies', $packageJson);
|
||||
|
||||
// Validate node_modules not found
|
||||
$this->assertDirectoryDoesNotExist($this->themePath . '/node_modules');
|
||||
$this->assertFileNotExists($this->lockPath);
|
||||
|
||||
$this->withPackageJsonRestore(function () {
|
||||
// Run npm install for a single dev package
|
||||
$this->artisan('npm:install', [
|
||||
'package' => 'theme-npmtest',
|
||||
'npmArgs' => ['is-odd'],
|
||||
'--dev' => true,
|
||||
'--disable-tty' => true
|
||||
])
|
||||
->assertExitCode(0);
|
||||
|
||||
// Validate lock file was generated successfully
|
||||
$this->assertFileExists($this->lockPath);
|
||||
|
||||
// Validate the contents of package.json
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayHasKey('devDependencies', $packageJson);
|
||||
$this->assertArrayHasKey('is-odd', $packageJson['devDependencies']);
|
||||
|
||||
// Validate that node_modules paths exist
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules');
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules/is-odd');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ability to install multiple dev npm packages via artisan
|
||||
*/
|
||||
public function testNpmInstallMultipleDev(): void
|
||||
{
|
||||
// Validate the package Json does not have dependencies
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayNotHasKey('devDependencies', $packageJson);
|
||||
|
||||
// Validate node_modules not found
|
||||
$this->assertDirectoryDoesNotExist($this->themePath . '/node_modules');
|
||||
$this->assertFileNotExists($this->lockPath);
|
||||
|
||||
$this->withPackageJsonRestore(function () {
|
||||
// Run npm install for multiple dev packages
|
||||
$this->artisan('npm:install', [
|
||||
'package' => 'theme-npmtest',
|
||||
'npmArgs' => ['is-odd', 'is-even'],
|
||||
'--dev' => true,
|
||||
'--disable-tty' => true
|
||||
])
|
||||
->assertExitCode(0);
|
||||
|
||||
// Validate lock file was generated successfully
|
||||
$this->assertFileExists($this->lockPath);
|
||||
|
||||
// Validate the contents of package.json
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayHasKey('devDependencies', $packageJson);
|
||||
$this->assertArrayHasKey('is-odd', $packageJson['devDependencies']);
|
||||
$this->assertArrayHasKey('is-even', $packageJson['devDependencies']);
|
||||
|
||||
// Validate that node_modules paths exist
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules');
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules/is-odd');
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules/is-even');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup the test theme
|
||||
*/
|
||||
public function tearDown(): void
|
||||
{
|
||||
if (File::isDirectory($this->themePath . '/node_modules')) {
|
||||
File::deleteDirectory($this->themePath . '/node_modules');
|
||||
}
|
||||
|
||||
foreach ([$this->backupPath, $this->lockPath] as $path) {
|
||||
if (File::exists($path)) {
|
||||
File::delete($path);
|
||||
}
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
55
modules/system/tests/console/asset/npm/NpmRunTest.php
Normal file
55
modules/system/tests/console/asset/npm/NpmRunTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace System\Tests\Console\Asset\Npm;
|
||||
|
||||
use System\Classes\Asset\PackageManager;
|
||||
use System\Tests\Bootstrap\TestCase;
|
||||
use Winter\Storm\Support\Facades\File;
|
||||
|
||||
class NpmRunTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!File::exists(base_path('node_modules'))) {
|
||||
$this->markTestSkipped('This test requires node_modules to be installed');
|
||||
}
|
||||
|
||||
// Add our testing theme because it won't be auto discovered
|
||||
PackageManager::instance()->registerPackage(
|
||||
'theme-npmtest',
|
||||
base_path('modules/system/tests/fixtures/themes/npmtest/vite.config.mjs'),
|
||||
'vite'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ability to run a npm script via artisan
|
||||
*/
|
||||
public function testNpmRunScript(): void
|
||||
{
|
||||
$this->artisan('npm:run', [
|
||||
'package' => 'theme-npmtest',
|
||||
'script' => 'testScript',
|
||||
'--disable-tty' => true
|
||||
])
|
||||
->expectsOutputToContain('> echo "Winter says $((1+2))"')
|
||||
->expectsOutputToContain('Winter says 3')
|
||||
->assertExitCode(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the error handling of a missing script
|
||||
*/
|
||||
public function testNpmRunScriptFailed(): void
|
||||
{
|
||||
$this->artisan('npm:run', [
|
||||
'package' => 'theme-npmtest',
|
||||
'script' => 'testMissingScript',
|
||||
'--disable-tty' => true
|
||||
])
|
||||
->expectsOutputToContain('Script "testMissingScript" is not defined in package "theme-npmtest"')
|
||||
->assertExitCode(1);
|
||||
}
|
||||
}
|
||||
104
modules/system/tests/console/asset/npm/NpmUpdateTest.php
Normal file
104
modules/system/tests/console/asset/npm/NpmUpdateTest.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace System\tests\console\asset\npm;
|
||||
|
||||
use System\Classes\Asset\PackageManager;
|
||||
use System\Tests\Bootstrap\TestCase;
|
||||
use System\Tests\Console\Asset\NpmTestTrait;
|
||||
use Winter\Storm\Support\Facades\File;
|
||||
|
||||
class NpmUpdateTest extends TestCase
|
||||
{
|
||||
use NpmTestTrait;
|
||||
|
||||
protected string $themePath;
|
||||
protected string $jsonPath;
|
||||
protected string $lockPath;
|
||||
protected string $backupPath;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!File::exists(base_path('node_modules'))) {
|
||||
$this->markTestSkipped('This test requires node_modules to be installed');
|
||||
}
|
||||
|
||||
// Define some helpful paths
|
||||
$this->themePath = base_path('modules/system/tests/fixtures/themes/npmtest');
|
||||
$this->jsonPath = $this->themePath . '/package.json';
|
||||
$this->lockPath = $this->themePath . '/package-lock.json';
|
||||
$this->backupPath = $this->themePath . '/package.backup.json';
|
||||
|
||||
// Add our testing theme because it won't be auto discovered
|
||||
PackageManager::instance()->registerPackage(
|
||||
'theme-npmtest',
|
||||
$this->themePath . '/vite.config.mjs',
|
||||
'vite'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ability to install a single npm package via artisan
|
||||
*/
|
||||
public function testNpmUpdate(): void
|
||||
{
|
||||
// Validate the package Json does not have dependencies
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$this->assertArrayNotHasKey('dependencies', $packageJson);
|
||||
|
||||
// Validate node_modules not found
|
||||
$this->assertDirectoryDoesNotExist($this->themePath . '/node_modules');
|
||||
$this->assertFileNotExists($this->lockPath);
|
||||
|
||||
$this->withPackageJsonRestore(function () {
|
||||
// Update the contents of package.json to include a package at an old patch
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
$packageJson['dependencies'] = [
|
||||
'is-odd' => '^3.0.0'
|
||||
];
|
||||
File::put($this->jsonPath, json_encode($packageJson, JSON_PRETTY_PRINT));
|
||||
|
||||
// Run npm update
|
||||
$this->artisan('npm:update', [
|
||||
'package' => 'theme-npmtest',
|
||||
'--save' => true,
|
||||
'--disable-tty' => true
|
||||
])
|
||||
->assertExitCode(0);
|
||||
|
||||
// Validate lock file was generated successfully
|
||||
$this->assertFileExists($this->lockPath);
|
||||
|
||||
// Get the new contents of package.json
|
||||
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
|
||||
|
||||
// Validate that the package.json contents does not match the old patch value we added above
|
||||
$this->assertArrayHasKey('dependencies', $packageJson);
|
||||
$this->assertArrayHasKey('is-odd', $packageJson['dependencies']);
|
||||
$this->assertNotEquals('^3.0.0', $packageJson['dependencies']['is-odd']);
|
||||
|
||||
// Validate that node_modules paths exist
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules');
|
||||
$this->assertDirectoryExists($this->themePath . '/node_modules/is-odd');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup the test theme
|
||||
*/
|
||||
public function tearDown(): void
|
||||
{
|
||||
if (File::isDirectory($this->themePath . '/node_modules')) {
|
||||
File::deleteDirectory($this->themePath . '/node_modules');
|
||||
}
|
||||
|
||||
foreach ([$this->backupPath, $this->lockPath] as $path) {
|
||||
if (File::exists($path)) {
|
||||
File::delete($path);
|
||||
}
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user