Skip to content
Draft
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
35 changes: 34 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"format:check": "prettier --check .",
"format:write": "prettier --write .",
"test:integration": "node --test integrationTests/apiTests/tests/testSuite.mjs",
"test:unit": "npm run build || true; npx mocha unitTests --config unitTests/.mocharc.json"
"test:unit": "npm run build || true; npx mocha unitTests --config unitTests/.mocharc.json",
"test:static-plugin-integration": "node --test test/staticPluginIntegrationTests/testSuite.test.mts"
},
"engines": {
"node": ">=20",
Expand All @@ -61,6 +62,7 @@
"@types/sinon": "^17.0.4",
"axios": "^1.12.2",
"chai": "^6.2.0",
"@types/tar-fs": "^2.0.4",
"eslint": "^9.36.0",
"fast-glob": "^3.3.3",
"fs-extra": "^11.3.2",
Expand All @@ -71,7 +73,8 @@
"supertest": "^7.1.4",
"tsx": "^4.20.6",
"typescript": "^5.7.3",
"typescript-eslint": "^8.45.0"
"typescript-eslint": "^8.45.0",
"undici": "^7.16.0"
},
"dependencies": {
"@aws-sdk/client-s3": "3.824.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { request } from 'undici';
import { suite, test, before, after } from 'node:test';
import assert from 'node:assert/strict';
import { join } from 'node:path';
import { pack } from 'tar-fs';
import { createGzip } from 'node:zlib';
import { setTimeout as sleep } from 'node:timers/promises';

async function packFixture(): Promise<string> {
const fixturePath = join(import.meta.dirname, 'fixture');
const chunks: Buffer[] = [];
return new Promise((resolve, reject) => {
pack(fixturePath)
.pipe(createGzip())
.on('data', (chunk: Buffer) => chunks.push(chunk))
.on('end', () => {
resolve(Buffer.concat(chunks).toString('base64'));
})
.on('error', reject);
});
}

async function dropFixture() {
const { statusCode, body } = await request('http://localhost:9925', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
operation: 'drop_component',
project: 'static-plugin-defaults'
})
});
assert.equal(statusCode, 200, `Failed to remove application: ${await body.text()}`);
}

void suite('Static Plugin - Defaults', async () => {
before(async () => {
await dropFixture();
const payload = await packFixture();
const { statusCode, body } = await request('http://localhost:9925', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
operation: 'deploy_component',
project: 'static-plugin-defaults',
payload,
restart: true
})
});
assert.equal(statusCode, 200, `Failed to deploy application: ${await body.text()}`);
await sleep(1000);
});

after(async () => {
await dropFixture();
});

await test('can access Harper instance', async () => {
const { statusCode, body } = await request('http://localhost:9925/health');
assert.equal(statusCode, 200);
const responseBody = await body.text();
assert.equal(responseBody, 'HarperDB is running.');
});

void test('can access index path', async () => {
const { statusCode, body, headers } = await request('http://localhost:9926/');
assert.equal(statusCode, 200);
assert.ok(headers['content-type'].includes('text/html'));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
static:
files: 'static/**/*'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "static-plugin-integration-tests-fixture",
"version": "1.0.0",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Root HTML File</title>
</head>
<body>
<h1>Harper!</h1>
</body>
</html>
6 changes: 6 additions & 0 deletions test/staticPluginIntegrationTests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.json",
"include": [
"**/*.mts",
]
}
Loading