Skip to content

Commit fa35c24

Browse files
Merge pull request #38 from Kibibit/feature/websockets-and-dev-center
Feature/websockets and dev center
2 parents fe9ffe3 + 842f61a commit fa35c24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+517
-92
lines changed

.devcontainer/devcontainer.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"formulahendry.auto-rename-tag",
3838
"donjayamanne.githistory",
3939
"oderwat.indent-rainbow",
40+
"Postman.postman-for-vscode",
4041
"GitHub.copilot"
4142
],
4243
"settings": {

.vscode/extensions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"dbaeumer.vscode-eslint",
55
"stylelint.vscode-stylelint",
66
"johnpapa.vscode-peacock",
7-
"streetsidesoftware.code-spell-checker"
7+
"streetsidesoftware.code-spell-checker",
8+
"postman.postman-for-vscode"
89
]
910
}

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"files.associations": {
55
"*.json": "json"
66
},
7+
"files.autoSave": "off",
78
"workbench.colorTheme": "Andromeda Bordered",
89
"indentRainbow.indicatorStyle": "light",
910
"indentRainbow.colors": [
@@ -12,6 +13,7 @@
1213
"rgba(255,127,255,0.3)",
1314
"rgba(79,236,236,0.3)"
1415
],
16+
"workbench.editor.pinnedTabsOnSeparateRow": true,
1517
"indentRainbow.lightIndicatorStyleLineWidth": 2,
1618
"gitlens.statusBar.enabled": false,
1719
"peacock.showColorInStatusBar": false,
@@ -53,6 +55,7 @@
5355
"scss.validate": false,
5456
"stylelint.validate": [ "css", "scss" ],
5557
"cSpell.words": [
58+
"achieveebeet",
5659
"achievibit",
5760
"adpyke",
5861
"autoimport",
@@ -90,6 +93,7 @@
9093
"ritwickdey",
9194
"Smee",
9295
"steoates",
96+
"Streamable",
9397
"stylelint",
9498
"stylelintrc",
9599
"thatkookooguy",

client/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"beercss": "^3.7.10",
2525
"material-dynamic-colors": "^1.1.2",
2626
"rxjs": "~7.8.0",
27+
"socket.io-client": "^4.8.0",
2728
"tslib": "^2.3.0",
2829
"zone.js": "~0.14.3"
2930
},

client/proxy.conf.json

+7
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,12 @@
1010
"changeOrigin": true,
1111
"secure": false,
1212
"logLevel": "debug"
13+
},
14+
"/socket.io": {
15+
"target": "http://localhost:10102/",
16+
"ws": true,
17+
"changeOrigin": true,
18+
"secure": false,
19+
"logLevel": "debug"
1320
}
1421
}

client/src/app/app.component.ts

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { combineLatest } from 'rxjs';
1+
import { combineLatest, Subscription } from 'rxjs';
22
import { NgFor, NgIf } from '@angular/common';
3-
import { Component, OnInit } from '@angular/core';
3+
import { Component, OnDestroy, OnInit } from '@angular/core';
44
import { RouterLink, RouterOutlet } from '@angular/router';
55

6+
import { SocketService } from './services/socket.service';
67
import { AppService } from './app.service';
78

89
@Component({
@@ -12,12 +13,33 @@ import { AppService } from './app.service';
1213
templateUrl: './app.component.html',
1314
styleUrl: './app.component.scss'
1415
})
15-
export class AppComponent implements OnInit {
16+
export class AppComponent implements OnInit, OnDestroy {
1617
loggedInUser: any;
1718

19+
private messageSubscription: Subscription;
20+
messages: string[] = [];
21+
newMessage: string = '';
22+
1823
constructor(
19-
private appService: AppService
20-
) {}
24+
private appService: AppService,
25+
private socketService: SocketService
26+
) {
27+
this.messageSubscription = this.socketService
28+
.on('ping')
29+
.subscribe((data) => {
30+
// this.messages.push(data.text);
31+
console.log('Received ping message:', data);
32+
});
33+
}
34+
35+
sendMessage() {
36+
this.socketService.emit('message', { text: this.newMessage });
37+
this.newMessage = '';
38+
}
39+
40+
ngOnDestroy() {
41+
this.messageSubscription.unsubscribe();
42+
}
2143

2244
ngOnInit(): void {
2345
const loggedInUserObs = this
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Observable } from 'rxjs';
2+
import { io, Socket } from 'socket.io-client';
3+
import { Injectable } from '@angular/core';
4+
5+
@Injectable({
6+
providedIn: 'root'
7+
})
8+
export class SocketService {
9+
private socket: Socket;
10+
11+
constructor() {
12+
this.socket = io(window.location.origin);
13+
}
14+
15+
emit(event: string, data: any) {
16+
this.socket.emit(event, data);
17+
}
18+
19+
on(event: string): Observable<any> {
20+
return new Observable((observer) => {
21+
this.socket.on(event, (data) => {
22+
observer.next(data);
23+
});
24+
25+
// Handle cleanup
26+
return () => {
27+
this.socket.off(event);
28+
};
29+
});
30+
}
31+
}

e2e/example.spec.ts

+34-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
11
import { expect, test } from '@playwright/test';
22

3-
test('has title', async ({ page }) => {
4-
await page.goto('https://playwright.dev/');
3+
test('achievibit test', async ({ page }) => {
4+
await page.goto('http://localhost:10101');
55

66
// Expect a title "to contain" a substring.
7-
await expect(page).toHaveTitle(/Playwright/);
7+
await expect(page).toHaveTitle(/achievibit/);
8+
9+
await expect(page.getByRole('heading', { name: 'achievibit' })).toBeVisible();
10+
});
11+
12+
test('login with github', async ({ page }) => {
13+
await page.goto('http://localhost:10101');
14+
15+
// Click the login with github button.
16+
await page.getByRole('link', { name: 'Login with GitHub' }).click();
17+
18+
// expect to be redirected to github login page
19+
await expect(page).toHaveURL(/github/);
20+
await expect(page.getByText('Sign in to GitHub to continue')).toBeVisible();
21+
});
22+
23+
test('login with gitlab', async ({ page }) => {
24+
await page.goto('http://localhost:10101');
25+
26+
// Click the login with gitlab button.
27+
await page.getByRole('link', { name: 'Login with GitLab' }).click();
28+
29+
// expect to be redirected to gitlab login page
30+
await expect(page).toHaveURL(/gitlab/);
31+
await expect(page.getByRole('heading', { name: 'Verify you are human by' })).toBeVisible();
832
});
933

10-
test('get started link', async ({ page }) => {
11-
await page.goto('https://playwright.dev/');
34+
test('login with bitbucket', async ({ page }) => {
35+
await page.goto('http://localhost:10101');
1236

13-
// Click the get started link.
14-
await page.getByRole('link', { name: 'Get started' }).click();
37+
// Click the login with bitbucket button.
38+
await page.getByRole('link', { name: 'Login with Bitbucket' }).click();
1539

16-
// Expects page to have a heading with the name of Installation.
17-
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
40+
// expect to be redirected to bitbucket login page
41+
await expect(page).toHaveURL(/bitbucket/);
42+
await expect(page.getByTestId('username')).toBeVisible();
1843
});

0 commit comments

Comments
 (0)