diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index f7113f2..746d997 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -25,7 +25,7 @@ jobs: - name: Install Ruby and gems for dummy app uses: ruby/setup-ruby@v1 with: - ruby-version: '3.3.5' + ruby-version: '3.3.6' bundler-cache: true - name: Setup dummy app diff --git a/package.json b/package.json index 9d56a58..2c554bc 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,9 @@ { "name": "@rolemodel/turbo-confirm", "type": "module", - "version": "2.1.0", + "version": "2.1.1", "description": "Drop-in upgrade for Rails' data-turbo-confirm feature to support custom HTML dialogs.", "main": "src/index.js", - "peerDependencies": { - "@hotwired/turbo": ">= 8.0.6" - }, "directories": { "lib": "src/lib" }, @@ -36,7 +33,7 @@ }, "homepage": "https://github.com/RoleModel/turbo-confirm#readme", "devDependencies": { - "@playwright/test": "^1.47", + "@playwright/test": "^1.49.1", "@types/node": "^20.11.30" } } diff --git a/src/index.js b/src/index.js index 359fb67..e208c45 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,7 @@ const start = (options) => { if (!window.Turbo) throw TurboConfirmError.noTurbo() const tc = new TurboConfirm(options) - window.Turbo.config.forms.confirm = async (message, formElement, submitter) => { + const confirmationHandler = async (message, formElement, submitter) => { const response = await tc.confirm(message, formElement, submitter) if (response) { @@ -16,6 +16,12 @@ const start = (options) => { return response } + + if (window.Turbo.config) { + window.Turbo.config.forms.confirm = confirmationHandler + } else { + window.Turbo.setConfirmMethod(confirmationHandler) + } } export default { start } diff --git a/test/dummy/.ruby-version b/test/dummy/.ruby-version index fa7adc7..9c25013 100644 --- a/test/dummy/.ruby-version +++ b/test/dummy/.ruby-version @@ -1 +1 @@ -3.3.5 +3.3.6 diff --git a/test/dummy/Gemfile.lock b/test/dummy/Gemfile.lock index 1319d7d..feff8d8 100644 --- a/test/dummy/Gemfile.lock +++ b/test/dummy/Gemfile.lock @@ -268,7 +268,7 @@ DEPENDENCIES web-console RUBY VERSION - ruby 3.3.5p100 + ruby 3.3.6p108 BUNDLED WITH 2.5.7 diff --git a/test/dummy/yarn.lock b/test/dummy/yarn.lock index e02fb77..0feb62a 100644 --- a/test/dummy/yarn.lock +++ b/test/dummy/yarn.lock @@ -501,17 +501,17 @@ integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A== "@hotwired/turbo-rails@^8.0.4": - version "8.0.10" - resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.10.tgz#28b0c1243868d9efc4a71f4a2ff7d97ee9cefbfa" - integrity sha512-BkERfjTbNwMb9/YQi0RL9+f9zkD+dZH2klEONtGwXrIE3O9BE1937Nn9++koZpDryD4XN3zE5U5ibyWoYJAWBg== + version "8.0.12" + resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.12.tgz#6f1a2661122c0a2bf717f3bc68b5106638798c89" + integrity sha512-ZXwu9ez+Gd4RQNeHIitqOQgi/LyqY8J4JqsUN0nnYiZDBRq7IreeFdMbz29VdJpIsmYqwooE4cFzPU7QvJkQkA== dependencies: - "@hotwired/turbo" "^8.0.6" + "@hotwired/turbo" "^8.0.12" "@rails/actioncable" "^7.0" -"@hotwired/turbo@^8.0.6": - version "8.0.10" - resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.10.tgz#d95569d259f0daad6e824ee1ada877ff94beb72b" - integrity sha512-xen1YhNQirAHlA8vr/444XsTNITC1Il2l/Vx4w8hAWPpI5nQO78mVHNsmFuayETodzPwh25ob2TgfCEV/Loiog== +"@hotwired/turbo@^8.0.12": + version "8.0.12" + resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.12.tgz#50aa8345d7f62402680c6d2d9814660761837001" + integrity sha512-l3BiQRkD7qrnQv6ms6sqPLczvwbQpXt5iAVwjDvX0iumrz6yEonQkNAzNjeDX25/OJMFDTxpHjkJZHGpM9ikWw== "@jest/schemas@^29.6.3": version "29.6.3" @@ -585,7 +585,7 @@ modern-css-reset "^1.4.0" "@rolemodel/turbo-confirm@link:../..": - version "2.1.0" + version "2.1.1" "@sinclair/typebox@^0.27.8": version "0.27.8" diff --git a/test/system/turbo.spec.js b/test/system/turbo.spec.js index b81c323..8a500bb 100644 --- a/test/system/turbo.spec.js +++ b/test/system/turbo.spec.js @@ -7,6 +7,11 @@ test.beforeAll(async ({ request }) => { const response = await request.post('/todos/setup') expect(response.ok()).toBeTruthy() todos = await response.json() + + expect(todos.length).toBe(3) + todos.forEach(todo => { + expect(Object.keys(todo)).toEqual(expect.arrayContaining(['id', 'title', 'body'])) + }) }) test.afterAll(async ({ request }) => { diff --git a/yarn.lock b/yarn.lock index abb1bf6..796a9f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,12 +2,12 @@ # yarn lockfile v1 -"@playwright/test@^1.47": - version "1.47.2" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.47.2.tgz#dbe7051336bfc5cc599954214f9111181dbc7475" - integrity sha512-jTXRsoSPONAs8Za9QEQdyjFn+0ZQFjCiIztAIF6bi1HqhBzG9Ma7g1WotyiGqFSBRZjIEqMdT8RUlbk1QVhzCQ== +"@playwright/test@^1.49.1": + version "1.49.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.1.tgz#55fa360658b3187bfb6371e2f8a64f50ef80c827" + integrity sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g== dependencies: - playwright "1.47.2" + playwright "1.49.1" "@types/node@^20.11.30": version "20.11.30" @@ -21,17 +21,17 @@ fsevents@2.3.2: resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -playwright-core@1.47.2: - version "1.47.2" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.47.2.tgz#7858da9377fa32a08be46ba47d7523dbd9460a4e" - integrity sha512-3JvMfF+9LJfe16l7AbSmU555PaTl2tPyQsVInqm3id16pdDfvZ8TTZ/pyzmkbDrZTQefyzU7AIHlZqQnxpqHVQ== +playwright-core@1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015" + integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg== -playwright@1.47.2: - version "1.47.2" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.47.2.tgz#155688aa06491ee21fb3e7555b748b525f86eb20" - integrity sha512-nx1cLMmQWqmA3UsnjaaokyoUpdVaaDhJhMoxX2qj3McpjnsqFHs516QAKYhqHAgOP+oCFTEOCOAaD1RgD/RQfA== +playwright@1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c" + integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA== dependencies: - playwright-core "1.47.2" + playwright-core "1.49.1" optionalDependencies: fsevents "2.3.2"