|
| 1 | +import { expect } from 'chai'; |
| 2 | +import { encryptDecrypt } from '../src/encryptDecrypt'; // Adjust the path as needed |
| 3 | + |
| 4 | +describe('Lit Action encryptDecrypt test', function() { |
| 5 | + // Increase timeout for API calls |
| 6 | + this.timeout(60000); // Extended to 60 seconds |
| 7 | + |
| 8 | + it('should encrypt and decrypt "Hello world" correctly', async () => { |
| 9 | + // Original message that should be recovered after decryption |
| 10 | + const originalMessage = 'Hello world'; |
| 11 | + |
| 12 | + try { |
| 13 | + const result = await encryptDecrypt(); |
| 14 | + |
| 15 | + // Basic success check |
| 16 | + expect(result.success, 'encryptDecrypt should execute successfully').to.be.true; |
| 17 | + |
| 18 | + // If it failed, log the error for easier debugging |
| 19 | + if (!result.success) { |
| 20 | + console.error('Test failed with error:', result.error); |
| 21 | + expect.fail('Test failed but should have passed'); |
| 22 | + } |
| 23 | + |
| 24 | + // Verify that the response exists |
| 25 | + expect(result.response, 'Response should not be null').to.not.be.null; |
| 26 | + |
| 27 | + // CRITICAL TEST: Verify the decrypted message matches the original input |
| 28 | + expect(result.response.response).to.equal(originalMessage, |
| 29 | + 'Decrypted message should match the original "Hello world" message'); |
| 30 | + |
| 31 | + // Log success and response information for debugging |
| 32 | + console.log('Successfully verified encryption/decryption: Original message was properly recovered'); |
| 33 | + console.log('Full response:', JSON.stringify(result.response, null, 2)); |
| 34 | + } catch (error) { |
| 35 | + console.error('Unexpected error during test execution:', error); |
| 36 | + throw error; // Re-throw to fail the test |
| 37 | + } |
| 38 | + }); |
| 39 | +}); |
0 commit comments