Stirling-PDF icon indicating copy to clipboard operation
Stirling-PDF copied to clipboard

Add tests via TestDriverAI

Open chottuthejimmy opened this issue 1 year ago • 15 comments

Description

This PR contains the test cases to test the basic functionality of the stirling.io webpage. The tests are written using testdriverai a next gen automation AI agent for end-to-end testing of web and desktop application.

Overview

This PR adds TestDriver tests that I generated using the testdriverai npm package. Instead of using selectors, TestDriver uses prompts and AI vision to complete tasks. This means the tests will still work even when code and design changes.

Another huge benefit is we can test PDF input and output because tests operate at the OS level. You can see the schema of supported commands here.

Test Cases

  • Opens Google Chrome and interacts with various UI elements like buttons and icons.
  • Verifies opening and viewing of a PDF file.
  • Navigates back to the homepage after certain actions.
  • Changes the language from English to Spanish and back, verifying text translations.
  • Toggles the website theme using sun and moon icons.
  • Searches for specific terms and verifies correct navigation to related pages.
  • Hovers over buttons like "Merge" and checks for visual feedback (background changes).

Setup

In order to complete this PR you’ll need to add a API key as a GitHub action secret. Follow the directions here for more info. Once you sign up, let us know your email and we’ll enroll you in the open source program for free Pro account.

Here's how to add more tests :

  • Install the testdriverai package via npm and start by creating tests by just prompting the cli using natural language prompts ( you can check the prompts field in the test file for motivation )
  • Once you are done writing the tests, just push it to the repo, here's where the magic happens.
  • Whenever there's a new PR, the VMs (maintained by us) will clone the feature branch and performs the tests and returns the result along with the screen recordings and its logs (thanks to dashcam.io)
  • Also feel free to check out our docs on how to improve performance and techniques like parallel testing

What’s next

We can set this up to build feature branches using our prerun scripts.

Checklist

  • [x] I have read the Contribution Guidelines
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings
  • [ ] I have read the section Add New Translation Tags (for new translation tags only)

chottuthejimmy avatar Sep 24 '24 15:09 chottuthejimmy

@Frooodle We need your approval to run the workflow.

CleanShot 2024-09-24 at 12 28 52

ianjennings avatar Sep 24 '24 17:09 ianjennings

I believe I need the key: ${{secrets.TESTDRIVER_API_KEY}}

As well? Additionally we should set it up to run on PR code not on web instance :p

Frooodle avatar Sep 24 '24 17:09 Frooodle

Here is a preview of the test execution:

testdriverai/Stirling-PDF/refs/heads/main

Watch testdriverai/Stirling-PDF/refs/heads/main on Dashcam

ianjennings avatar Sep 24 '24 17:09 ianjennings

Hey @Frooodle could you have another look at this.

It's a go from our side!

Cheers!

chottuthejimmy avatar Sep 25 '24 16:09 chottuthejimmy

Sorry been very busy should be able to properly check it end of week

Frooodle avatar Sep 25 '24 16:09 Frooodle

Added key but job still failed, does account need upgraded?

Frooodle avatar Sep 28 '24 12:09 Frooodle

Added key but job still failed, does account need upgraded?

The API is reporting the key a null. Are you sure PRs have perms to access secrets? Or the variable name is correct?

ianjennings avatar Sep 30 '24 18:09 ianjennings

Hey @Frooodle could please make sure you have got the API set up properly. I would be happy to hop on a call and help you out, so let me know.

chottuthejimmy avatar Oct 01 '24 15:10 chottuthejimmy

Secret is there along side other secrets used within this repo, image

Frooodle avatar Oct 01 '24 21:10 Frooodle

Hey @Frooodle, so I tried to recreate the issue by forking and making a PR. I think its pretty much the API issue and nothing more. So could you try out a couple of things for us please.

Go to dashcam.io/team and click on the cycle button next to API Key, copy it and click on update. And replace the secret with this new key. image

Try to re-run the failed job over here

If that doesn't work, make sure the right permissions are set here for PRs to access the secrets, or you can just merge this PR if you do not wish to change the permission.

chottuthejimmy avatar Oct 02 '24 12:10 chottuthejimmy

All seems okay my side from what I can see, Can we add a - name: Debug - Print masked secret run: | echo "Secret is: ${{ secrets.TESTDRIVER_API_KEY }}"

to the job just to see if it can grab it or if its being lost in the call to the github action

Frooodle avatar Oct 03 '24 08:10 Frooodle

yes, lets try that. I made a commit, could try to run the workflow here

chottuthejimmy avatar Oct 03 '24 13:10 chottuthejimmy

Hmm printing nope I'll check more my side

Frooodle avatar Oct 03 '24 14:10 Frooodle

Hmm printing nope I'll check more my side

It printed yes for me when I tried on my fork

chottuthejimmy avatar Oct 03 '24 14:10 chottuthejimmy

Is it because of this code ??

chottuthejimmy avatar Oct 03 '24 14:10 chottuthejimmy

@Frooodle could you take a look at this sometime today please!

chottuthejimmy avatar Oct 07 '24 14:10 chottuthejimmy

Merging into repo branch to test it

Frooodle avatar Oct 09 '24 20:10 Frooodle

and that instantly worked.. looks like it had to be integrated first to have access to secret, it works fine now

Frooodle avatar Oct 09 '24 20:10 Frooodle

going to monitor PR and see ETA runtimes etc, will need to have it run a docker container and test the actual code not stirlingpdf.io deployment before merging into main also due to runtime might make more sense for this to be pre-release instead of precommit

Frooodle avatar Oct 09 '24 20:10 Frooodle

https://app.dashcam.io/replay/6706e85e67f936f4742aef4d?share=3NOziidOgB0CDw1kNjVaA

Did show some package.json error

Frooodle avatar Oct 09 '24 20:10 Frooodle

and that instantly worked.. looks like it had to be integrated first to have access to secret, it works fine now

Told you hear JK.

chottuthejimmy avatar Oct 10 '24 07:10 chottuthejimmy

Did show some package.json error

We are unable to access the recordings (as they belong to your org / acc) please accept my request access so that we can have a look into it

chottuthejimmy avatar Oct 10 '24 07:10 chottuthejimmy