Test/video text - #74
Conversation
emil720a1
left a comment
There was a problem hiding this comment.
I found several blockers during the local review. The branch currently fails to build with 9 errors: GetRequiredConnectionString() was removed while existing tests still depend on it, and GetAllPartnerShortHandler is no longer accessible from its tests.
This PR also appears to revert unrelated functionality from dev, including Term creation, Fact DisplayOrder and sorting, connection-string validation, and ASPNETCORE_ENVIRONMENT. Please restore unrelated files to their current dev versions and keep this PR focused on the intended Video/Text changes.
Additionally, please check the following:
Text column length changes require an EF migration.
Some added Streetcode DTO and handler files are empty.
Several files contain CRLF/trailing-whitespace issues.
Ukrainian strings are corrupted and should be restored using UTF-8 encoding.
Video tests should include a successful request with a valid YouTube URL.
If the Create/Preview production endpoints are intentionally part of this task, please document them in the PR description; otherwise, they should be moved to a separate feature PR.
DrFaust555
left a comment
There was a problem hiding this comment.
-
The branch does not compile. CI shows Build FAILED with 10 errors and no
tests ran. Restore GetRequiredConnectionString in
ConfigurationBuilderExtensions.cs (DbUpdate/Program.cs and
ConfigurationBuilderExtensionsTests.cs call it) and make
GetAllPartnerShortHandler public again. -
The PR reverts unrelated work from dev. Restore these files to their dev
versions: Fact.cs and FactDTO.cs (DisplayOrder), GetAllFactsHandler.cs and
GetFactByStreetcodeIdHandler.cs (OrderBy DisplayOrder), TermProfile.cs
(TermCreateDTO map), TermController.cs (Create action),
ServiceCollectionExtensions.cs, launchSettings.json
(ASPNETCORE_ENVIRONMENT), StreetcodeController.cs (line-ending-only
change), .github/workflows/build.yml. -
Fact.DisplayOrder is removed from the entity, but migration
20260817084414_AddDisplayOrderToFact and the snapshot still have the
column. The model no longer matches the snapshot. Fixed by item 2. -
Delete the six empty files: StreetcodeCreateDTO.cs, StreetcodeUpdateDTO.cs,
CreateStreetcodeCommand.cs, CreateStreetcodeHandler.cs,
UpdateStreetcodeCommand.cs, UpdateStreetcodeHandler.cs. -
CreateTextHandler.cs line 32, TextProfileTests.cs, CreateTextHandlerTests.cs,
AddTermsToTextServiceTests.cs: the Ukrainian strings are stored as "?"
bytes. The comparison with "Текст підготовлений спільно з" can never match.
Re-save the files as UTF-8 and retype the strings. Put the default text in
one constant and use it from the handler and the tests. -
Migration UpdateTextColumnLengths narrows Title 300 to 50 and
AdditionalText 500 to 200 without handling existing rows longer than the
new limit. The migration fails on such data. Add an UPDATE that trims the
values before AlterColumn, or keep the database lengths and enforce the
limits in the DTO only. -
VideoController.cs: two actions are both [HttpGet] with no route template
(GetAll and GetPreview). Give GetPreview its own template. Move the
YouTube check out of the controller into a validator for
CreateVideoCommand; the pipeline from #76 will run it. Accept youtu.be
and m.youtube.com as well, or state that they are rejected on purpose. -
GetVideoAdminPreviewHandler returns the input string unchanged. Either
return something useful (embed URL, video id) or drop the endpoint. -
VideoProfileTests.cs namespace Streetcode.XUnitTest.MappingTests.Media and
TextProfileTests.cs namespace Streetcode.XUnitTest.Mapping.Streetcode.
TextContent do not match the folder Mappings/. Use
Streetcode.XUnitTest.Mappings.. -
VideoControllerTests.cs has no test for a valid YouTube URL. Add one that
passes a mocked IMediator and asserts the command is sent. -
Squash the eleven "Add files via upload" commits into meaningful commits.
Fix the PR description: remove the stray "dev" line, replace the
placeholder JIRA link with the GitHub issue, fill in reviewers instead
of @github_username, add "Closes #". -
Fix the three SA1009 Sonar issues in CreateTextCommand.cs,
CreateVideoCommand.cs and GetVideoForAdminPreviewCommand.cs.
c5e4604 to
1dc9ca0
Compare
Loki22978964
left a comment
There was a problem hiding this comment.
I ran a review and found a few issues that need to be fixed before the merge:
- Loss of fact sorting (regression)
In GetAllFactsHandler and GetFactByStreetcodeIdHandler, OrderBy(f => f.DisplayOrder) was removed, even though the DisplayOrder field hasn’t gone anywhere—it’s still present in FactDto and in the model. This looks like an accidental loss during the merge rather than a deliberate decision. If this wasn’t intentional, we need to restore the sorting; otherwise, facts will be returned from the database in random order, which will break the front-end display.
- Inconsistent validation of YouTube links (logic is scattered across three places)
I noticed that the validation of YouTube URLs is duplicated and, more importantly, inconsistent:
VideoController.Create manually checks only the hosts youtube.com and www.youtube.com;
CreateVideoCommandValidator allows a broader list—including youtu.be and m.youtube.com;
GetVideoAdminPreviewHandler contains its own, third, separate implementation of URL parsing.
Because of this, a link like https://youtu.be/xxx—which is valid according to the validator and is even covered by tests in CreateVideoCommandValidatorTests—will throw a BadRequest exception at the controller level, never even reaching the validator. I suggest moving this logic into a single shared method or service and using it in all three places to avoid maintaining three separate sources of truth.
- ValidationExceptionHandler can now silently “swallow” an error
Before the changes: if _problemDetailsService.TryWriteAsync returned false, the response was still written manually via WriteAsJsonAsync—in other words, there was a fallback.
After the changes: the code simply returns await _problemDetailsService.TryWriteAsync(...) without any fallback. If the service is unable to write the problem details for some reason, the client risks receiving a response with no body at all, and this will be difficult to debug. I suggest restoring the handling of this negative scenario or at least logging this case.
Translated with DeepL.com (free version)
|


dev
JIRA
Code reviewers
Second Level Review
Summary of issue
Admin is able to enter "Заголовок", limit is 50 symbols (uppercase and lowercase cyrillic and latin letters, numbers and special symbols).
Admin is able to enter "Основний текст". The limit is 25 000 symbols. The area for text is resizable.
Admin can apply basic formatting on text: bold and italic.
Admin is able to add a youtube.com link to "Відео", other links are not accepted.
Admin is able to request video preview via the "Попередній перегляд" button.
The "Відео" field is inactive until the Admin fills in the "Заголовок" field.
Admin is able to request a main text preview via the "Попередній перегляд тексту" button.
Admin is able to add text to the "Авторство" field. The text input field is prefilled with "Текст підготовлений спільно з". If this field remained unchanged - it will not be displayed for the user. Symbols limit is 200.
Summary of change
Implemented video/text functionality and unit tests for Streetcode.
PR Description
Video endpoints
The following production endpoints are intentionally included as part of this task:
POST /api/Video/Create — creates a video and validates that the URL belongs to YouTube.
GET /api/Video/GetPreview — provides video preview functionality for the admin interface.
These endpoints are part of the Video/Text functionality.
CHECK LIST