[PR #2240] [CLOSED] add cypress tests #3677

Closed
opened 2026-04-25 00:16:37 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/2240
Author: @MxMarx
Created: 10/23/2023
Status: Closed

Base: masterHead: cypress-tests


📝 Commits (1)

📊 Changes

34 files changed (+15420 additions, -1979 deletions)

View changed files

📝 .devcontainer/Dockerfile (+7 -2)
📝 .devcontainer/devcontainer.json (+7 -1)
📝 .gitignore (+4 -0)
📝 client/components/app/BookShelfCategorized.vue (+1 -1)
📝 client/components/modals/AccountModal.vue (+4 -4)
📝 client/components/modals/libraries/EditLibrary.vue (+3 -3)
📝 client/components/modals/libraries/EditModal.vue (+1 -1)
📝 client/components/player/PlayerPlaybackControls.vue (+1 -1)
📝 client/components/player/PlayerUi.vue (+2 -2)
📝 client/components/tables/UsersTable.vue (+1 -1)
📝 client/components/tables/library/LibrariesTable.vue (+1 -1)
📝 client/nuxt.config.js (+4 -1)
📝 client/package-lock.json (+176 -1)
📝 client/package.json (+2 -1)
📝 client/pages/item/_id/index.vue (+1 -1)
📝 client/pages/login.vue (+5 -5)
cypress.config.js (+31 -0)
cypress/e2e/00-initializeDatabase.cy.js (+121 -0)
cypress/e2e/00-initializeDatabaseWithGui.cy.js (+113 -0)
cypress/e2e/api/scanner.cy.js (+73 -0)

...and 14 more files

📄 Description

I got bored enough to try learning how to write tests. I don't know how useful this is but I did it anyway!

npm run test will start the server with a fresh database, create some synthetic audiobooks to test with, and run the tests with coverage. There are currently five main tests:

  • Use either the UI or API to initialize the server, add a library, and start a scan
  • Log in with the UI
  • Create and delete a user with the UI
  • Check that the scanner added the test books and that their metadata is correct with the API
  • Navigate to an audiobook, press play, and verify that audio is playing

To seed an audiobook library for testing, I made a script that takes json files from a few known library items, and uses ffmpeg and tone to create some small audiobook files with silent audio but real metadata and chapters.

Cypress seems to need a desktop to run, but adding ghcr.io/devcontainers/features/desktop-lite:1 to devcontainers seems to work.

It could probably still use some cleaning, but I guess I'd like to know if this approach is worth continuing first (for audiobookshelf in addition to personal growth) before I get too far into it.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/2240 **Author:** [@MxMarx](https://github.com/MxMarx) **Created:** 10/23/2023 **Status:** ❌ Closed **Base:** `master` ← **Head:** `cypress-tests` --- ### 📝 Commits (1) - [`e8432d9`](https://github.com/advplyr/audiobookshelf/commit/e8432d9a0dc4a180a1e2b50fa9935e6509d4908b) add cypress tests ### 📊 Changes **34 files changed** (+15420 additions, -1979 deletions) <details> <summary>View changed files</summary> 📝 `.devcontainer/Dockerfile` (+7 -2) 📝 `.devcontainer/devcontainer.json` (+7 -1) 📝 `.gitignore` (+4 -0) 📝 `client/components/app/BookShelfCategorized.vue` (+1 -1) 📝 `client/components/modals/AccountModal.vue` (+4 -4) 📝 `client/components/modals/libraries/EditLibrary.vue` (+3 -3) 📝 `client/components/modals/libraries/EditModal.vue` (+1 -1) 📝 `client/components/player/PlayerPlaybackControls.vue` (+1 -1) 📝 `client/components/player/PlayerUi.vue` (+2 -2) 📝 `client/components/tables/UsersTable.vue` (+1 -1) 📝 `client/components/tables/library/LibrariesTable.vue` (+1 -1) 📝 `client/nuxt.config.js` (+4 -1) 📝 `client/package-lock.json` (+176 -1) 📝 `client/package.json` (+2 -1) 📝 `client/pages/item/_id/index.vue` (+1 -1) 📝 `client/pages/login.vue` (+5 -5) ➕ `cypress.config.js` (+31 -0) ➕ `cypress/e2e/00-initializeDatabase.cy.js` (+121 -0) ➕ `cypress/e2e/00-initializeDatabaseWithGui.cy.js` (+113 -0) ➕ `cypress/e2e/api/scanner.cy.js` (+73 -0) _...and 14 more files_ </details> ### 📄 Description I got bored enough to try learning how to write tests. I don't know how useful this is but I did it anyway! `npm run test` will start the server with a fresh database, create some synthetic audiobooks to test with, and run the tests with coverage. There are currently five main tests: - Use either the UI or API to initialize the server, add a library, and start a scan - Log in with the UI - Create and delete a user with the UI - Check that the scanner added the test books and that their metadata is correct with the API - Navigate to an audiobook, press play, and verify that audio is playing To seed an audiobook library for testing, I made a script that takes json files from a few known library items, and uses ffmpeg and tone to create some small audiobook files with silent audio but real metadata and chapters. Cypress seems to need a desktop to run, but adding ghcr.io/devcontainers/features/desktop-lite:1 to devcontainers seems to work. It could probably still use some cleaning, but I guess I'd like to know if this approach is worth continuing first (for audiobookshelf in addition to personal growth) before I get too far into it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:16:37 +02:00
adam closed this issue 2026-04-25 00:16:37 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3677