Skip to content

Commit

Permalink
[TASK] Fix functional tests for config command
Browse files Browse the repository at this point in the history
  • Loading branch information
s2b committed Sep 28, 2023
1 parent dbb3d66 commit 025fb39
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Resources/Private/ViteConfigTemplates/glob.vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const VITE_OUTPUT_PATH = 'public/_assets/vite/';
// ------------------------------------------------------

// Base URL that will be prepended to all referenced assets in dev mode
// e. g// Set this to the URL of your vite dev server,
. https://myproject.ddev.site:5173
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

// Ignored patterns to speed up globbing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "Resources/Public/Vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -24,4 +29,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -23,4 +28,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -23,4 +28,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

// Ignored patterns to speed up globbing
const VITE_PATTERN_IGNORE = ['**/node_modules/**', '**/.git/**'];

Expand All @@ -30,4 +35,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -24,4 +29,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -23,4 +28,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "Resources/Public/Vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -24,4 +29,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -24,4 +29,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -24,4 +29,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -24,4 +29,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const VITE_ENTRYPOINTS = [
// Output path for generated assets
const VITE_OUTPUT_PATH = "public/_assets/vite/";

// Base URL that will be prepended to all referenced assets in dev mode
// Set this to the URL of your vite dev server,
// e. g. https://myproject.ddev.site:5173
const VITE_DEV_ORIGIN = '';

const rootPath = resolve(__dirname, VITE_TYPO3_ROOT);
export default defineConfig({
base: '',
Expand All @@ -23,4 +28,7 @@ export default defineConfig({
outDir: resolve(rootPath, VITE_OUTPUT_PATH),
},
publicDir: false,
server: {
origin: VITE_DEV_ORIGIN,
},
});
27 changes: 24 additions & 3 deletions Tests/Functional/Command/ViteConfigCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public function setUp(): void
}
}

public function tearDown(): void
{
// Delete config file from overwriteConfigFile() test
$overwriteConfigFile = self::getInstancePath() . '/vite.config.js';
if (file_exists($overwriteConfigFile)) {
unlink($overwriteConfigFile);
}
}

public static function outputConfigDataProvider(): array
{
return [
Expand Down Expand Up @@ -255,7 +264,11 @@ public function overwriteConfigFile(): void
$input = ['--outputfile' => './vite.config.js'];
$output = new BufferedOutput();
$command->run(new ArrayInput($input, $command->getDefinition()), $output);
self::assertEquals(sprintf("Vite config has been written to %s.\n", $outputFile), $output->fetch());
self::assertEquals(
sprintf("Vite config has been written to %s.\n", $outputFile),
$output->fetch(),
'Initial file can be written'
);
self::assertEquals(
$expectedFirstResult,
file_get_contents($outputFile),
Expand All @@ -268,7 +281,11 @@ public function overwriteConfigFile(): void
];
$output = new BufferedOutput();
$command->run(new ArrayInput($input, $command->getDefinition()), $output);
self::assertEquals(sprintf("Output file %s already exists. Use --force if you want to overwrite the existing file.\n", $outputFile), $output->fetch());
self::assertEquals(
sprintf("Output file %s already exists. Use --force if you want to overwrite the existing file.\n", $outputFile),
$output->fetch(),
'Overwrite attempt without force option'
);
self::assertEquals(
$expectedFirstResult,
file_get_contents($outputFile),
Expand All @@ -278,7 +295,11 @@ public function overwriteConfigFile(): void
$input['--force'] = null;
$output = new BufferedOutput();
$command->run(new ArrayInput($input, $command->getDefinition()), $output);
self::assertEquals(sprintf("Vite config has been written to %s.\n", $outputFile), $output->fetch());
self::assertEquals(
sprintf("Vite config has been written to %s.\n", $outputFile),
$output->fetch(),
'Overwrite attempt with force option'
);
self::assertEquals(
$expectedLaterResult,
file_get_contents($outputFile),
Expand Down

0 comments on commit 025fb39

Please sign in to comment.