Skip to content

Commit

Permalink
Add failing test for multiple applications
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Jun 3, 2024
1 parent 3a93236 commit 7a659b4
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application

export { application }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName

import { application } from "./application"

import HelloController from "../hello_controller"

application.register("hello", HelloController)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application

export { application }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName

import { application } from "./application"

import HelloController from "../hello_controller"

application.register("hello", HelloController)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {

}
}
8 changes: 8 additions & 0 deletions test/fixtures/multiple-applications/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "multiple-applications",
"private": true,
"dependencies": {
"@hotwired/stimulus": "^3.2.2",
"esbuild": "^0.20.0"
}
}
152 changes: 152 additions & 0 deletions test/fixtures/multiple-applications/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@esbuild/aix-ppc64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.20.0.tgz#509621cca4e67caf0d18561a0c56f8b70237472f"
integrity sha512-fGFDEctNh0CcSwsiRPxiaqX0P5rq+AqE0SRhYGZ4PX46Lg1FNR6oCxJghf8YgY0WQEgQuh3lErUFE4KxLeRmmw==

"@esbuild/android-arm64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.20.0.tgz#109a6fdc4a2783fc26193d2687827045d8fef5ab"
integrity sha512-aVpnM4lURNkp0D3qPoAzSG92VXStYmoVPOgXveAUoQBWRSuQzt51yvSju29J6AHPmwY1BjH49uR29oyfH1ra8Q==

"@esbuild/android-arm@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.20.0.tgz#1397a2c54c476c4799f9b9073550ede496c94ba5"
integrity sha512-3bMAfInvByLHfJwYPJRlpTeaQA75n8C/QKpEaiS4HrFWFiJlNI0vzq/zCjBrhAYcPyVPG7Eo9dMrcQXuqmNk5g==

"@esbuild/android-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.20.0.tgz#2b615abefb50dc0a70ac313971102f4ce2fdb3ca"
integrity sha512-uK7wAnlRvjkCPzh8jJ+QejFyrP8ObKuR5cBIsQZ+qbMunwR8sbd8krmMbxTLSrDhiPZaJYKQAU5Y3iMDcZPhyQ==

"@esbuild/darwin-arm64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.20.0.tgz#5c122ed799eb0c35b9d571097f77254964c276a2"
integrity sha512-AjEcivGAlPs3UAcJedMa9qYg9eSfU6FnGHJjT8s346HSKkrcWlYezGE8VaO2xKfvvlZkgAhyvl06OJOxiMgOYQ==

"@esbuild/darwin-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.20.0.tgz#9561d277002ba8caf1524f209de2b22e93d170c1"
integrity sha512-bsgTPoyYDnPv8ER0HqnJggXK6RyFy4PH4rtsId0V7Efa90u2+EifxytE9pZnsDgExgkARy24WUQGv9irVbTvIw==

"@esbuild/freebsd-arm64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.0.tgz#84178986a3138e8500d17cc380044868176dd821"
integrity sha512-kQ7jYdlKS335mpGbMW5tEe3IrQFIok9r84EM3PXB8qBFJPSc6dpWfrtsC/y1pyrz82xfUIn5ZrnSHQQsd6jebQ==

"@esbuild/freebsd-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.20.0.tgz#3f9ce53344af2f08d178551cd475629147324a83"
integrity sha512-uG8B0WSepMRsBNVXAQcHf9+Ko/Tr+XqmK7Ptel9HVmnykupXdS4J7ovSQUIi0tQGIndhbqWLaIL/qO/cWhXKyQ==

"@esbuild/linux-arm64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.20.0.tgz#24efa685515689df4ecbc13031fa0a9dda910a11"
integrity sha512-uTtyYAP5veqi2z9b6Gr0NUoNv9F/rOzI8tOD5jKcCvRUn7T60Bb+42NDBCWNhMjkQzI0qqwXkQGo1SY41G52nw==

"@esbuild/linux-arm@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.20.0.tgz#6b586a488e02e9b073a75a957f2952b3b6e87b4c"
integrity sha512-2ezuhdiZw8vuHf1HKSf4TIk80naTbP9At7sOqZmdVwvvMyuoDiZB49YZKLsLOfKIr77+I40dWpHVeY5JHpIEIg==

"@esbuild/linux-ia32@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.20.0.tgz#84ce7864f762708dcebc1b123898a397dea13624"
integrity sha512-c88wwtfs8tTffPaoJ+SQn3y+lKtgTzyjkD8NgsyCtCmtoIC8RDL7PrJU05an/e9VuAke6eJqGkoMhJK1RY6z4w==

"@esbuild/linux-loong64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.20.0.tgz#1922f571f4cae1958e3ad29439c563f7d4fd9037"
integrity sha512-lR2rr/128/6svngnVta6JN4gxSXle/yZEZL3o4XZ6esOqhyR4wsKyfu6qXAL04S4S5CgGfG+GYZnjFd4YiG3Aw==

"@esbuild/linux-mips64el@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.20.0.tgz#7ca1bd9df3f874d18dbf46af009aebdb881188fe"
integrity sha512-9Sycc+1uUsDnJCelDf6ZNqgZQoK1mJvFtqf2MUz4ujTxGhvCWw+4chYfDLPepMEvVL9PDwn6HrXad5yOrNzIsQ==

"@esbuild/linux-ppc64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.20.0.tgz#8f95baf05f9486343bceeb683703875d698708a4"
integrity sha512-CoWSaaAXOZd+CjbUTdXIJE/t7Oz+4g90A3VBCHLbfuc5yUQU/nFDLOzQsN0cdxgXd97lYW/psIIBdjzQIwTBGw==

"@esbuild/linux-riscv64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.20.0.tgz#ca63b921d5fe315e28610deb0c195e79b1a262ca"
integrity sha512-mlb1hg/eYRJUpv8h/x+4ShgoNLL8wgZ64SUr26KwglTYnwAWjkhR2GpoKftDbPOCnodA9t4Y/b68H4J9XmmPzA==

"@esbuild/linux-s390x@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.20.0.tgz#cb3d069f47dc202f785c997175f2307531371ef8"
integrity sha512-fgf9ubb53xSnOBqyvWEY6ukBNRl1mVX1srPNu06B6mNsNK20JfH6xV6jECzrQ69/VMiTLvHMicQR/PgTOgqJUQ==

"@esbuild/linux-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.20.0.tgz#ac617e0dc14e9758d3d7efd70288c14122557dc7"
integrity sha512-H9Eu6MGse++204XZcYsse1yFHmRXEWgadk2N58O/xd50P9EvFMLJTQLg+lB4E1cF2xhLZU5luSWtGTb0l9UeSg==

"@esbuild/netbsd-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.20.0.tgz#6cc778567f1513da6e08060e0aeb41f82eb0f53c"
integrity sha512-lCT675rTN1v8Fo+RGrE5KjSnfY0x9Og4RN7t7lVrN3vMSjy34/+3na0q7RIfWDAj0e0rCh0OL+P88lu3Rt21MQ==

"@esbuild/openbsd-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.20.0.tgz#76848bcf76b4372574fb4d06cd0ed1fb29ec0fbe"
integrity sha512-HKoUGXz/TOVXKQ+67NhxyHv+aDSZf44QpWLa3I1lLvAwGq8x1k0T+e2HHSRvxWhfJrFxaaqre1+YyzQ99KixoA==

"@esbuild/sunos-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.20.0.tgz#ea4cd0639bf294ad51bc08ffbb2dac297e9b4706"
integrity sha512-GDwAqgHQm1mVoPppGsoq4WJwT3vhnz/2N62CzhvApFD1eJyTroob30FPpOZabN+FgCjhG+AgcZyOPIkR8dfD7g==

"@esbuild/win32-arm64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.20.0.tgz#a5c171e4a7f7e4e8be0e9947a65812c1535a7cf0"
integrity sha512-0vYsP8aC4TvMlOQYozoksiaxjlvUcQrac+muDqj1Fxy6jh9l9CZJzj7zmh8JGfiV49cYLTorFLxg7593pGldwQ==

"@esbuild/win32-ia32@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.20.0.tgz#f8ac5650c412d33ea62d7551e0caf82da52b7f85"
integrity sha512-p98u4rIgfh4gdpV00IqknBD5pC84LCub+4a3MO+zjqvU5MVXOc3hqR2UgT2jI2nh3h8s9EQxmOsVI3tyzv1iFg==

"@esbuild/win32-x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.20.0.tgz#2efddf82828aac85e64cef62482af61c29561bee"
integrity sha512-NgJnesu1RtWihtTtXGFMU5YSE6JyyHPMxCwBZK7a6/8d31GuSo9l0Ss7w1Jw5QnKUawG6UEehs883kcXf5fYwg==

"@hotwired/stimulus@^3.2.2":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608"
integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==

esbuild@^0.20.0:
version "0.20.0"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.20.0.tgz#a7170b63447286cd2ff1f01579f09970e6965da4"
integrity sha512-6iwE3Y2RVYCME1jLpBqq7LQWK3MW6vjV2bZy6gt/WrqkY+WE74Spyc0ThAOYpMtITvnjX09CrC6ym7A/m9mebA==
optionalDependencies:
"@esbuild/aix-ppc64" "0.20.0"
"@esbuild/android-arm" "0.20.0"
"@esbuild/android-arm64" "0.20.0"
"@esbuild/android-x64" "0.20.0"
"@esbuild/darwin-arm64" "0.20.0"
"@esbuild/darwin-x64" "0.20.0"
"@esbuild/freebsd-arm64" "0.20.0"
"@esbuild/freebsd-x64" "0.20.0"
"@esbuild/linux-arm" "0.20.0"
"@esbuild/linux-arm64" "0.20.0"
"@esbuild/linux-ia32" "0.20.0"
"@esbuild/linux-loong64" "0.20.0"
"@esbuild/linux-mips64el" "0.20.0"
"@esbuild/linux-ppc64" "0.20.0"
"@esbuild/linux-riscv64" "0.20.0"
"@esbuild/linux-s390x" "0.20.0"
"@esbuild/linux-x64" "0.20.0"
"@esbuild/netbsd-x64" "0.20.0"
"@esbuild/openbsd-x64" "0.20.0"
"@esbuild/sunos-x64" "0.20.0"
"@esbuild/win32-arm64" "0.20.0"
"@esbuild/win32-ia32" "0.20.0"
"@esbuild/win32-x64" "0.20.0"
35 changes: 35 additions & 0 deletions test/system/multiple-applications.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { describe, test, expect } from "vitest"
import { setupProject } from "../helpers/setup"

const project = setupProject("multiple-applications")

describe("System", () => {
test("multiple-applications", async () => {
expect(project.controllersFiles.length).toEqual(0)
expect(project.applicationFile).toBeUndefined()
expect(project.registeredControllers.length).toEqual(0)

await project.initialize()

expect(project.applicationFile).toBeDefined()
expect(project.applicationFile.localApplicationConstant).toEqual("application")
expect(project.applicationFile.exportedApplicationConstant).toEqual("application")
expect(project.relativePath(project.applicationFile.path)).toEqual("app/javascript/controllers/backend/application.js")

expect(project.controllersFiles.length).toEqual(1)
expect(project.controllersFiles[0].applicationImport).toBeDefined()
expect(project.controllersFiles[0].localApplicationConstant).toEqual("application")
expect(project.relativePath(project.controllersFiles[0].path)).toEqual("app/javascript/controllers/backend/index.js")

expect(project.controllerRoots.length).toEqual(2)

Check failure on line 24 in test/system/multiple-applications.test.ts

View workflow job for this annotation

GitHub Actions / JavaScript Test Action (18)

test/system/multiple-applications.test.ts > System > multiple-applications

AssertionError: expected 1 to deeply equal 2 - Expected + Received - 2 + 1 ❯ test/system/multiple-applications.test.ts:24:44

Check failure on line 24 in test/system/multiple-applications.test.ts

View workflow job for this annotation

GitHub Actions / JavaScript Test Action (20)

test/system/multiple-applications.test.ts > System > multiple-applications

AssertionError: expected 1 to deeply equal 2 - Expected + Received - 2 + 1 ❯ test/system/multiple-applications.test.ts:24:44

Check failure on line 24 in test/system/multiple-applications.test.ts

View workflow job for this annotation

GitHub Actions / JavaScript Test Action (21)

test/system/multiple-applications.test.ts > System > multiple-applications

AssertionError: expected 1 to deeply equal 2 - Expected + Received - 2 + 1 ❯ test/system/multiple-applications.test.ts:24:44

Check failure on line 24 in test/system/multiple-applications.test.ts

View workflow job for this annotation

GitHub Actions / JavaScript Test Action (18)

test/system/multiple-applications.test.ts > System > multiple-applications

AssertionError: expected 1 to deeply equal 2 - Expected + Received - 2 + 1 ❯ test/system/multiple-applications.test.ts:24:44

Check failure on line 24 in test/system/multiple-applications.test.ts

View workflow job for this annotation

GitHub Actions / JavaScript Test Action (20)

test/system/multiple-applications.test.ts > System > multiple-applications

AssertionError: expected 1 to deeply equal 2 - Expected + Received - 2 + 1 ❯ test/system/multiple-applications.test.ts:24:44

Check failure on line 24 in test/system/multiple-applications.test.ts

View workflow job for this annotation

GitHub Actions / JavaScript Test Action (21)

test/system/multiple-applications.test.ts > System > multiple-applications

AssertionError: expected 1 to deeply equal 2 - Expected + Received - 2 + 1 ❯ test/system/multiple-applications.test.ts:24:44
expect(project.controllerRoots[0]).toEqual("app/javascript/controllers/application")
expect(project.controllerRoots[1]).toEqual("app/javascript/controllers/backend")

expect(project.registeredControllers.length).toEqual(1)
expect(project.registeredControllers.map(controller => [controller.identifier, controller.loadMode])).toEqual([["hello", "register"]])
expect(Array.from(project.controllerRoots).sort()).toEqual([
"app/javascript/controllers/application",
"app/javascript/controllers/backend"
])
})
})

0 comments on commit 7a659b4

Please sign in to comment.