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

test(dev): fix router test #376

Merged
merged 2 commits into from
Sep 28, 2024
Merged

test(dev): fix router test #376

merged 2 commits into from
Sep 28, 2024

Conversation

nobkd
Copy link
Collaborator

@nobkd nobkd commented Sep 27, 2024

This fixes the router test (mentioned in #375)

Note

Problem now is, that you can't identify what a component was, when it is rendered, from the DOM alone.
What do you think about maybe adding custom="<name>" instead of only custom?


PS: (to #375 (comment))
these tests are only slow when they time out.
I agree, that they're maybe complex and error-prone, but that's also, because the API changes.
I hope, that I will take some time to refactor them soon, so they get less complex and error-prone. (Maybe even adding more tests to ensure DOM gets changed as expected.)

@nobkd nobkd changed the title test: fix router test test(dev): fix router test Sep 27, 2024
@nobkd
Copy link
Collaborator Author

nobkd commented Sep 27, 2024

OK, changed the code, so the component keeps the name. I know, that the name is duplicated now, but I at least still know what the component was, once rendered.

Just undo the last commit, if you don't agree with this change.

@tipiirai tipiirai merged commit 9355e03 into nuejs:dev Sep 28, 2024
4 checks passed
@tipiirai
Copy link
Contributor

Thanks.

Is there a specific reason for keeping the name value? Does it help with testing? (You can get the name via element.tagName too)

@nobkd nobkd deleted the test/router branch September 28, 2024 14:21
@nobkd
Copy link
Collaborator Author

nobkd commented Sep 28, 2024

@tipiirai

Of course, this isn't always needed.
But see the following, when running source linked (bun link in packages/nuekit) nue from packages/nuekit/test/page-router-test before my change (adding the name to custom):

Before nue renders components (rendered index.html):

<main>
  <article>
    <h1>Home</h1>
    <app custom></app>
  </article>
</main>

After nue rendered components (opening page in browser):

<main>
  <article>
    <h1>Home</h1>
    <section custom>
      <h2>App mounted</h2>
    </section>
  </article>
</main>

So... how would you now know what this component ever was, when you don't have access to nue's in memory component structure?
element.tagName gives section, if you just select the [custom] elements.
You might never need this from external, but at least testing DOM gets much easier when adding the name to the element somehow! (especially when there are multiple components in the page)

@nobkd nobkd mentioned this pull request Sep 28, 2024
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.

2 participants