ci: use Gitea API for releases #2
@@ -21,6 +21,9 @@ jobs:
|
||||
- name: Install dev dependencies
|
||||
run: npm ci || npm install
|
||||
|
||||
- name: Install PyMuPDF (PDF text assertions)
|
||||
run: python3 -m pip install --quiet pymupdf
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
|
||||
+18
-1
@@ -38,7 +38,19 @@ function extractPdfText(bytes) {
|
||||
return execFileSync('python3', ['-c', script], { encoding: 'utf8' });
|
||||
}
|
||||
|
||||
test('buildStudyLoadPdf returns valid PDF bytes', async () => {
|
||||
// PyMuPDF (fitz) is only needed for the text-extraction assertions below. It is
|
||||
// installed in CI, but if it is missing locally we skip those assertions rather
|
||||
// than hard-failing.
|
||||
function fitzAvailable() {
|
||||
try {
|
||||
execFileSync('python3', ['-c', 'import fitz'], { stdio: 'ignore' });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
test('buildStudyLoadPdf returns valid PDF bytes', async (t) => {
|
||||
const bytes = await buildStudyLoadPdf(sampleData);
|
||||
assert.ok(bytes instanceof Uint8Array);
|
||||
const head = Buffer.from(bytes.slice(0, 5)).toString('latin1');
|
||||
@@ -46,6 +58,11 @@ test('buildStudyLoadPdf returns valid PDF bytes', async () => {
|
||||
const doc = await PDFLib.PDFDocument.load(bytes);
|
||||
assert.strictEqual(doc.getPageCount(), 1);
|
||||
|
||||
if (!fitzAvailable()) {
|
||||
t.skip('PyMuPDF (fitz) not available; skipping PDF text assertions');
|
||||
return;
|
||||
}
|
||||
|
||||
const text = extractPdfText(bytes);
|
||||
assert.ok(text.includes('CIS 2101'), 'PDF text should contain course code CIS 2101');
|
||||
assert.ok(text.includes("STUDENT'S STUDY LOAD"), 'PDF text should contain the title');
|
||||
|
||||
Reference in New Issue
Block a user