Skip to content
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

AddTimeToOpponent (clean) #125

Open
wants to merge 79 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
5845c36
[AddTimeToOpponent] moved all change in this PR, previous one was pol…
MartinREMY42 Dec 24, 2021
e695168
[P4Enhanced] P4 and Six coverage bumped and rules utils used for test
MartinREMY42 Dec 26, 2021
9384ba6
[AddTimeToOpponent] PR Comments Wave 1
MartinREMY42 Dec 27, 2021
83a3da7
Merge branch 'develop' of https://github.com/MartinREMY42/multi-game-…
MartinREMY42 Dec 27, 2021
84458f7
[AddTimeToOpponent] Chrono now resynchronised after time add
MartinREMY42 Dec 28, 2021
e0ab44f
[P4Enhance]PR Comment Wave 1
MartinREMY42 Dec 28, 2021
76ff69d
[P4Enhance] pulled develop and fixed conflict
MartinREMY42 Dec 28, 2021
ba387df
[AddTimeToOpponent] Messages after agreed draw enhanced
MartinREMY42 Dec 29, 2021
75369ee
[AddTimeToOpponent] Several should be addable to same chrono twice in…
MartinREMY42 Jan 3, 2022
eb6c072
[AddTimeToOpponent] pulled develop and fixed conflict
MartinREMY42 Jan 4, 2022
0660f59
[AddTimeToOpponent] pulled develop and fix conflict
MartinREMY42 Jan 4, 2022
ee6ae36
[activeparts-missing] Get 100% coverage for active parts, bugfix for …
acieroid Jan 5, 2022
27f5830
[activespart-missing] Improve FirebaseFirestoreDAO types to reflect r…
acieroid Jan 6, 2022
9b2998b
[activeparts-missing] Improve Firestore DAOs
acieroid Jan 6, 2022
83e9942
[activeparts-missing] Fix linter issue
acieroid Jan 6, 2022
7b6cd58
[current-player-color] Remove duplicate function
acieroid Jan 7, 2022
a1bb4db
[current-player-color] Add current player color to tuto & online game…
acieroid Jan 9, 2022
c4afe2f
Merge branch 'develop' of github.com:EveryBoard/EveryBoard into curre…
acieroid Jan 9, 2022
d04ec75
[current-player-color] fix all expect-matcher errors and cover siam p…
acieroid Jan 9, 2022
812cd2c
[current-color-player] More coverage improvements
acieroid Jan 9, 2022
e7fc981
[AddTimeToOpponent] remove use of french false friend 'case'
MartinREMY42 Jan 9, 2022
b8dc6ba
[activeparts-missing] PR comments
acieroid Jan 10, 2022
0445aeb
Merge branch 'develop' of github.com:EveryBoard/EveryBoard into activ…
acieroid Jan 10, 2022
4c1625c
[a,ctiveparts-missing] Cover missing branch in GameService
acieroid Jan 10, 2022
dfe437d
[activeparts-missing] Move some files and rename classes
acieroid Jan 10, 2022
33d142e
[current-player-color] PR comments
acieroid Jan 10, 2022
04c750c
Merge branch 'develop' of github.com:EveryBoard/EveryBoard into curre…
acieroid Jan 10, 2022
63a49f6
[AddTimeToOpponent] adding again coverage file
MartinREMY42 Jan 10, 2022
2880c43
[AddTimeToOpponent] pulled develop from everyboard repo and fixed con…
MartinREMY42 Jan 11, 2022
3b90a28
[P4Enhance] Fixed conflict
MartinREMY42 Jan 11, 2022
b70e433
[Brandhub] Update images
acieroid Jan 11, 2022
deffb0c
Merge pull request #7 from EveryBoard/current-player-color
MartinREMY42 Jan 11, 2022
798b917
Merge pull request #8 from EveryBoard/Brandhub
acieroid Jan 11, 2022
2c1b886
[P4Enhance] pulled everyboard/develop and fixed conflict
MartinREMY42 Jan 11, 2022
a4c4501
[P4Enhance] fix coverage.py and csvs
MartinREMY42 Jan 11, 2022
c1766ed
[P4Enhance] Fix coverage.py
acieroid Jan 11, 2022
659ec4f
Merge pull request #9 from EveryBoard/P4Enhance
acieroid Jan 12, 2022
55ba6af
[AddTimeToOpponent] pulled develop and fixed conflict + PR Comment
MartinREMY42 Jan 12, 2022
181be4f
[AddTimeToOpponent] pulled everyboard develop and fixed conflict
MartinREMY42 Jan 13, 2022
f42f0bb
[activeparts-missing] Better handling of subscriptions
acieroid Jan 13, 2022
995b457
Merge branch 'develop' of github.com:EveryBoard/EveryBoard into activ…
acieroid Jan 13, 2022
9600ff0
[activeparts-missing] Fix new tests
acieroid Jan 13, 2022
de2c912
[AddTimeToOpponent] PR Comment Wave 3.1415926585
MartinREMY42 Jan 13, 2022
455f55b
[activeparts-missing] Further improve subscriptions
acieroid Jan 14, 2022
206563d
[P4Enhance] PR Comments Wave 2
MartinREMY42 Jan 14, 2022
e2f7440
Merge branch 'develop' of https://github.com/MartinREMY42/multi-game-…
MartinREMY42 Jan 14, 2022
7b07480
[activeparts-missing] Refactoring to subscriptions, fix all tests
acieroid Jan 14, 2022
62c323d
[activeparts-missing] Fix linter
acieroid Jan 14, 2022
c8beef1
Merge branch 'develop' of github.com:EveryBoard/EveryBoard into HEAD
acieroid Jan 14, 2022
334dae6
[activeparts-missing] Cover missing branch in part-creation
acieroid Jan 14, 2022
03b959e
Merge branch 'develop' of github.com:EveryBoard/EveryBoard into activ…
acieroid Jan 14, 2022
52751a8
[activeparts-missing] Fix linter issue
acieroid Jan 14, 2022
51dfa1f
[activeparts-missing] PR comments
acieroid Jan 17, 2022
e68cfb4
[improve-awale-and-quarto] Get 100% coverage for Awale
acieroid Jan 17, 2022
9f598a7
[improve-awale-and-quart] Fix conspirateurs component
acieroid Jan 17, 2022
f5c6153
[activeparts-missing] Fix linter
acieroid Jan 17, 2022
81ae90a
[improve-awale-and-quarto] Get 100% coverage of quarto
acieroid Jan 18, 2022
a9d38d4
[activeparts-missing] PR comments
acieroid Jan 19, 2022
f1ec01a
[activeparts-missing] Update version number
acieroid Jan 19, 2022
cb076b9
[activeparts-missing] Remove DomainWrapper and fix lint
acieroid Jan 20, 2022
fac3dc1
[improve-awale-and-quarto] PR comments and fix coverage.py
acieroid Jan 20, 2022
4c434c8
[improve-awale-and-quarto] Last PR comment
acieroid Jan 20, 2022
0d1c3ca
[improve-awale-and-quarto] Use expectToBeCreated for Quarto too
acieroid Jan 20, 2022
11378b6
[AddTimeToOpponent] PR Comment Wave 3
MartinREMY42 Jan 20, 2022
4d03e95
Merge pull request #12 from EveryBoard/improve-awale-and-quarto
MartinREMY42 Jan 20, 2022
3fe432f
[activeparts-missing] PR comments and renamings
acieroid Jan 21, 2022
3b9ce61
Merge branch 'develop' of github.com:EveryBoard/EveryBoard into activ…
acieroid Jan 21, 2022
dc22959
[activeparts-missing] Finalize renaming
acieroid Jan 21, 2022
b78944f
[activeparts-missing] Linter & coverage data
acieroid Jan 21, 2022
dd08381
Merge pull request #6 from EveryBoard/activeparts-missing
MartinREMY42 Jan 22, 2022
1d6f210
Redeploy failed develop deployment
acieroid Jan 22, 2022
91f318a
[AddTimeToOpponent] PR Comment wave 4
MartinREMY42 Jan 22, 2022
8c0391f
[AddTimeToOpponent] removed unused css
MartinREMY42 Jan 22, 2022
0b4c528
[AddTimeToOpponent] change french translation
MartinREMY42 Jan 22, 2022
faac669
[AddTimeToOpponent] Pulled Everyboard/develop and fixed conflict
MartinREMY42 Jan 24, 2022
7c7a7a2
[AddTimeToOpponent] Generate CSV file
MartinREMY42 Jan 24, 2022
bb6334a
[AddTimeToOpponent] rename case sensitivity on file naming
MartinREMY42 Jan 24, 2022
32f9b49
[AddTimeToOpponent] fix translation and linter
MartinREMY42 Jan 24, 2022
0d92ce2
[AddTimeToOpponent] updated coverage and translation
MartinREMY42 Jan 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
'plugin:jasmine/recommended',
],
rules: {
'jasmine/expect-matcher': ['error'],
'jasmine/new-line-before-expect': ['off'],
'jasmine/new-line-between-declarations': ['off'],
'no-warning-comments': [
Expand All @@ -42,7 +43,6 @@ module.exports = {
'@typescript-eslint/switch-exhaustiveness-check': ['warn'],
'@typescript-eslint/no-unused-expressions': ['warn'],
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/no-use-before-define': ['warn'],
acieroid marked this conversation as resolved.
Show resolved Hide resolved
'@typescript-eslint/no-useless-constructor': ['warn'],
'@typescript-eslint/typedef': [
'error',
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
/.sass-cache
/connect.lock
/coverage
! coverage/branches.csv
! coverage/functions.csv
! coverage/statements.csv
! coverage/lines.csv
! /coverage/branches.csv
! /coverage/functions.csv
! /coverage/statements.csv
! /coverage/lines.csv
/typings
acieroid marked this conversation as resolved.
Show resolved Hide resolved
*.log

Expand Down
41 changes: 18 additions & 23 deletions coverage/branches.csv
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
AttackEpaminondasMinimax.ts,1
AwaleRules.ts,2
AwaleMinimax.ts,2
AuthenticationService.ts,1
ActivesPartsService.ts,4
ActivesUsersService.ts,1
count-down.component.ts,1
Coord.ts,1
CoerceoPiecesThreatTilesMinimax.ts,3
GameWrapper.ts,1
GoGroupsDatas.ts,5
HexagonalGameState.ts,3
LinesOfActionRules.ts,1
MGPNode.ts,1
online-game-wrapper.component.ts,11
ObjectUtils.ts,3
Player.ts,1
PylosState.ts,1
PositionalEpaminondasMinimax.ts,1
QuartoHasher.ts,1
QuartoRules.ts,3
SixMinimax.ts,6
SiamPiece.ts,1
AwaleMinimax.ts,2
AwaleRules.ts,2
AttackEpaminondasMinimax.ts,1
ActivesPartsService.ts,3
ActivesUsersService.ts,1
AuthenticationService.ts,1
CoerceoPiecesThreatTilesMinimax.ts,3
GameWrapper.ts,1
GoGroupsDatas.ts,5
HexagonalGameState.ts,3
LinesOfActionRules.ts,1
MGPNode.ts,1
online-game-wrapper.component.ts,13
ObjectUtils.ts,3
PositionalEpaminondasMinimax.ts,1
PylosState.ts,1
QuartoHasher.ts,1
QuartoRules.ts,3
17 changes: 7 additions & 10 deletions coverage/functions.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
AuthenticationService.ts,2
ActivesPartsService.ts,5
ActivesUsersService.ts,3
NodeUnheritance.ts,1
online-game-wrapper.component.ts,2
PieceThreat.ts,1
PylosState.ts,1
QuartoRules.ts,1
server-page.component.ts,1
SixMinimax.ts,3
ActivesPartsService.ts,2
ActivesUsersService.ts,3
AuthenticationService.ts,2
online-game-wrapper.component.ts,1
PieceThreat.ts,1
QuartoRules.ts,1
server-page.component.ts,1
39 changes: 17 additions & 22 deletions coverage/lines.csv
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
AwaleRules.ts,1
AuthenticationService.ts,3
ActivesPartsService.ts,13
ActivesUsersService.ts,3
CoerceoPiecesThreatTilesMinimax.ts,1
GameWrapper.ts,1
GoGroupsDatas.ts,4
HexagonalGameState.ts,6
LinesOfActionRules.ts,1
MGPNode.ts,1
NodeUnheritance.ts,1
online-game-wrapper.component.ts,9
ObjectUtils.ts,2
PieceThreat.ts,1
Player.ts,2
PylosState.ts,1
PositionalEpaminondasMinimax.ts,1
QuartoHasher.ts,1
QuartoRules.ts,5
server-page.component.ts,1
SixMinimax.ts,13
SiamPiece.ts,1
AwaleRules.ts,1
ActivesPartsService.ts,6
ActivesUsersService.ts,3
AuthenticationService.ts,3
CoerceoPiecesThreatTilesMinimax.ts,1
GameWrapper.ts,1
GoGroupsDatas.ts,4
HexagonalGameState.ts,6
LinesOfActionRules.ts,1
MGPNode.ts,1
online-game-wrapper.component.ts,11
ObjectUtils.ts,2
PositionalEpaminondasMinimax.ts,1
PieceThreat.ts,1
QuartoHasher.ts,1
QuartoRules.ts,5
server-page.component.ts,1
41 changes: 18 additions & 23 deletions coverage/statements.csv
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
AwaleRules.ts,1
AuthenticationService.ts,3
ActivesPartsService.ts,15
ActivesUsersService.ts,5
Coord.ts,1
CoerceoPiecesThreatTilesMinimax.ts,1
GameWrapper.ts,1
GoGroupsDatas.ts,4
HexagonalGameState.ts,6
LinesOfActionRules.ts,1
MGPNode.ts,1
NodeUnheritance.ts,1
online-game-wrapper.component.ts,9
ObjectUtils.ts,2
PieceThreat.ts,1
Player.ts,2
PylosState.ts,2
PositionalEpaminondasMinimax.ts,1
QuartoHasher.ts,1
QuartoRules.ts,5
server-page.component.ts,1
SixMinimax.ts,13
SiamPiece.ts,1
AwaleRules.ts,1
ActivesPartsService.ts,7
ActivesUsersService.ts,5
AuthenticationService.ts,3
CoerceoPiecesThreatTilesMinimax.ts,1
GameWrapper.ts,1
GoGroupsDatas.ts,4
HexagonalGameState.ts,6
LinesOfActionRules.ts,1
MGPNode.ts,1
online-game-wrapper.component.ts,11
ObjectUtils.ts,2
PositionalEpaminondasMinimax.ts,1
PylosState.ts,1
PieceThreat.ts,1
QuartoHasher.ts,1
QuartoRules.ts,5
server-page.component.ts,1
5 changes: 3 additions & 2 deletions scripts/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
print('Usage: %s [generate|check]' % sys.argv[0])
exit(1)

def sort_function(x):
return str.lower(x[0])
def sort_function(file_and_coverage):
return str.lower(file_and_coverage[0])

def to_missing(x):
"Converts from the string AA/BB to the number BB-AA"
[low, high] = x.split('/')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<div>
<div class="level"
[ngClass]="getTimeClass()"
>
<p id="remainingTime"
[ngClass]="getTimeClass()">{{ displayedMinute }}:{{ displayedSec | number:'2.0-0' }}</p>
class="level-item"
>{{ displayedMinute }}:{{ displayedSec | number:'2.0-0' }}</p>
<button id="addTimeButton"
class="button level-item is-small"
*ngIf="canAddTime"
(click)="addTime()"
i18n>Add {{ timeToAdd }} to chrono</button>
acieroid marked this conversation as resolved.
Show resolved Hide resolved
</div>
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
/* eslint-disable max-lines-per-function */
import { DebugElement } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { fakeAsync, tick } from '@angular/core/testing';
import { SimpleComponentTestUtils } from 'src/app/utils/tests/TestUtils.spec';
import { CountDownComponent } from './count-down.component';

describe('CountDownComponent', () => {

let component: CountDownComponent;
let testUtils: SimpleComponentTestUtils<CountDownComponent>;

let fixture: ComponentFixture<CountDownComponent>;
let component: CountDownComponent;

beforeEach(fakeAsync(async() => {
await TestBed.configureTestingModule({
declarations: [CountDownComponent],
}).compileComponents();
fixture = TestBed.createComponent(CountDownComponent);
component = fixture.componentInstance;
fixture.detectChanges();
testUtils = await SimpleComponentTestUtils.create(CountDownComponent);
component = testUtils.getComponent();
}));
it('should create', () => {
expect(component).toBeTruthy();
Expand All @@ -41,14 +37,15 @@ describe('CountDownComponent', () => {
});
it('should show remaining time once set', () => {
component.setDuration(62000);
fixture.detectChanges();
const element: DebugElement = fixture.debugElement.query(By.css('#remainingTime'));
const timeText: string = element.nativeElement.innerHTML;
testUtils.detectChanges();
const element: DebugElement = testUtils.findElement('#remainingTime');
const timeText: string = element.nativeElement.innerText;
expect(timeText).toBe('1:02');
});
it('should throw when starting stopped chrono again', () => {
component.setDuration(1250);
component.start();
expect(component.isStarted()).toBeTrue();
component.stop();
expect(() => component.start()).toThrowError('Should not start a chrono that has not been set!');
});
Expand Down Expand Up @@ -93,34 +90,34 @@ describe('CountDownComponent', () => {
component.setDuration(3000);
component.start();
tick(1000);
fixture.detectChanges();
let timeText: string = fixture.debugElement.query(By.css('#remainingTime')).nativeElement.innerHTML;
testUtils.detectChanges();
let timeText: string = testUtils.findElement('#remainingTime').nativeElement.innerText;
expect(timeText).toBe('0:02');
tick(1000);
fixture.detectChanges();
timeText = fixture.debugElement.query(By.css('#remainingTime')).nativeElement.innerHTML;
testUtils.detectChanges();
timeText = testUtils.findElement('#remainingTime').nativeElement.innerText;
expect(timeText).toBe('0:01');
component.stop();
}));
it('should update written time correctly (closest rounding) even when playing in less than refreshing time', fakeAsync(() => {
spyOn(component.outOfTimeAction, 'emit').and.callThrough();
component.setDuration(599501); // 9 minutes 59 sec 501 ms
fixture.detectChanges();
let timeText: string = fixture.debugElement.query(By.css('#remainingTime')).nativeElement.innerHTML;
component.setDuration((9 * 60 + 59) * 1000 + 501); // 9 minutes 59 sec 501 ms
testUtils.detectChanges();
let timeText: string = testUtils.findElement('#remainingTime').nativeElement.innerText;
expect(timeText).toBe('9:59');
component.start();

tick(401); // 9 min 59.501s -> 9 min 59.1 (9:59)
component.pause();
fixture.detectChanges();
timeText = fixture.debugElement.query(By.css('#remainingTime')).nativeElement.innerHTML;
testUtils.detectChanges();
timeText = testUtils.findElement('#remainingTime').nativeElement.innerText;
expect(timeText).toBe('9:59');

component.resume();
tick(200); // 9 min 59.1 -> 9 min 58.9 (9:58)
component.pause();
fixture.detectChanges();
timeText = fixture.debugElement.query(By.css('#remainingTime')).nativeElement.innerHTML;
testUtils.detectChanges();
timeText = testUtils.findElement('#remainingTime').nativeElement.innerText;
expect(timeText).toBe('9:58');
}));
it('should emit when timeout reached', fakeAsync(() => {
Expand All @@ -132,21 +129,44 @@ describe('CountDownComponent', () => {
tick(1000);
expect(component.outOfTimeAction.emit).toHaveBeenCalledOnceWith();
}));
describe('Add Time Button', () => {
it('should offer opportunity to add time if allowed', fakeAsync(async() => {
// Given a CountDownComponent allowed to add time
component.canAddTime = true;
component.remainingMs = 60 * 1000;
testUtils.detectChanges();

// When clicking the add time button
spyOn(component.addTimeToOpponent, 'emit').and.callThrough();
await testUtils.clickElement('#addTimeButton');

// Then the component should have called addTimeToOpponent
expect(component.addTimeToOpponent.emit).toHaveBeenCalledOnceWith();
}));
it('should not display button when not allowed to add time', fakeAsync(async() => {
// Given a CountDownComponent not allowed to add time
component.canAddTime = false;
testUtils.detectChanges();

// Then the component should not have that button
testUtils.expectElementNotToExist('#addTimeButton');
}));
});
describe('Style depending of remaining time', () => {
it('Should be safe style when upper than limit', () => {
component.dangerTimeLimit = 10 * 1000;
component.setDuration(12 * 1000);
expect(component.getTimeClass()).toEqual(component.SAFE_TIME);
expect(component.getTimeClass()).toEqual(CountDownComponent.SAFE_TIME);
});
it('Should be first danger style when lower than limit and even remaining second', () => {
component.dangerTimeLimit = 10 * 1000;
component.setDuration(9 * 1000);
expect(component.getTimeClass()).toEqual(component.DANGER_TIME_EVEN);
expect(component.getTimeClass()).toEqual(CountDownComponent.DANGER_TIME_EVEN);
});
it('Should be second danger style when lower than limit and odd remaining second', () => {
component.dangerTimeLimit = 10 * 1000;
component.setDuration(8 * 1000);
expect(component.getTimeClass()).toEqual(component.DANGER_TIME_ODD);
expect(component.getTimeClass()).toEqual(CountDownComponent.DANGER_TIME_ODD);
});
it('Should be in passive style when passive', () => {
// given a chrono that could be in danger time style
Expand All @@ -156,7 +176,7 @@ describe('CountDownComponent', () => {
component.active = false;

// then it should still be in passive style
expect(component.getTimeClass()).toEqual(component.PASSIVE_STYLE);
expect(component.getTimeClass()).toEqual(CountDownComponent.PASSIVE_STYLE);
});
});
});
Loading