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: adding tests (playwright) #48

Merged
merged 15 commits into from
Aug 23, 2022
Merged

Conversation

vvidday
Copy link
Contributor

@vvidday vvidday commented Aug 13, 2022

Setup + basic tests using playwright

Currently implements the following (E2E) tests:

Use Case / Feature Expected Behaviour
Basic typing / editing Text should update as user types
Text should be formatted appropriately when user inputs bold/italics
Converting between types Blocks should be converted appropriately when user selects a type from the menu
Blocks should be converted appropriately when user initiates conversion by searching/typing
Caret position should be maintained after conversion if initiated from search
Creating new lines / Breaking lines Pressing 'Enter' at the end of a block should create a new line
Pressing 'Enter' in the middle of a block should create a new line containing the text after the caret position
Merging two lines Pressing 'Backspace' at the beginning of a text block should merge the current block's content with the previous block
Pressing 'Backspace' at the beginning of a non-text block should convert the current block to a text block

I also included an example using playwright's component testing (c9a30f1 and 89329ed), which will be very useful since it allows us to mount components with custom props. (eg if we want to test custom inputs like bold/italic bold/headings etc we can mount the component with these inputs instead of having to create them in an end to end test)

One 'downside' of playwright compared to cypress is that we can't (to my knowledge) access instance methods (for example directly calling Lotion.vue::getCaretPos()), but we can still test the correctness of the methods outcome e.g. by initiating a change in block type via the menu.

Also, I'm not sure regarding CI (I'm not familiar with AWS), currently npx playwright test is configured to start the local server with npm run dev and test on that url - might need some changes for CI.

@greentfrapp
Copy link
Contributor

Hey @vvidday sorry about the long delay!

Thanks again for helping to look into Playwright!

Quick overview:

  • We're planning to use vitest for unit and component testing because it's pretty fast and has watch mode built-in already
  • Then using Playwright for E2E primarily for browser coverage across Chrome, FF and Safari

Added some comments in the PR review.

I've also set up some very basic tests (unit/component/e2e) in main for reference, see tests folder. Take a look and let me know what you think?

package.json Outdated Show resolved Hide resolved
playwright/index.html Outdated Show resolved Hide resolved
src/components/BlockMenu.vue Outdated Show resolved Hide resolved
tests/utils/testTypes.ts Show resolved Hide resolved
src/components/tests/Lotion.test.ts Outdated Show resolved Hide resolved
@vvidday
Copy link
Contributor Author

vvidday commented Aug 22, 2022

Skipped the 2 failing tests (on chromium) for now, will address in future PR - see #54 for details

@vvidday vvidday marked this pull request as ready for review August 22, 2022 14:26
@greentfrapp greentfrapp merged commit 65b8550 into Dashibase:main Aug 23, 2022
@greentfrapp greentfrapp mentioned this pull request Aug 23, 2022
@vvidday vvidday deleted the test/playwright branch August 23, 2022 10:34
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