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

Fix quirks in URL field in view editor #21410

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/panels/lovelace/editor/view-editor/hui-view-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ export class HuiViewEditor extends LitElement {
if (
this.isNew &&
!this._suggestedPath &&
config.title &&
this._config.path === config.path &&
(!this._config.path ||
config.path === slugify(this._config.title || "", "-"))
) {
config.path = slugify(config.title, "-");
config.path = slugify(config.title || "", "-");
Comment on lines +149 to +153
Copy link
Contributor

Choose a reason for hiding this comment

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

Refinement of URL field logic in the view editor.

The change in the assignment of config.path to use slugify(config.title || "", "-") effectively addresses the issue described, ensuring the URL field behaves as expected when the title is deleted or empty.

However, it would be beneficial to add unit tests to verify that this new behavior works correctly across different scenarios, especially since the PR description mentions that tests have not been added.

  • No existing unit tests for config.path setting logic were found in the repository.

Would you like assistance in creating these tests, or should I open a GitHub issue to track this task?

Analysis chain

Refinement of URL field logic in the view editor.

The change in the assignment of config.path to use slugify(config.title || "", "-") effectively addresses the issue described, ensuring the URL field behaves as expected when the title is deleted or empty.

However, it would be beneficial to add unit tests to verify that this new behavior works correctly across different scenarios, especially since the PR description mentions that tests have not been added.

Would you like assistance in creating these tests, or should I open a GitHub issue to track this task?

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for unit tests related to `config.path` setting logic in the view editor.

# Test: Search for tests in the test directory that involve `config.path`. Expect: No matches indicating missing tests.
rg --type typescript -A 5 $'config.path' tests/

Length of output: 81


Script:

#!/bin/bash
# Description: Search for unit tests related to `config.path` setting logic in the view editor.

# Test: Search for tests in the test directory that involve `config.path`. Expect: No matches indicating missing tests.
rg 'config.path' tests/ --glob '*.ts' -A 5

Length of output: 89


Script:

#!/bin/bash
# Description: Search for unit tests related to `config.path` setting logic in the view editor.

# Test: Search for tests in the entire repository that involve `config.path`. Expect: No matches indicating missing tests.
rg 'config.path' --glob '*.ts' -A 5

Length of output: 881

}

fireEvent(this, "view-config-changed", { config });
Expand Down
Loading