SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.74k stars 740 forks source link

PR for #1673 issue: Trying display test code in a text area #1675

Closed mKabouri closed 11 months ago

mKabouri commented 1 year ago

This is a PR for #1673 issue. Thank you @toddtarsi.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

toddtarsi commented 1 year ago

@mKabouri - I promise I haven't forgotten about this. This weekend I'll take a look. Btw, v42 or latest is a lot more stable to develop on, so if you come up, you'll have a less bad time now

toddtarsi commented 1 year ago

Might have to still build, I still need to figure out where electron-chromedriver and pnpm are putting things in binary

toddtarsi commented 12 months ago

@mKabouri - Am I correct that you're trying to improve tooling for format authors?

toddtarsi commented 12 months ago

I love the intent behind this. However, this is what you'll need to do to get what you want:

  1. In OutputFormatsController, make a new async method, something like getTestCodeFromIDAndFormat. Just gut the bits you need for this. If you want to be super clean, you can make the old function use it, but no pressure. This will be what does the work in the backend to get the info and return it.
  2. Repeat this same function signature in side-api. It would be in a file like packages/side-api/commands/outputFormats/getTestCodeFromIDAndFormat.ts. Add this to side-api so that you can call await window.sideAPI.outputFormats.getTestCodeFromIDAndFormat(test.id, format.name) or whatever. Follow a file pattern like commands/projects/getActive.ts, and also make sure that you make index.ts files in side-api to hoist everything here similarly.
  3. Get your code the easy way using window.sideAPI in the component layers as needed. At this point, intellisense should be your friend.
toddtarsi commented 12 months ago

@mKabouri - I should explain, the side-api package is a weird and kinda ugly abstraction, but I wanted a utility package for plugin authors so they would have the entire shape of the api without having to install electron as a dev package.

mKabouri commented 12 months ago

@toddtarsi I tried this but the Project editor just turning. Is there another alternative, for example using ipcRenderer and ipcMain ?

toddtarsi commented 12 months ago

@mKabouri - Doing it this way is worth it. Commit what you have and I'll help.

toddtarsi commented 12 months ago

@mKabouri - I'll take a look in about 6 hours and commit or PR some of the work to your branch, depending on the access I have.

toddtarsi commented 12 months ago

@mKabouri - I'm sorry, I'm a bit too tired tonight. I'm going to try to look at this tomorrow. You're on the right track with the side-api additions!

toddtarsi commented 11 months ago

@mKabouri - I think you need to supply some state for export format as well. You might be better off coming at this from a menu / hotkey angle so that format iteration and selection is solved (example here: https://github.com/SeleniumHQ/selenium-ide/blob/acf86928d1c9950b9c60d320cf0c1bcbb996a736/packages/selenium-ide/src/main/session/controllers/Menu/menus/suiteManager.ts).

This might sound shady, but I'm starting to work on a paid plugin that will basically "supercharge" (buzzword I'm sorry) export format development and playback as well, so while I'm supportive of any effort to democratize and add good code-export features and tooling, I'm planning to solve some of these DX problems to a pretty extreme degree via a cheap plugin.

toddtarsi commented 11 months ago

Oh, I tried it out last night! But yeah, it seems a little too incomplete right now.

mKabouri commented 11 months ago

I console.log test.id in the browser side it always prints '-1' in the console, and test is imported from side-api. I don't know if this is the problem because when I create a new test it has also an id of '-1'.

toddtarsi commented 11 months ago

@mKabouri - Can I see a reference to a line of code for what you're experiencing?

toddtarsi commented 11 months ago

@mKabouri - Said differently, can you show me how you're always getting -1?

mKabouri commented 11 months ago

In the line before window.sideAPI.get....("language", test.id). I just console log console.log("Debug: ", test.id);. I got 'Debug: -1'