Skip to content

Test/video text - #74

Open
Mult1pers wants to merge 8 commits into
devfrom
test/video-text
Open

Test/video text#74
Mult1pers wants to merge 8 commits into
devfrom
test/video-text

Conversation

@Mult1pers

@Mult1pers Mult1pers commented Aug 18, 2026

Copy link
Copy Markdown

dev

JIRA

Code reviewers

Second Level Review

  • @github_username

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

  • СI passed
  • Сode coverage >=95%
  • PR is reviewed manually again (to make sure you have 100% ready code)
  • All reviewers agreed to merge the PR
  • I've checked new feature as logged in and logged out user if needed
  • PR meets all conventions

@emil720a1 emil720a1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Mult1pers
Mult1pers requested a review from emil720a1 August 21, 2026 16:25

@DrFaust555 DrFaust555 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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.

  2. 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.

  3. 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.

  4. Delete the six empty files: StreetcodeCreateDTO.cs, StreetcodeUpdateDTO.cs,
    CreateStreetcodeCommand.cs, CreateStreetcodeHandler.cs,
    UpdateStreetcodeCommand.cs, UpdateStreetcodeHandler.cs.

  5. 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.

  6. 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.

  7. 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.

  8. GetVideoAdminPreviewHandler returns the input string unchanged. Either
    return something useful (embed URL, video id) or drop the endpoint.

  9. 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..

  10. VideoControllerTests.cs has no test for a valid YouTube URL. Add one that
    passes a mocked IMediator and asserts the command is sent.

  11. 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 #".

  12. Fix the three SA1009 Sonar issues in CreateTextCommand.cs,
    CreateVideoCommand.cs and GetVideoForAdminPreviewCommand.cs.

@Mult1pers
Mult1pers requested a review from DrFaust555 August 23, 2026 12:07

@Loki22978964 Loki22978964 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran a review and found a few issues that need to be fixed before the merge:

  1. 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.

  1. 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.

  1. 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)

@Mult1pers
Mult1pers requested a review from Loki22978964 August 28, 2026 19:09
@Mult1pers Mult1pers closed this Aug 30, 2026
@Mult1pers Mult1pers reopened this Aug 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants