mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Feature: OAuth2 Gmail and Outlook email support (#7866)
This commit is contained in:
		| @@ -4,7 +4,7 @@ import { TestBed } from '@angular/core/testing' | ||||
| import { environment } from 'src/environments/environment' | ||||
| import { commonAbstractPaperlessServiceTests } from './abstract-paperless-service.spec' | ||||
| import { MailAccountService } from './mail-account.service' | ||||
| import { IMAPSecurity } from 'src/app/data/mail-account' | ||||
| import { IMAPSecurity, MailAccountType } from 'src/app/data/mail-account' | ||||
|  | ||||
| let httpTestingController: HttpTestingController | ||||
| let service: MailAccountService | ||||
| @@ -20,6 +20,7 @@ const mail_accounts = [ | ||||
|     username: 'user', | ||||
|     password: 'pass', | ||||
|     is_token: false, | ||||
|     account_type: MailAccountType.IMAP, | ||||
|   }, | ||||
|   { | ||||
|     name: 'Mail Account 2', | ||||
| @@ -30,6 +31,7 @@ const mail_accounts = [ | ||||
|     username: 'user', | ||||
|     password: 'pass', | ||||
|     is_token: false, | ||||
|     account_type: MailAccountType.IMAP, | ||||
|   }, | ||||
|   { | ||||
|     name: 'Mail Account 3', | ||||
| @@ -40,6 +42,7 @@ const mail_accounts = [ | ||||
|     username: 'user', | ||||
|     password: 'pass', | ||||
|     is_token: false, | ||||
|     account_type: MailAccountType.IMAP, | ||||
|   }, | ||||
| ] | ||||
|  | ||||
| @@ -55,20 +58,6 @@ describe(`Additional service tests for MailAccountService`, () => { | ||||
|     expect(req.request.method).toEqual('POST') | ||||
|   }) | ||||
|  | ||||
|   it('should support patchMany', () => { | ||||
|     subscription = service.patchMany(mail_accounts).subscribe() | ||||
|     mail_accounts.forEach((mail_account) => { | ||||
|       const req = httpTestingController.expectOne( | ||||
|         `${environment.apiBaseUrl}${endpoint}/${mail_account.id}/` | ||||
|       ) | ||||
|       expect(req.request.method).toEqual('PATCH') | ||||
|       req.flush(mail_account) | ||||
|     }) | ||||
|     httpTestingController.expectOne( | ||||
|       `${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000` | ||||
|     ) | ||||
|   }) | ||||
|  | ||||
|   it('should support reload', () => { | ||||
|     service['reload']() | ||||
|     const req = httpTestingController.expectOne( | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| import { HttpClient } from '@angular/common/http' | ||||
| import { Injectable } from '@angular/core' | ||||
| import { combineLatest, Observable } from 'rxjs' | ||||
| import { tap } from 'rxjs/operators' | ||||
| import { MailAccount } from 'src/app/data/mail-account' | ||||
| import { AbstractPaperlessService } from './abstract-paperless-service' | ||||
| @@ -34,15 +33,11 @@ export class MailAccountService extends AbstractPaperlessService<MailAccount> { | ||||
|   } | ||||
|  | ||||
|   update(o: MailAccount) { | ||||
|     // Remove expiration from the object before updating | ||||
|     delete o.expiration | ||||
|     return super.update(o).pipe(tap(() => this.reload())) | ||||
|   } | ||||
|  | ||||
|   patchMany(objects: MailAccount[]): Observable<MailAccount[]> { | ||||
|     return combineLatest(objects.map((o) => super.patch(o))).pipe( | ||||
|       tap(() => this.reload()) | ||||
|     ) | ||||
|   } | ||||
|  | ||||
|   delete(o: MailAccount) { | ||||
|     return super.delete(o).pipe(tap(() => this.reload())) | ||||
|   } | ||||
|   | ||||
| @@ -76,21 +76,6 @@ const mail_rules = [ | ||||
| commonAbstractPaperlessServiceTests(endpoint, MailRuleService) | ||||
|  | ||||
| describe(`Additional service tests for MailRuleService`, () => { | ||||
|   it('should support patchMany', () => { | ||||
|     subscription = service.patchMany(mail_rules).subscribe() | ||||
|     mail_rules.forEach((mail_rule) => { | ||||
|       const req = httpTestingController.expectOne( | ||||
|         `${environment.apiBaseUrl}${endpoint}/${mail_rule.id}/` | ||||
|       ) | ||||
|       expect(req.request.method).toEqual('PATCH') | ||||
|       req.flush(mail_rule) | ||||
|     }) | ||||
|     const reloadReq = httpTestingController.expectOne( | ||||
|       `${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000` | ||||
|     ) | ||||
|     reloadReq.flush({ results: mail_rules }) | ||||
|   }) | ||||
|  | ||||
|   it('should support reload', () => { | ||||
|     service['reload']() | ||||
|     const req = httpTestingController.expectOne( | ||||
|   | ||||
| @@ -37,12 +37,6 @@ export class MailRuleService extends AbstractPaperlessService<MailRule> { | ||||
|     return super.update(o).pipe(tap(() => this.reload())) | ||||
|   } | ||||
|  | ||||
|   patchMany(objects: MailRule[]): Observable<MailRule[]> { | ||||
|     return combineLatest(objects.map((o) => super.patch(o))).pipe( | ||||
|       tap(() => this.reload()) | ||||
|     ) | ||||
|   } | ||||
|  | ||||
|   delete(o: MailRule) { | ||||
|     return super.delete(o).pipe(tap(() => this.reload())) | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon