Skip to content

Commit fbd1e52

Browse files
committed
FIX #1216
1 parent c0be95f commit fbd1e52

File tree

16 files changed

+339
-50
lines changed

16 files changed

+339
-50
lines changed

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"qodana.projectId": "AOK69"
2+
"qodana.projectId": "AOK69",
3+
"cody.autocomplete.advanced.provider": "experimental-ollama",
4+
"cody.autocomplete.experimental.ollamaOptions": {
5+
"url": "http://localhost:11434",
6+
"model": "codellama"
7+
},
38
}

src/app/account/components/add-email/add-email.component.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
fill="white" />
2121
</svg>
2222
</div>
23-
<h4 class="title" translate="MODALS.ADD_EMAIL_HEADING"></h4>
23+
<h4 class="title">{{ 'MODALS.ADD_EMAIL_HEADING' | translate }}</h4>
2424
</div>
2525
<div class="dialog_close">
2626
<a class="btn_dialog_close icon" dialog-close>
@@ -34,29 +34,31 @@ <h4 class="title" translate="MODALS.ADD_EMAIL_HEADING"></h4>
3434
</div>
3535
<div class="dialog_content no_footer">
3636
<form [formGroup]="form">
37-
<cos-input placeholder="{{'MODALS.ADD_EMAIL_PLACEHOLDER_EMAIL' | translate}}">
37+
<cos-input [placeholder]="'MODALS.ADD_EMAIL_PLACEHOLDER_EMAIL' | translate">
3838
<input id="email" formControlName="email" type="email"
39-
placeholder="{{'MODALS.ADD_EMAIL_PLACEHOLDER_EMAIL' | translate}}" (focus)="wWidth > 1024"
39+
[placeholder]="'MODALS.ADD_EMAIL_PLACEHOLDER_EMAIL' | translate" (focus)="wWidth > 1024"
4040
[ngClass]="{'error_input': form.controls['email'].touched && form.controls['email'].invalid}" [maxlength]="254">
4141
<label for="email" class="error_label" *ngIf="form.controls['email'].touched && form.controls['email'].invalid">
4242
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
4343
<path fill-rule="evenodd" clip-rule="evenodd"
4444
d="M8.89438 1.78863C8.52586 1.05158 7.47405 1.05158 7.10553 1.78863L0.723562 14.5526C0.391112 15.2175 0.874608 15.9998 1.61799 15.9998H14.3819C15.1253 15.9998 15.6088 15.2175 15.2763 14.5526L8.89438 1.78863ZM6.99996 6.99977C6.99996 6.44749 7.44767 5.99977 7.99996 5.99977C8.55224 5.99977 8.99996 6.44749 8.99996 6.99977V9.99977C8.99996 10.5521 8.55224 10.9998 7.99996 10.9998C7.44767 10.9998 6.99996 10.5521 6.99996 9.99977V6.99977ZM6.99996 12.9998C6.99996 12.4475 7.44767 11.9998 7.99996 11.9998C8.55224 11.9998 8.99996 12.4475 8.99996 12.9998C8.99996 13.5521 8.55224 13.9998 7.99996 13.9998C7.44767 13.9998 6.99996 13.5521 6.99996 12.9998Z"
4545
fill="#EF4025" />
4646
</svg>
47-
<span translate="MODALS.ADD_EMAIL_ERROR_MSG_INVALID"></span>
47+
<span>{{ 'MODALS.ADD_EMAIL_ERROR_MSG_INVALID' | translate }}</span>
4848
</label>
4949
</cos-input>
5050

51-
<div class="delete_info_text bold" translate="MODALS.ADD_EMAIL_TXT_VERIFY"></div>
51+
<div class="delete_info_text bold">{{ 'MODALS.ADD_EMAIL_TXT_VERIFY' | translate }}</div>
5252
</form>
5353
<div class="button_wrap">
54-
<button class="btn_big_submit" (click)="doUpdateProfile()" [disabled]="form.invalid"
55-
translate="MODALS.ADD_EMAIL_LOG_IN"></button>
56-
<a translate="MODALS.ADD_EMAIL_LNK_CANCEL" (click)="logout()"></a>
54+
<button class="btn_big_submit" (click)="doUpdateProfile()" [disabled]="form.invalid">
55+
{{ 'MODALS.ADD_EMAIL_LOG_IN' | translate }}
56+
</button>
57+
<a (click)="logout()">{{ 'MODALS.ADD_EMAIL_LNK_CANCEL' | translate }}</a>
5758
</div>
5859
<div class="dialog_footer">
5960
</div>
6061
</div>
6162
</div>
6263
</div>
64+
Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,58 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
32
import { IdeaComponent } from './idea.component';
3+
import { TranslateService } from '@ngx-translate/core';
4+
import { of } from 'rxjs';
5+
import { provideHttpClient } from '@angular/common/http';
6+
import { provideHttpClientTesting } from '@angular/common/http/testing';
7+
48

5-
describe('IdeaComponent', () => {
9+
describe('IdeaComponent TranslateService', () => {
610
let component: IdeaComponent;
711
let fixture: ComponentFixture<IdeaComponent>;
12+
let translateService: TranslateService;
813

914
beforeEach(() => {
1015
TestBed.configureTestingModule({
11-
declarations: [IdeaComponent]
16+
declarations: [IdeaComponent],
17+
providers: [TranslateService, provideHttpClient(), provideHttpClientTesting()],
18+
imports: []
1219
});
1320
fixture = TestBed.createComponent(IdeaComponent);
1421
component = fixture.componentInstance;
22+
translateService = TestBed.inject(TranslateService);
1523
fixture.detectChanges();
1624
});
1725

18-
it('should create', () => {
19-
expect(component).toBeTruthy();
26+
it('should inject TranslateService', () => {
27+
expect(translateService).toBeTruthy();
28+
});
29+
30+
it('should handle language change', () => {
31+
const newLang = 'es';
32+
translateService.use(newLang);
33+
expect(translateService.currentLang).toBe(newLang);
34+
});
35+
36+
it('should translate keys correctly', (done) => {
37+
const testKey = 'TEST.KEY';
38+
const expectedValue = 'Translated Value';
39+
40+
spyOn(translateService, 'get').and.returnValue(of(expectedValue));
41+
42+
translateService.get(testKey).subscribe(value => {
43+
expect(value).toBe(expectedValue);
44+
done();
45+
});
46+
});
47+
48+
it('should handle missing translations', (done) => {
49+
const missingKey = 'MISSING.KEY';
50+
51+
spyOn(translateService, 'get').and.returnValue(of(missingKey));
52+
53+
translateService.get(missingKey).subscribe(value => {
54+
expect(value).toBe(missingKey);
55+
done();
56+
});
2057
});
2158
});

src/app/ideation/components/idea/idea.component.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import { IdeaAttachmentService } from 'src/app/services/idea-attachment.service';
2-
import { TopicIdeaRepliesService } from './../../../services/topic-idea-replies.service';
3-
import { TopicIdeaService } from 'src/app/services/topic-idea.service';
4-
import { Component, ContentChildren, QueryList, ViewChildren, inject } from '@angular/core';
1+
import { IdeaAttachmentService } from '@services/idea-attachment.service';
2+
import { TopicIdeaRepliesService } from '@services/topic-idea-replies.service';
3+
import { TopicIdeaService } from '@services/topic-idea.service';
4+
import { Component, ContentChildren, QueryList, inject } from '@angular/core';
55
import { ActivatedRoute, Router } from '@angular/router';
66
import { DIALOG_DATA, DialogRef, DialogService } from 'src/app/shared/dialog';
7-
import { take, combineLatest, Observable, switchMap, map, of, tap } from 'rxjs';
8-
import { Idea } from 'src/app/interfaces/idea';
9-
import { AuthService } from 'src/app/services/auth.service';
7+
import { take, combineLatest, Observable, switchMap, map, tap } from 'rxjs';
8+
import { AuthService } from '@services/auth.service';
109
import { IdeaboxComponent } from '../ideabox/ideabox.component';
11-
import { ConfigService } from 'src/app/services/config.service';
12-
import { LocationService } from 'src/app/services/location.service';
13-
import { NotificationService } from 'src/app/services/notification.service';
10+
import { ConfigService } from '@services/config.service';
11+
import { LocationService } from '@services/location.service';
12+
import { NotificationService } from '@services/notification.service';
1413
import { TranslateService } from '@ngx-translate/core';
1514
import { Argument } from 'src/app/interfaces/argument';
16-
import { TopicService } from 'src/app/services/topic.service';
15+
import { TopicService } from '@services/topic.service';
1716
import { Folder } from 'src/app/interfaces/folder';
1817
import { DomSanitizer } from '@angular/platform-browser';
1918
import { IdeaReplyComponent } from '../idea-reply/idea-reply.component';

src/app/interfaces/topic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface Topic {
3636
moderatedReasonType: string | null,
3737
moderatedReasonText: string | null
3838
},
39-
events: any,
39+
events?: any,
4040
vote?: Vote,
4141
revision?: number
4242
}
Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
import { TestBed } from '@angular/core/testing';
2-
2+
import { provideHttpClient } from '@angular/common/http';
33
import { PublicGroupMemberTopicsService } from './public-group-member-topics.service';
4+
import { provideHttpClientTesting } from '@angular/common/http/testing';
5+
import { firstValueFrom } from 'rxjs';
46

5-
describe('PublicGroupMemberTopicsService', () => {
7+
describe('PublicGroupMemberTopicsService.reload', () => {
68
let service: PublicGroupMemberTopicsService;
79

810
beforeEach(() => {
9-
TestBed.configureTestingModule({});
11+
TestBed.configureTestingModule({
12+
imports: [],
13+
providers: [
14+
provideHttpClient(),
15+
provideHttpClientTesting(),
16+
PublicGroupMemberTopicsService
17+
]
18+
});
1019
service = TestBed.inject(PublicGroupMemberTopicsService);
1120
});
1221

13-
it('should be created', () => {
14-
expect(service).toBeTruthy();
22+
it('should reset offset to 0', () => {
23+
service.params$.value.offset = 10;
24+
service.reload();
25+
expect(service.params$.value.offset).toBe(0);
26+
});
27+
28+
it('should reset page to 1', () => {
29+
service.params$.value.page = 5;
30+
service.reload();
31+
expect(service.params$.value.page).toBe(1);
32+
});
33+
34+
it('should maintain other params values', () => {
35+
service.params$.value.order = 'asc';
36+
service.reload();
37+
expect(service.params$.value.order).toBe('asc');
1538
});
1639
});
40+
41+
// Add interface for params
42+
interface Params {
43+
offset: number;
44+
page: number;
45+
order: string;
46+
}
47+
48+
const DEFAULT_OFFSET = 10;
49+
const DEFAULT_PAGE = 5;
50+
const DEFAULT_ORDER = 'asc';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<div class="overlay" dialog-close></div>
2+
<div class="dialog_wrap">
3+
<div class="dialog">
4+
<div class="dialog_header warning">
5+
<div class="header_with_icon">
6+
<div class="icon_notification">
7+
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
8+
<rect width="40" height="40" rx="20" fill="#F39129" />
9+
<path
10+
d="M19.0645 8C18.4876 8 18.0304 8.48668 18.0664 9.06238L18.9414 23.0624C18.9743 23.5894 19.4114 24 19.9395 24H20.0605C20.5886 24 21.0257 23.5894 21.0586 23.0624L21.9336 9.06238C21.9696 8.48668 21.5124 8 20.9355 8H19.0645Z"
11+
fill="white" />
12+
<path
13+
d="M20 31C21.1046 31 22 30.1046 22 29C22 27.8954 21.1046 27 20 27C18.8954 27 18 27.8954 18 29C18 30.1046 18.8954 31 20 31Z"
14+
fill="white" />
15+
</svg>
16+
</div>
17+
<h4 class="title" translate="COMPONENTS.CLOSE_VOTING_CONFIRM.HEADING"></h4>
18+
</div>
19+
<div class="dialog_close">
20+
<a class="btn_dialog_close icon" dialog-close>
21+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
22+
<path
23+
d="M7.72152 6.29537C7.3277 5.90154 6.68919 5.90154 6.29537 6.29537C5.90154 6.68919 5.90154 7.3277 6.29537 7.72153L10.5738 12L6.29541 16.2785C5.90159 16.6723 5.90159 17.3108 6.29541 17.7046C6.68923 18.0985 7.32774 18.0985 7.72156 17.7046L12 13.4262L16.2784 17.7046C16.6723 18.0985 17.3108 18.0985 17.7046 17.7046C18.0984 17.3108 18.0984 16.6723 17.7046 16.2785L13.4262 12L17.7046 7.72153C18.0985 7.3277 18.0985 6.68919 17.7046 6.29537C17.3108 5.90154 16.6723 5.90154 16.2785 6.29537L12 10.5739L7.72152 6.29537Z"
24+
fill="#2C3B47" />
25+
</svg>
26+
</a>
27+
</div>
28+
</div>
29+
<div class="dialog_content">
30+
<div class="info_row center" translate="COMPONENTS.CLOSE_VOTING_CONFIRM.ARE_YOU_SURE"></div>
31+
</div>
32+
<div class="dialog_content" *ngIf="data.topic.ideationId || data.topic.discussionId">
33+
<div class="info_row center" translate="COMPONENTS.CLOSE_VOTING_CONFIRM.CLOSE_VOTING_DESCRIPTION"></div>
34+
</div>
35+
<div class="dialog_content no_footer">
36+
<div class="button_wrap">
37+
<button class="btn_big_submit" [dialog-close]="true"
38+
translate="COMPONENTS.CLOSE_VOTING_CONFIRM.CONFIRM_YES"></button>
39+
<a dialog-close translate="COMPONENTS.CLOSE_VOTING_CONFIRM.CONFIRM_NO"></a>
40+
</div>
41+
</div>
42+
<div class="dialog_footer">
43+
</div>
44+
</div>
45+
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.dialog {
2+
max-width: 560px;
3+
}
4+
.warn {
5+
.icon_notification {
6+
rect {
7+
fill: var(--color-warn);
8+
}
9+
}
10+
}
11+
12+
.error {
13+
.icon_notification {
14+
rect {
15+
fill: var(--color-error);
16+
}
17+
}
18+
}
19+
20+
.center {
21+
text-align: center;
22+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { CloseVotingComponent } from './close-voting.component';
4+
import { DIALOG_DATA } from 'src/app/shared/dialog';
5+
import { CloseVotingData } from './close-voting.component';
6+
7+
describe('CloseVotingComponent', () => {
8+
let component: CloseVotingComponent;
9+
let fixture: ComponentFixture<CloseVotingComponent>;
10+
11+
beforeEach(async () => {
12+
await TestBed.configureTestingModule({
13+
imports: [CloseVotingComponent]
14+
})
15+
.compileComponents();
16+
17+
fixture = TestBed.createComponent(CloseVotingComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
26+
describe('CloseVotingComponent', () => {
27+
let component: CloseVotingComponent;
28+
let fixture: ComponentFixture<CloseVotingComponent>;
29+
const mockDialogData: CloseVotingData = {
30+
topic: {
31+
authors: [
32+
{
33+
id: '123',
34+
name: 'Test Author',
35+
company: 'Test Company'
36+
}
37+
],
38+
id: 'topic123',
39+
title: 'Test Topic Title',
40+
intro: 'Test topic introduction text',
41+
description: '<p>Test topic description</p>',
42+
status: 'open',
43+
visibility: 'public',
44+
hashtag: 'testtopic',
45+
join: {
46+
token: 'abc123',
47+
level: 'read'
48+
},
49+
categories: ['category1', 'category2'],
50+
endsAt: '2024-12-31T23:59:59Z',
51+
createdAt: '2024-01-01T00:00:00Z',
52+
updatedAt: '2024-01-01T00:00:00Z',
53+
sourcePartnerId: null,
54+
sourcePartnerObjectId: null,
55+
permission: {
56+
level: 'admin',
57+
levelGroup: 'group1'
58+
},
59+
creator: {
60+
id: 'user123',
61+
name: 'Test Creator'
62+
},
63+
lastActivity: '2024-03-19T10:00:00Z',
64+
country: 'US',
65+
language: 'en',
66+
members: {
67+
users: [],
68+
groups: []
69+
},
70+
voteId: 'vote123',
71+
ideationId: 'ideation123',
72+
discussionId: 'discussion123',
73+
comments: {
74+
count: 0,
75+
latest: []
76+
},
77+
padUrl: 'https://example.com/pad/123',
78+
favourite: false,
79+
imageUrl: 'https://example.com/image.jpg'
80+
}
81+
};
82+
83+
beforeEach(async () => {
84+
await TestBed.configureTestingModule({
85+
declarations: [CloseVotingComponent],
86+
providers: [
87+
{ provide: DIALOG_DATA, useValue: mockDialogData }
88+
]
89+
})
90+
.compileComponents();
91+
92+
fixture = TestBed.createComponent(CloseVotingComponent);
93+
component = fixture.componentInstance;
94+
fixture.detectChanges();
95+
});
96+
97+
it('should create', () => {
98+
expect(component).toBeTruthy();
99+
});
100+
101+
it('should have data injected', () => {
102+
expect(component.data).toEqual(mockDialogData);
103+
});
104+
});
105+
106+
});

0 commit comments

Comments
 (0)