forked from Cutlery/immich
		
	* feat: asset e2e with job option * feat: checkout test assets * feat: library e2e tests * fix: use node 21 in e2e * fix: tests * fix: use normalized external path * feat: more external path tests * chore: use parametrized tests * chore: remove unused test code * chore: refactor test asset path * feat: centralize test app creation * fix: correct error message for missing assets * feat: test file formats * fix: don't compare checksum * feat: build libvips * fix: install meson * fix: use immich test asset repo * feat: test nikon raw files * fix: set Z timezone * feat: test offline library files * feat: richer metadata tests * feat: e2e tests in docker * feat: e2e test with arm64 docker * fix: manual docker compose run * fix: remove metadata processor import * fix: run e2e tests in test.yml * fix: checkout e2e assets * fix: typo * fix: checkout files in app directory * fix: increase e2e memory * fix: rm submodules * fix: revert action name * test: mark file offline when external path changes * feat: rename env var to TEST_ENV * docs: new test procedures * feat: can run docker e2e tests manually if needed * chore: use new node 20.8 for e2e * chore: bump exiftool-vendored * feat: simplify test launching * fix: rename env vars to use immich_ prefix * feat: asset folder is submodule * chore: cleanup after 20.8 upgrade * fix: don't log postgres in e2e * fix: better warning about not running all tests --------- Co-authored-by: Jonathan Jogenfors <jonathan@jogenfors.se>
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { PostgreSqlContainer } from '@testcontainers/postgresql';
 | |
| import * as fs from 'fs';
 | |
| import path from 'path';
 | |
| 
 | |
| export default async () => {
 | |
|   const allTests: boolean = process.env.IMMICH_RUN_ALL_TESTS === 'true';
 | |
| 
 | |
|   if (!allTests) {
 | |
|     console.warn(
 | |
|       `\n\n
 | |
|       *** Not running all e2e tests. Run 'make test-e2e' to run all tests inside Docker (recommended)\n
 | |
|       *** or set 'IMMICH_RUN_ALL_TESTS=true' to run all tests(requires dependencies to be installed)\n`,
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   let IMMICH_TEST_ASSET_PATH: string = '';
 | |
| 
 | |
|   if (process.env.IMMICH_TEST_ASSET_PATH === undefined) {
 | |
|     IMMICH_TEST_ASSET_PATH = path.normalize(`${__dirname}/../assets/`);
 | |
|     process.env.IMMICH_TEST_ASSET_PATH = IMMICH_TEST_ASSET_PATH;
 | |
|   } else {
 | |
|     IMMICH_TEST_ASSET_PATH = process.env.IMMICH_TEST_ASSET_PATH;
 | |
|   }
 | |
| 
 | |
|   const directoryExists = async (dirPath: string) =>
 | |
|     await fs.promises
 | |
|       .access(dirPath)
 | |
|       .then(() => true)
 | |
|       .catch(() => false);
 | |
| 
 | |
|   if (!(await directoryExists(`${IMMICH_TEST_ASSET_PATH}/albums`))) {
 | |
|     throw new Error(
 | |
|       `Test assets not found. Please checkout https://github.com/immich-app/test-assets into ${IMMICH_TEST_ASSET_PATH} before testing`,
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   if (process.env.DB_HOSTNAME === undefined) {
 | |
|     // DB hostname not set which likely means we're not running e2e through docker compose. Start a local postgres container.
 | |
|     const pg = await new PostgreSqlContainer('postgres')
 | |
|       .withExposedPorts(5432)
 | |
|       .withDatabase('immich')
 | |
|       .withUsername('postgres')
 | |
|       .withPassword('postgres')
 | |
|       .withReuse()
 | |
|       .start();
 | |
| 
 | |
|     process.env.DB_URL = pg.getConnectionUri();
 | |
|   }
 | |
| 
 | |
|   process.env.NODE_ENV = 'development';
 | |
|   process.env.TYPESENSE_ENABLED = 'false';
 | |
|   process.env.IMMICH_MACHINE_LEARNING_ENABLED = 'false';
 | |
|   process.env.IMMICH_TEST_ENV = 'true';
 | |
|   process.env.TZ = 'Z';
 | |
| };
 |