forked from lichess-org/mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuzzle_screen_test.dart
More file actions
625 lines (503 loc) · 22.7 KB
/
puzzle_screen_test.dart
File metadata and controls
625 lines (503 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
import 'package:chessground/chessground.dart';
import 'package:dartchess/dartchess.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/testing.dart';
import 'package:lichess_mobile/src/model/account/account_preferences.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_batch_storage.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_difficulty.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_preferences.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_storage.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
import 'package:lichess_mobile/src/network/http.dart';
import 'package:lichess_mobile/src/utils/string.dart';
import 'package:lichess_mobile/src/view/puzzle/puzzle_screen.dart';
import 'package:lichess_mobile/src/widgets/bottom_bar_button.dart';
import 'package:mocktail/mocktail.dart';
import '../../model/auth/fake_session_storage.dart';
import '../../test_helpers.dart';
import '../../test_provider_scope.dart';
import 'example_data.dart';
class MockPuzzleBatchStorage extends Mock implements PuzzleBatchStorage {}
class MockPuzzleStorage extends Mock implements PuzzleStorage {}
class MockPuzzlePreferences extends PuzzlePreferences with Mock {
MockPuzzlePreferences(this._rated);
final bool _rated;
@override
PuzzlePrefs build() {
return PuzzlePrefs(
id: fakeSession.user.id,
difficulty: PuzzleDifficulty.normal,
autoNext: false,
rated: _rated,
);
}
}
void main() {
setUpAll(() {
registerFallbackValue(PuzzleBatch(solved: IList(const []), unsolved: IList([puzzle])));
registerFallbackValue(puzzle);
});
final mockBatchStorage = MockPuzzleBatchStorage();
final mockHistoryStorage = MockPuzzleStorage();
group('PuzzleScreen', () {
testWidgets('meets accessibility guidelines', variant: kPlatformVariant, (
WidgetTester tester,
) async {
final SemanticsHandle handle = tester.ensureSemantics();
final app = await makeTestProviderScopeApp(
tester,
home: PuzzleScreen(
angle: const PuzzleTheme(PuzzleThemeKey.mix),
puzzleId: puzzle.puzzle.id,
),
overrides: [
puzzleBatchStorageProvider.overrideWith((ref) => mockBatchStorage),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
],
);
when(
() => mockHistoryStorage.fetch(puzzleId: puzzle.puzzle.id),
).thenAnswer((_) async => puzzle);
await tester.pumpWidget(app);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
await meetsTapTargetGuideline(tester);
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('Loads puzzle directly by passing a puzzleId', variant: kPlatformVariant, (
tester,
) async {
final app = await makeTestProviderScopeApp(
tester,
home: PuzzleScreen(
angle: const PuzzleTheme(PuzzleThemeKey.mix),
puzzleId: puzzle.puzzle.id,
),
overrides: [
puzzleBatchStorageProvider.overrideWith((ref) => mockBatchStorage),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
],
);
when(
() => mockHistoryStorage.fetch(puzzleId: puzzle.puzzle.id),
).thenAnswer((_) async => puzzle);
await tester.pumpWidget(app);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
expect(find.byType(Chessboard), findsOneWidget);
expect(find.text('Your turn'), findsOneWidget);
});
testWidgets('Loads next puzzle when no puzzleId is passed', (tester) async {
final app = await makeTestProviderScopeApp(
tester,
home: const PuzzleScreen(angle: PuzzleTheme(PuzzleThemeKey.mix)),
overrides: [
puzzleBatchStorageProvider.overrideWith((ref) => mockBatchStorage),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
],
);
when(
() => mockBatchStorage.fetch(userId: null, angle: const PuzzleTheme(PuzzleThemeKey.mix)),
).thenAnswer((_) async => batch);
when(() => mockHistoryStorage.save(puzzle: any(named: 'puzzle'))).thenAnswer((_) async {});
await tester.pumpWidget(app);
expect(find.byType(Chessboard), findsNothing);
expect(find.text('Your turn'), findsNothing);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
expect(find.byType(Chessboard), findsOneWidget);
expect(find.text('Your turn'), findsOneWidget);
});
testWidgets('solves a puzzle and loads the next one', variant: kPlatformVariant, (
tester,
) async {
final mockClient = MockClient((request) {
if (request.url.path == '/api/puzzle/batch/mix') {
return mockResponse(batchOf1, 200);
}
return mockResponse('', 404);
});
when(
() => mockHistoryStorage.fetch(puzzleId: puzzle2.puzzle.id),
).thenAnswer((_) async => puzzle2);
final app = await makeTestProviderScopeApp(
tester,
home: PuzzleScreen(
angle: const PuzzleTheme(PuzzleThemeKey.mix),
puzzleId: puzzle2.puzzle.id,
),
overrides: [
lichessClientProvider.overrideWith((ref) {
return LichessClient(mockClient, ref);
}),
puzzleBatchStorageProvider.overrideWith((ref) {
return mockBatchStorage;
}),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
],
);
Future<void> saveDBReq() => mockBatchStorage.save(
userId: null,
angle: const PuzzleTheme(PuzzleThemeKey.mix),
data: any(named: 'data'),
);
when(saveDBReq).thenAnswer((_) async {});
when(
() => mockBatchStorage.fetch(userId: null, angle: const PuzzleTheme(PuzzleThemeKey.mix)),
).thenAnswer((_) async => batch);
when(() => mockHistoryStorage.save(puzzle: any(named: 'puzzle'))).thenAnswer((_) async {});
await tester.pumpWidget(app);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
expect(find.byType(Chessboard), findsOneWidget);
expect(find.text('Your turn'), findsOneWidget);
// before the first move is played, puzzle is not interactable
expect(find.byKey(const Key('g4-blackrook')), findsOneWidget);
await tester.tap(find.byKey(const Key('g4-blackrook')));
await tester.pump();
expect(find.byKey(const Key('g4-selected')), findsNothing);
const orientation = Side.black;
// wait for first move to be played
await tester.pump(const Duration(milliseconds: 1500));
// in play mode we don't see the continue button
expect(find.byIcon(CupertinoIcons.play_arrow_solid), findsNothing);
// in play mode we see the solution button
expect(find.byIcon(Icons.help), findsOneWidget);
expect(find.byKey(const Key('g4-blackrook')), findsOneWidget);
expect(find.byKey(const Key('h8-whitequeen')), findsOneWidget);
await playMove(tester, 'g4', 'h4', orientation: orientation);
expect(find.byKey(const Key('h4-blackrook')), findsOneWidget);
expect(find.text('Best move!'), findsOneWidget);
// wait for line reply and move animation
await tester.pump(const Duration(milliseconds: 500));
await tester.pumpAndSettle();
expect(find.byKey(const Key('h4-whitequeen')), findsOneWidget);
await playMove(tester, 'b4', 'h4', orientation: orientation);
expect(find.byKey(const Key('h4-blackrook')), findsOneWidget);
expect(find.text('Success!'), findsOneWidget);
// wait for move animation
await tester.pumpAndSettle();
// called once to save solution and once after fetching a new puzzle
verify(saveDBReq).called(2);
expect(find.byIcon(CupertinoIcons.play_arrow_solid), findsOneWidget);
expect(find.byIcon(Icons.help), findsNothing);
await tester.tap(find.byIcon(CupertinoIcons.play_arrow_solid));
// await for new puzzle load
await tester.pump(const Duration(milliseconds: 500));
expect(find.text('Success!'), findsNothing);
expect(find.text('Your turn'), findsOneWidget);
});
for (final showRatings in ShowRatings.values) {
testWidgets('fails a puzzle, (showRatings: $showRatings)', variant: kPlatformVariant, (
tester,
) async {
final mockClient = MockClient((request) {
if (request.url.path == '/api/puzzle/batch/mix') {
return mockResponse(batchOf1, 200);
}
return mockResponse('', 404);
});
when(
() => mockHistoryStorage.fetch(puzzleId: puzzle2.puzzle.id),
).thenAnswer((_) async => puzzle2);
final app = await makeTestProviderScopeApp(
tester,
home: PuzzleScreen(
angle: const PuzzleTheme(PuzzleThemeKey.mix),
puzzleId: puzzle2.puzzle.id,
),
overrides: [
lichessClientProvider.overrideWith((ref) {
return LichessClient(mockClient, ref);
}),
puzzleBatchStorageProvider.overrideWith((ref) {
return mockBatchStorage;
}),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
showRatingsPrefProvider.overrideWith((ref) {
return showRatings;
}),
],
);
when(() => mockHistoryStorage.save(puzzle: any(named: 'puzzle'))).thenAnswer((_) async {});
Future<void> saveDBReq() => mockBatchStorage.save(
userId: null,
angle: const PuzzleTheme(PuzzleThemeKey.mix),
data: any(named: 'data'),
);
when(saveDBReq).thenAnswer((_) async {});
when(
() => mockBatchStorage.fetch(userId: null, angle: const PuzzleTheme(PuzzleThemeKey.mix)),
).thenAnswer((_) async => batch);
await tester.pumpWidget(app);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
expect(find.byType(Chessboard), findsOneWidget);
expect(find.text('Your turn'), findsOneWidget);
const orientation = Side.black;
// await for first move to be played
await tester.pump(const Duration(milliseconds: 1500));
expect(find.byKey(const Key('g4-blackrook')), findsOneWidget);
await playMove(tester, 'g4', 'f4', orientation: orientation);
expect(find.text("That's not the move!"), findsOneWidget);
// wait for move cancel and animation
await tester.pump(const Duration(milliseconds: 500));
await tester.pumpAndSettle();
// can still play the puzzle
expect(find.byKey(const Key('g4-blackrook')), findsOneWidget);
await playMove(tester, 'g4', 'h4', orientation: orientation);
expect(find.byKey(const Key('h4-blackrook')), findsOneWidget);
expect(find.text('Best move!'), findsOneWidget);
// wait for line reply and move animation
await tester.pump(const Duration(milliseconds: 500));
await tester.pumpAndSettle();
await playMove(tester, 'b4', 'h4', orientation: orientation);
expect(find.byKey(const Key('h4-blackrook')), findsOneWidget);
expect(find.text('Puzzle complete!'), findsOneWidget);
final expectedPlayedXTimes =
'Played ${puzzle2.puzzle.plays.toString().localizeNumbers()} times.';
expect(
find.text(
showRatings == ShowRatings.no
? expectedPlayedXTimes
: 'Rating: ${puzzle2.puzzle.rating}. $expectedPlayedXTimes',
),
findsOneWidget,
);
// wait for move animation
await tester.pumpAndSettle();
// called once to save solution and once after fetching a new puzzle
verify(saveDBReq).called(2);
});
}
testWidgets('view solution', variant: kPlatformVariant, (tester) async {
final mockClient = MockClient((request) {
if (request.url.path == '/api/puzzle/batch/mix') {
return mockResponse(batchOf1, 200);
}
return mockResponse('', 404);
});
final app = await makeTestProviderScopeApp(
tester,
home: PuzzleScreen(
angle: const PuzzleTheme(PuzzleThemeKey.mix),
puzzleId: puzzle2.puzzle.id,
),
overrides: [
lichessClientProvider.overrideWith((ref) {
return LichessClient(mockClient, ref);
}),
puzzleBatchStorageProvider.overrideWith((ref) {
return mockBatchStorage;
}),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
],
);
when(
() => mockHistoryStorage.fetch(puzzleId: puzzle2.puzzle.id),
).thenAnswer((_) async => puzzle2);
when(() => mockHistoryStorage.save(puzzle: any(named: 'puzzle'))).thenAnswer((_) async {});
Future<void> saveDBReq() => mockBatchStorage.save(
userId: null,
angle: const PuzzleTheme(PuzzleThemeKey.mix),
data: any(named: 'data'),
);
when(saveDBReq).thenAnswer((_) async {});
when(
() => mockBatchStorage.fetch(userId: null, angle: const PuzzleTheme(PuzzleThemeKey.mix)),
).thenAnswer((_) async => batch);
await tester.pumpWidget(app);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
expect(find.byType(Chessboard), findsOneWidget);
expect(find.text('Your turn'), findsOneWidget);
// await for first move to be played
await tester.pump(const Duration(milliseconds: 1500));
expect(find.byKey(const Key('g4-blackrook')), findsOneWidget);
// Help button should still be disabled
expect(find.byIcon(Icons.help), findsOneWidget);
expect(
tester
.firstWidget<BottomBarButton>(
find.ancestor(of: find.byIcon(Icons.help), matching: find.byType(BottomBarButton)),
)
.enabled,
isFalse,
);
// wait for the solution button to be enabled
await tester.pump(const Duration(seconds: 4));
await tester.tap(find.byIcon(Icons.help));
// wait for solution replay animation to finish
await tester.pump(const Duration(seconds: 1));
expect(find.byKey(const Key('h4-blackrook')), findsOneWidget);
expect(find.byKey(const Key('h8-whitequeen')), findsOneWidget);
expect(find.text('Puzzle complete!'), findsOneWidget);
final nextMoveBtnEnabled = find.byWidgetPredicate(
(widget) =>
widget is BottomBarButton &&
widget.icon == CupertinoIcons.chevron_forward &&
widget.enabled,
);
expect(nextMoveBtnEnabled, findsOneWidget);
// advance to next move of solution
await tester.tap(nextMoveBtnEnabled);
expect(find.byIcon(CupertinoIcons.play_arrow_solid), findsOneWidget);
// called once to save solution and once after fetching a new puzzle
verify(saveDBReq).called(2);
});
for (final isRatedPreference in [true, false]) {
testWidgets(
'puzzle rating is saved correctly, (isRatedPreference: $isRatedPreference)',
variant: kPlatformVariant,
(WidgetTester tester) async {
final mockClient = MockClient((request) {
if (request.url.path == '/api/puzzle/batch/mix') {
return mockResponse(batchOf1, 200);
}
return mockResponse('', 404);
});
final app = await makeTestProviderScopeApp(
tester,
home: PuzzleScreen(
angle: const PuzzleTheme(PuzzleThemeKey.mix),
puzzleId: puzzle2.puzzle.id,
),
overrides: [
lichessClientProvider.overrideWith((ref) {
return LichessClient(mockClient, ref);
}),
puzzleBatchStorageProvider.overrideWith((ref) => mockBatchStorage),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
puzzlePreferencesProvider.overrideWith(
() => MockPuzzlePreferences(isRatedPreference),
),
],
userSession: fakeSession,
);
Future<void> saveDBReq() => mockBatchStorage.save(
userId: fakeSession.user.id,
angle: const PuzzleTheme(PuzzleThemeKey.mix),
data: captureAny(named: 'data'),
);
when(saveDBReq).thenAnswer((_) async {});
when(
() => mockBatchStorage.fetch(
userId: fakeSession.user.id,
angle: const PuzzleTheme(PuzzleThemeKey.mix),
),
).thenAnswer((_) async => batch);
when(
() => mockHistoryStorage.save(puzzle: any(named: 'puzzle')),
).thenAnswer((_) async {});
await tester.pumpWidget(app);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
// wait for first move to be played and view solution button to appear
await tester.pump(const Duration(seconds: 5));
// view solution
expect(find.byIcon(Icons.help), findsOneWidget);
await tester.tap(find.byIcon(Icons.help));
// wait for solution replay animation to finish
await tester.pump(const Duration(seconds: 1));
// check puzzle was saved as isRatedPreference
final captured = verify(saveDBReq).captured.map((e) => e as PuzzleBatch).toList();
expect(captured.length, 2);
expect(captured[0].solved, [
PuzzleSolution(id: puzzle2.puzzle.id, win: false, rated: isRatedPreference),
]);
expect(captured[1].solved.length, 0);
},
);
}
testWidgets('puzzle rating is saved correctly when hint is used', variant: kPlatformVariant, (
WidgetTester tester,
) async {
final mockClient = MockClient((request) {
if (request.url.path == '/api/puzzle/batch/mix') {
return mockResponse(batchOf1, 200);
}
return mockResponse('', 404);
});
final app = await makeTestProviderScopeApp(
tester,
home: PuzzleScreen(
angle: const PuzzleTheme(PuzzleThemeKey.mix),
puzzleId: puzzle2.puzzle.id,
),
overrides: [
lichessClientProvider.overrideWith((ref) {
return LichessClient(mockClient, ref);
}),
puzzleBatchStorageProvider.overrideWith((ref) => mockBatchStorage),
puzzleStorageProvider.overrideWith((ref) => mockHistoryStorage),
puzzlePreferencesProvider.overrideWith(() => MockPuzzlePreferences(true)),
],
userSession: fakeSession,
);
Future<void> saveDBReq() => mockBatchStorage.save(
userId: fakeSession.user.id,
angle: const PuzzleTheme(PuzzleThemeKey.mix),
data: captureAny(named: 'data'),
);
when(saveDBReq).thenAnswer((_) async {});
when(
() => mockBatchStorage.fetch(
userId: fakeSession.user.id,
angle: const PuzzleTheme(PuzzleThemeKey.mix),
),
).thenAnswer((_) async => batch);
when(() => mockHistoryStorage.save(puzzle: any(named: 'puzzle'))).thenAnswer((_) async {});
await tester.pumpWidget(app);
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
// wait for first move to be played and hint/view solution buttons to appear
await tester.pump(const Duration(seconds: 5));
// check possible hint widgets before hint is set
final customPaintWidgetsBefore = find.byType(CustomPaint).evaluate().toSet();
// get hint and wait for it to show
expect(find.byIcon(Icons.info), findsOneWidget);
await tester.tap(find.byIcon(Icons.info));
await tester.pump(const Duration(milliseconds: 100));
// check hint is set
final customPaintWidgetsAfter = find.byType(CustomPaint).evaluate();
expect(customPaintWidgetsAfter.length, customPaintWidgetsBefore.length + 1);
final diff = customPaintWidgetsAfter.toSet().difference(customPaintWidgetsBefore);
expect(diff.length, 1);
expect((diff.first.widget as CustomPaint).painter.runtimeType.toString(), '_CirclePainter');
// view solution
expect(find.byIcon(Icons.help), findsOneWidget);
await tester.tap(find.byIcon(Icons.help));
// wait for solution replay animation to finish
await tester.pump(const Duration(seconds: 1));
// go to next puzzle
expect(find.byIcon(CupertinoIcons.play_arrow_solid), findsOneWidget);
await tester.tap(find.byIcon(CupertinoIcons.play_arrow_solid));
// wait for the puzzle to load
await tester.pump(const Duration(milliseconds: 200));
// wait for first move to be played and hint/view solution buttons to appear
await tester.pump(const Duration(seconds: 5));
// view solution
expect(find.byIcon(Icons.help), findsOneWidget);
await tester.tap(find.byIcon(Icons.help));
// wait for solution replay animation to finish
await tester.pump(const Duration(seconds: 1));
// check first puzzle was unrated due to hint
// and following puzzles are still rated when not using the hint
final captured = verify(saveDBReq).captured.map((e) => e as PuzzleBatch).toList();
expect(captured.length, 4);
expect(captured[0].solved, [PuzzleSolution(id: puzzle2.puzzle.id, win: false, rated: false)]);
expect(captured[1].solved.length, 0);
expect(captured[2].solved, [PuzzleSolution(id: puzzle.puzzle.id, win: false, rated: true)]);
expect(captured[3].solved.length, 0);
});
});
}
const batchOf1 = '''
{"puzzles":[{"game":{"id":"PrlkCqOv","perf":{"key":"rapid","name":"Rapid"},"rated":true,"players":[{"name":"silverjo", "rating":1777,"color":"white"},{"name":"Robyarchitetto", "rating":1742,"color":"black"}],"pgn":"e4 Nc6 Bc4 e6 a3 g6 Nf3 Bg7 c3 Nge7 d3 O-O Be3 Na5 Ba2 b6 Qd2 Bb7 Bh6 d5 e5 d4 Bxg7 Kxg7 Qf4 Bxf3 Qxf3 dxc3 Nxc3 Nac6 Qf6+ Kg8 Rd1 Nd4 O-O c5 Ne4 Nef5 Rd2 Qxf6 Nxf6+ Kg7 Re1 h5 h3 Rad8 b4 Nh4 Re3 Nhf5 Re1 a5 bxc5 bxc5 Bc4 Ra8 Rb1 Nh4 Rdb2 Nc6 Rb7 Nxe5 Bxe6 Kxf6 Bd5 Nf5 R7b6+ Kg7 Bxa8 Rxa8 R6b3 Nd4 Rb7 Nxd3 Rd1 Ne2+ Kh2 Ndf4 Rdd7 Rf8 Ra7 c4 Rxa5 c3 Rc5 Ne6 Rc4 Ra8 a4 Rb8 a5 Rb2 a6 c2","clock":"5+8"},"puzzle":{"id":"20yWT","rating":1859,"plays":551,"initialPly":93,"solution":["a6a7","b2a2","c4c2","a2a7","d7a7"],"themes":["endgame","long","advantage","advancedPawn"]}}]}
''';