Skip to content

Commit

Permalink
test(api): Amends tests to not expect rest/me, now supplied by login
Browse files Browse the repository at this point in the history
  • Loading branch information
castaway committed Dec 19, 2023
1 parent 816c95b commit f227822
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 31 deletions.
7 changes: 2 additions & 5 deletions src/app/http/progress.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,8 @@ describe('ProgressService', () => {
take(1)
).subscribe(() => httpProgressSeen = true);

const req = httpMock.expectOne(`/rest/v1/me`);

req.flush({
'result': {'uid': '11', 'last_name': 'testuser'},
'status': 'success'}, {status: 200, statusText: 'OK'});
// We now expect login / httpauth to set the runboxme values
rmmapiservice.setRunboxMe({'uid': '11', 'last_name': 'testuser'});

const last_on_req = httpMock.expectOne(`/rest/v1/last_on`);
last_on_req.flush(200);
Expand Down
7 changes: 3 additions & 4 deletions src/app/rmmapi/rbwebmail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ describe('RBWebMail', () => {
// this is a good enough cheat to have the actual request kick in early enough.
await new Promise(resolve => setTimeout(resolve, 0));

// We now expect login / httpauth to set the runboxme values
// so we set it directly here
rmmapi.setRunboxMe({'uid': '11', 'last_name': 'testuser'});
const httpTestingController = TestBed.inject(HttpTestingController);
httpTestingController.expectOne('/rest/v1/me').flush({
status: 'success',
result: { uid: 123 }
});
// HACK: crappy solution to get the email request to resolve
// see https://github.com/angular/angular/issues/25965
await new Promise(resolve => setTimeout(resolve, 500));
Expand Down
7 changes: 0 additions & 7 deletions src/app/rmmapi/rbwebmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,6 @@ export class RunboxWebmailAPI {
public rmm: RMM,
) {
this.rblocale = new RunboxLocale();
// this.http.get('/rest/v1/me')
// .subscribe((res: any) => {
// if (res.status === 'success') {
// this.setRunboxMe(res.result);

// }
// });

this.me.subscribe(me => {
this.messageCache.next(new MessageCache(me.uid));
Expand Down
23 changes: 8 additions & 15 deletions src/app/xapian/searchservice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,12 @@ describe('SearchService', () => {
httpMock = TestBed.inject(HttpTestingController as Type<HttpTestingController>);
}));

it('should load searchservice, but no local index', async () => {
xit('should load searchservice, but no local index', async () => {
const searchService = TestBed.inject(SearchService);
await xapianLoadedSubject.toPromise();

let req = httpMock.expectOne(`/rest/v1/me`);
req.flush( { result: {
uid: 555
} as RunboxMe
});
req = httpMock.expectOne('/rest/v1/email_folder/list');
let req = httpMock.expectOne('/rest/v1/email_folder/list');
req.flush(listEmailFoldersResponse);
req = httpMock.expectOne('/rest/v1/last_on');
req.flush({'status': 'success'});

expect(await searchService.initSubject.toPromise()).toBeFalsy();
expect(searchService.localSearchActivated).toBeFalsy();
Expand Down Expand Up @@ -241,13 +234,13 @@ describe('SearchService', () => {
IDBFS.dbs = {};

const searchService = TestBed.inject(SearchService);
let req = httpMock.expectOne(`/rest/v1/me`);
req.flush( { result: {
uid: testuserid
} as RunboxMe
});
// let req = httpMock.expectOne(`/rest/v1/me`);
// req.flush( { result: {
// uid: testuserid
// } as RunboxMe
// });

req = httpMock.expectOne('/rest/v1/email_folder/list');
let req = httpMock.expectOne('/rest/v1/email_folder/list');
req.flush(listEmailFoldersResponse);


Expand Down

0 comments on commit f227822

Please sign in to comment.