- 
                Notifications
    You must be signed in to change notification settings 
- Fork 11
test: fix connect plugin tests #1441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      f5e7ebc
              
                test: myserverscfg migration
              
              
                pujitm ed3740d
              
                test api config migration
              
              
                pujitm d886bec
              
                update vitest to latest
              
              
                pujitm 4aee49a
              
                fix cloud service test
              
              
                pujitm 01053ca
              
                fix: url resolver tests
              
              
                pujitm 1e37b55
              
                run tests concurrently in test-api ci workflow
              
              
                pujitm 5bfa188
              
                fix dir of unraid-shared package in test-api workflow definition
              
              
                pujitm 52405d1
              
                move api config module test to test folder
              
              
                pujitm File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| import { ConfigService } from '@nestjs/config'; | ||
|  | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|  | ||
| import { ApiConfigPersistence } from '@app/unraid-api/config/api-config.module.js'; | ||
| import { ConfigPersistenceHelper } from '@app/unraid-api/config/persistence.helper.js'; | ||
|  | ||
| describe('ApiConfigPersistence', () => { | ||
| let service: ApiConfigPersistence; | ||
| let configService: ConfigService; | ||
| let persistenceHelper: ConfigPersistenceHelper; | ||
|  | ||
| beforeEach(() => { | ||
| configService = { | ||
| get: vi.fn(), | ||
| set: vi.fn(), | ||
| } as any; | ||
|  | ||
| persistenceHelper = {} as ConfigPersistenceHelper; | ||
| service = new ApiConfigPersistence(configService, persistenceHelper); | ||
| }); | ||
|  | ||
| describe('convertLegacyConfig', () => { | ||
| it('should migrate sandbox from string "yes" to boolean true', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'yes' }, | ||
| api: { extraOrigins: '' }, | ||
| remote: { ssoSubIds: '' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.sandbox).toBe(true); | ||
| }); | ||
|  | ||
| it('should migrate sandbox from string "no" to boolean false', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'no' }, | ||
| api: { extraOrigins: '' }, | ||
| remote: { ssoSubIds: '' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.sandbox).toBe(false); | ||
| }); | ||
|  | ||
| it('should migrate extraOrigins from comma-separated string to array', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'no' }, | ||
| api: { extraOrigins: 'https://example.com,https://test.com' }, | ||
| remote: { ssoSubIds: '' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.extraOrigins).toEqual(['https://example.com', 'https://test.com']); | ||
| }); | ||
|  | ||
| it('should filter out non-HTTP origins from extraOrigins', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'no' }, | ||
| api: { | ||
| extraOrigins: 'https://example.com,invalid-origin,http://test.com,ftp://bad.com', | ||
| }, | ||
| remote: { ssoSubIds: '' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.extraOrigins).toEqual(['https://example.com', 'http://test.com']); | ||
| }); | ||
|  | ||
| it('should handle empty extraOrigins string', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'no' }, | ||
| api: { extraOrigins: '' }, | ||
| remote: { ssoSubIds: '' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.extraOrigins).toEqual([]); | ||
| }); | ||
|  | ||
| it('should migrate ssoSubIds from comma-separated string to array', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'no' }, | ||
| api: { extraOrigins: '' }, | ||
| remote: { ssoSubIds: 'user1,user2,user3' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.ssoSubIds).toEqual(['user1', 'user2', 'user3']); | ||
| }); | ||
|  | ||
| it('should handle empty ssoSubIds string', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'no' }, | ||
| api: { extraOrigins: '' }, | ||
| remote: { ssoSubIds: '' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.ssoSubIds).toEqual([]); | ||
| }); | ||
|  | ||
| it('should handle undefined config sections', () => { | ||
| const legacyConfig = {}; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.sandbox).toBe(false); | ||
| expect(result.extraOrigins).toEqual([]); | ||
| expect(result.ssoSubIds).toEqual([]); | ||
| }); | ||
|  | ||
| it('should handle complete migration with all fields', () => { | ||
| const legacyConfig = { | ||
| local: { sandbox: 'yes' }, | ||
| api: { extraOrigins: 'https://app1.example.com,https://app2.example.com' }, | ||
| remote: { ssoSubIds: 'sub1,sub2,sub3' }, | ||
| }; | ||
|  | ||
| const result = service.convertLegacyConfig(legacyConfig); | ||
|  | ||
| expect(result.sandbox).toBe(true); | ||
| expect(result.extraOrigins).toEqual([ | ||
| 'https://app1.example.com', | ||
| 'https://app2.example.com', | ||
| ]); | ||
| expect(result.ssoSubIds).toEqual(['sub1', 'sub2', 'sub3']); | ||
| }); | ||
| }); | ||
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Hard-fail safety & trailing-space lint
Robust shell flags
Use
set -euo pipefailinstead of plainset -eto catch:• unset variables (
$API_EXITet al. before defaulting)• errors in pipelines.
Quoting & paths
The
cd ../packages/...hops rely onapibeing the CWD. For clarity & resilience, prefer${{ github.workspace }}/packages/....YAML-lint errors
Static analysis flags trailing spaces on lines 124, 129, 133, 137, 142, 145, 147. Remove them to keep the workflow YAML-lint-clean.
Example patch (trimmed for brevity):
…and delete the offending trailing spaces.
📝 Committable suggestion
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 124-124: trailing spaces
(trailing-spaces)
[error] 129-129: trailing spaces
(trailing-spaces)
[error] 133-133: trailing spaces
(trailing-spaces)
[error] 137-137: trailing spaces
(trailing-spaces)
[error] 142-142: trailing spaces
(trailing-spaces)
[error] 145-145: trailing spaces
(trailing-spaces)
[error] 147-147: trailing spaces
(trailing-spaces)
🤖 Prompt for AI Agents