WIP: Dodaj wsparcie dla Dockera #128
@ -82,9 +82,10 @@ CMD ["echo", "Use verify stage for testing"]
|
||||
# Integration test stage - automated testing with exit code
|
||||
FROM runtime AS integration_test
|
||||
|
||||
# Copy verification script
|
||||
COPY tests/test_verify.py /app/test_verify.py
|
||||
RUN chmod +x /app/test_verify.py
|
||||
# Copy verification scripts
|
||||
COPY tests/test_verify.py /app/tests/test_verify.py
|
||||
COPY tests/test-lib.js /app/tests/test-lib.js
|
||||
RUN chmod +x /app/tests/test_verify.py
|
||||
|
||||
# Run verification and exit with proper exit code
|
||||
CMD ["python3", "/app/test_verify.py"]
|
||||
CMD ["python3", "/app/tests/test_verify.py"]
|
||||
|
||||
1257
package-lock.json
generated
1257
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
tests/test-lib.js
Normal file
36
tests/test-lib.js
Normal file
@ -0,0 +1,36 @@
|
||||
// Test library for Marionette-based extension verification
|
||||
// This JavaScript code runs in the browser context via Marionette
|
||||
|
||||
/**
|
||||
* Test that background script performs computation correctly
|
||||
* @param {number} testValue - Input value for computation
|
||||
* @returns {Promise<number|null>} - Computed result or null on failure
|
||||
*/
|
||||
function testBackgroundComputation(testValue) {
|
||||
// Check if content script loaded
|
||||
if (!document.body.getAttribute('data-rentgen-injected')) {
|
||||
return -1; // Content script not loaded
|
||||
}
|
||||
|
||||
// Dispatch test request to content script
|
||||
document.dispatchEvent(new CustomEvent('rentgen_test_request', {
|
||||
detail: { value: testValue, timestamp: Date.now() }
|
||||
}));
|
||||
|
||||
// Wait for background response
|
||||
return new Promise((resolve) => {
|
||||
let attempts = 0;
|
||||
const checkInterval = setInterval(() => {
|
||||
attempts++;
|
||||
const computed = document.body.getAttribute('data-rentgen-computed');
|
||||
|
||||
if (computed) {
|
||||
clearInterval(checkInterval);
|
||||
resolve(parseInt(computed));
|
||||
} else if (attempts > 50) {
|
||||
clearInterval(checkInterval);
|
||||
resolve(null);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
@ -70,36 +70,17 @@ def test_addition():
|
||||
test_value = 17
|
||||
expected = 37
|
||||
|
||||
result = client.execute_script("""
|
||||
const testValue = arguments[0];
|
||||
# Load test library
|
||||
test_lib_path = os.path.join(os.path.dirname(__file__), 'test-lib.js')
|
||||
with open(test_lib_path, 'r') as f:
|
||||
test_lib = f.read()
|
||||
|
||||
// Check if content script loaded
|
||||
if (!document.body.getAttribute('data-rentgen-injected')) {
|
||||
return -1; // Content script not loaded
|
||||
}
|
||||
|
||||
// Dispatch test request to content script
|
||||
document.dispatchEvent(new CustomEvent('rentgen_test_request', {
|
||||
detail: { value: testValue, timestamp: Date.now() }
|
||||
}));
|
||||
|
||||
// Wait for background response
|
||||
return new Promise((resolve) => {
|
||||
let attempts = 0;
|
||||
const checkInterval = setInterval(() => {
|
||||
attempts++;
|
||||
const computed = document.body.getAttribute('data-rentgen-computed');
|
||||
|
||||
if (computed) {
|
||||
clearInterval(checkInterval);
|
||||
resolve(parseInt(computed));
|
||||
} else if (attempts > 50) {
|
||||
clearInterval(checkInterval);
|
||||
resolve(null);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
""", script_args=[test_value], script_timeout=10000)
|
||||
# Execute test
|
||||
result = client.execute_script(
|
||||
test_lib + "\nreturn testBackgroundComputation(arguments[0]);",
|
||||
script_args=[test_value],
|
||||
script_timeout=10000
|
||||
)
|
||||
|
||||
client.close()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user