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

(ASIM-4306) network widgets custom fonts #108

Merged
merged 8 commits into from
Dec 2, 2021

Conversation

dettmerramon
Copy link
Contributor

No description provided.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Can we have a test for this functionality? We need at least some test to use this, to ensure future code changes don't break it unexpectedly.

Copy link

@haensch-mauricio haensch-mauricio left a comment

Choose a reason for hiding this comment

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

Will wait for a test too.

@dettmerramon
Copy link
Contributor Author

How would I go about writing a test for it? Any examples?
I wrote one in the alfasim_gui rep but seems it isn't enough, although I do agree that it could benefit from one

@nicoddemus
Copy link
Member

nicoddemus commented Oct 13, 2021

I wrote one in the alfasim_gui rep but seems it isn't enough, although I do agree that it could benefit from one

The point is that changes in a library should be accompanied by a test, so if we break the functionality a test in the library will point the breakage.

@prusse-martin any suggestions?

@prusse-martin
Copy link
Member

I wrote one in the alfasim_gui rep but seems it isn't enough, although I do agree that it could benefit from one

The point is that changes in a library should be accompanied by a test, so if we break the functionality a test in the library will point the breakage.

An image test (comparing the screen shot).
This will probably be SO dependent. Today we only run the ci tests on linux, but I really like to be able to run them on my local machine (windows).

Another variation of the image test is using a canvas (set font and fill text then extract the pixel data from the canvas). But I will like to keep it simple. If mxgraph is shows to be "flaky" on node/label positioning we can use the canvas approach.

@nicoddemus
Copy link
Member

Hmm I think we should move away from anything take needs the UI to work.

Can't we just check that things are set on the JS side, after GraphOptions.custom_fonts has been changed?

@prusse-martin
Copy link
Member

Yes we can check that...
But if the font is not properly configured a system default will be used without errors (just the rendering will be wrong).
That is how it is tested in alfasim, checking that "we properly instructed qmx to setup things", I think we should check here that qmx setup is actually working.

I am ready to stand down if you think we should not take this approach in this case.

@nicoddemus
Copy link
Member

But if the font is not properly configured a system default will be used without errors (just the rendering will be wrong).

That's fine, I want more of a smoke test to ensure some refactoring just doesn't forward custom_fonts to JS anymore, and no test here breaks because of that.

That is how it is tested in alfasim, checking that "we properly instructed qmx to setup things", I think we should check here that qmx setup is actually working.

Agreed.

I am ready to stand down if you think we should not take this approach in this case.

What? I thought we are in agreement?

@prusse-martin
Copy link
Member

That is how it is tested in alfasim, checking that "we properly instructed qmx to setup things", I think we should check here that qmx setup is actually working.

Agreed.

I am ready to stand down if you think we should not take this approach in this case.

What? I thought we are in agreement?

Sorry if was I was not able to convey my idea.
By "that qmx setup is actually working" I intended to express "that qmx setup is actually resulting in the expected effect".

If a test "that qmx setup is happening" was in place (how it was in alfasim) during the qt port that test will happily pass.
If a test "that qmx setup is actually resulting in the expected effect" it will fail.

@nicoddemus
Copy link
Member

If a test "that qmx setup is happening" was in place (how it was in alfasim) during the qt port that test will happily pass.

I disagree, we would have catch this error because we would have seen the setup failing in JS (I'm advocating to check things on the JS side, not only on the Python side).

I don't want to introduce screenshot tests or anything like that because we know how flaky/hard to maintain those are, so I think at least we can meet halfway and have a test which checks the integration is happening.

Do you agree, or you strongly believe we should go for a image/screenshot approach?

@prusse-martin
Copy link
Member

prusse-martin commented Oct 15, 2021

I disagree, we would have catch this error because we would have seen the setup failing in JS (I'm advocating to check things on the JS side, not only on the Python side).

Test this on JS side would be doing the "canvas" hack, due to security concerns it is not possible to check the actual font used to render in html.
But we could check that in some convoluted (read "canvas hack") ways like suggested here: https://stackoverflow.com/a/38910481/783219
We use as base line an invalid font then check if using a valid font the canvas rendered text changed.

Do you agree, or you strongly believe we should go for a image/screenshot approach?

I believe we should. But I will repeat.
I am ready to stand down if you think we should not take this approach in this case.

@nicoddemus
Copy link
Member

nicoddemus commented Oct 15, 2021

OK, let's go with the more complete test then.

Could you tackle that in a separate PR @prusse-martin? I think this is out of @dettmerramon's expertise.

Pushing the test here also works too if you prefer. 👍

@prusse-martin
Copy link
Member

prusse-martin commented Oct 15, 2021

I will work on this test later.

@haensch-mauricio
Copy link

I will work on this test later.

By later you mean in another PR or in this one?

By the way, tests are failing in this one.

Copy link

@haensch-mauricio haensch-mauricio left a comment

Choose a reason for hiding this comment

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

Need to check why tests are failing.

@prusse-martin
Copy link
Member

I will work on this test later.

By later you mean in another PR or in this one?

Yes. I created a follow up issue for this.

src/qmxgraph/page/graphs.js Outdated Show resolved Hide resolved
@dettmerramon dettmerramon changed the title Fb asim 4306 network widgets custom fonts (ASIM-4306) network widgets custom fonts Nov 29, 2021
@dettmerramon dettmerramon force-pushed the fb-ASIM-4306-network-widgets-custom-fonts branch from 1eaecf4 to bf7016d Compare November 29, 2021 12:43
@coveralls
Copy link

coveralls commented Nov 29, 2021

Coverage Status

Coverage increased (+0.01%) to 89.483% when pulling 3d4be6a on fb-ASIM-4306-network-widgets-custom-fonts into 9cbee62 on master.

ramon added 3 commits December 1, 2021 08:13
Implemented the ability to load different fonts to
be used in the NetworkWidget through Qmxgraph

Solves ASIM-4306
@dettmerramon dettmerramon force-pushed the fb-ASIM-4306-network-widgets-custom-fonts branch from d9c4c54 to 3d4be6a Compare December 1, 2021 14:24
@dettmerramon dettmerramon merged commit 0e06962 into master Dec 2, 2021
@dettmerramon dettmerramon deleted the fb-ASIM-4306-network-widgets-custom-fonts branch December 2, 2021 16:15
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.

None yet

5 participants