positron icon indicating copy to clipboard operation
positron copied to clipboard

Register top action bar Save and Save All button commands

Open sharon-wang opened this issue 1 year ago • 2 comments

Description

  • Addresses https://github.com/posit-dev/positron/issues/2276

Changes

  • registers the Save and Save All commands to the CommandCenter so that they are available in the top action bar
  • add smoke test for the Save/Save All top action bar buttons and some scaffolding for future top action bar smoke tests
  • adds isDisabled() and isEnabled() to PositronBaseElement

Demo

https://github.com/posit-dev/positron/assets/25834218/6b6fb56c-5829-4700-8fda-8739cb678d8c

QA Notes

Please add new TestRail items for these new tests.

sharon-wang avatar Jul 05 '24 11:07 sharon-wang

Thanks for working on this! I noticed that even in VS Code, a Save menu option is always enabled even if there are no dirty state files. The Save All menu option is disabled until at least one file in a dirty state. Positron's icons now match that behavior, though the underlying logic feels a little inconsistent. We don't need to reconcile that in this PR, however.

petetronic avatar Jul 05 '24 16:07 petetronic

Running tests on windows, I get:

      Save Actions
spec.js:54
        √ Save and Save All both disabled when no unsaved editors are open
spec.js:76
        1) Save enabled and Save All disabled when a single unsaved file is open
spec.js:88
        √ Save and Save All both enabled when multiple unsaved files are open
spec.js:76
        2) Save and Save All both enabled when an unsaved new file is open
spec.js:88
  2 passing (19s)
base.js:379
  2 failing

I think the 1st one "Save enabled and Save All disabled when a single unsaved file is open" is a timing issue for me. It seems to pass sometimes, especially when I run it by itself. If I add await app.code.wait(1000) before checking if buttons are enabled/disabled, it passes without issue.

The 2nd one (also what Chris mentioned) .. for me at least is that when you click save, it opens a System dialog, and since we can't automate that, the save doesn't actually happen.

jonvanausdeln avatar Jul 05 '24 18:07 jonvanausdeln

@jonvanausdeln

I think the 1st one "Save enabled and Save All disabled when a single unsaved file is open" is a timing issue for me. It seems to pass sometimes, especially when I run it by itself. If I add await app.code.wait(1000) before checking if buttons are enabled/disabled, it passes without issue.

I ended up wrapping the checks in expect().toPass(). Hopefully, the built-in retry logic helps us avoid some flakiness here!

The 2nd one (also what Chris mentioned) .. for me at least is that when you click save, it opens a System dialog, and since we can't automate that, the save doesn't actually happen.

Right 👍 I have removed clicking on Save and the rest of that test. So in the new untitled file case, the automation just covers that before clicking Save/Save All, they are enabled.


Tests passed in CI after making the last few changes ✅

sharon-wang avatar Jul 08 '24 09:07 sharon-wang

As a side note, please feel free to to merge this on my behalf if I'm out when this PR gets approved!

sharon-wang avatar Jul 08 '24 09:07 sharon-wang