Discourse 플러그인 개발 - 6부 - 승인 테스트 추가

LOAD_PLUGINS=1 QUNIT_SKIP_CORE=1 QUNIT_SINGLE_PLUGIN='discouse-humble-box' /home/ravenstorm/.rbenv/versions/2.5.3/bin/rake qunit:test
Chrome is not installed. Download from https://www.google.com/chrome/browser/desktop/index.html
rake aborted!
Command failed with status (1): [LOAD_PLUGINS=1 QUNIT_SKIP_CORE=1 QUNIT_SIN...]
/home/ravenstorm/discourse/lib/tasks/plugin.rake:117:in `block in <main>'
Tasks: TOP => plugin:qunit
1개의 좋아요

Install Chrome and then give it another try.

1개의 좋아요

Oh sorry i’ve pasted an old error code which i had stored in a pastebin :frowning_face:

navigate to http://localhost:60099/qunit?qunit_single_plugin=discouse-humble-box&qunit_skip_core=1&seed=187998423095278311109560784485973475676
Tests timed out
rake aborted!
Command failed with status (124): [node /home/ravenstorm/discourse/vendor/ass...]
/home/ravenstorm/discourse/lib/tasks/qunit.rake:89:in `block in <main>'
Tasks: TOP => qunit:test
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [LOAD_PLUGINS=1 QUNIT_SKIP_CORE=1 QUNIT_SIN...]
/home/ravenstorm/discourse/lib/tasks/plugin.rake:117:in `block in <main>'
Tasks: TOP => plugin:qunit

Try running the test in the browser as David suggested earlier. So, in your browser, when the server is running, go to your-local-site/qunit. Very often, for me, timeouts in the Terminal have errors in JS that I could see and fix after visiting /qunit on the browser.

Thats one of the problems :smiley:

I can’t find acceptance tests on my /qunit

Even after turning on all modules and filtering it with box and humble nothing is here :slightly_frowning_face:

Try renaming the folder to test/javascripts/acceptance - that extra s is quite important!

You might need to do rm -rf tmp, and then restart your development server for the changes to take effect.

1개의 좋아요

Do what David said above (rename the folder to javascripts), but ALSO, change the name of your plugin in plugin.rb to discourse-humble-box to match the folder name. I did these two changes, and I see tests locally:

4개의 좋아요

Yea i’ve seen those as well now, but these aren’t really eye-opening results tbh.

But gotta dig deeper and lookup why these errors are shown.

Thanks for the help guys.
For example the second test case.. if i am testing it myself by hand.. it works, but running it on qunit it fails :frowning:

Ok, got a brief idea whats bringing me the errors and it confuses me:
http://localhost:9292/ in my browser has the plugin installed and working
http://localhost:9292/qunit the test shows, that the plugin is not even installed

I thought these two are using the same enviroment ?
Could this be caused by my local dev-enviroment since it’s not using docker and I’m not able to install the plugin like Install plugins on a self-hosted site ? It’s just sitting in the plugins folder like the others.

Any idea how this is possible ?

이 가이드를 따르려고 하고 있지만, 바로 시작점에서 막혀 있습니다: /qunit에 전혀 접근할 수 없습니다. (이 문제는 Install Discourse on Ubuntu or Debian for Development 와도 관련이 있어 보입니다. 이 링크는 개발을 학습하기 위해 로컬 머신에 Discourse를 배포하는 데 제가 기본적으로 사용하고 있는 접근 방식과 거의 동일합니다. 하지만 이 가이드가 제 장애물의 직접적인 원인이었기 때문에 여기에 질문을 남기게 되었습니다.) 해당 경로를 접근하려고 하면 "해당 페이지가 존재하지 않거나 비공개입니다"라는 응답이 반환됩니다.

/qunit 라우트의 컨트롤러(discourse/app/controllers/qunit_controller.rb at 166fe3bb34f99bd0baa613726486ce0f13c7a992 · discourse/discourse · GitHub)에는 # only used in non-ember-cli test / dev라는 주석이 붙어 있습니다(해당 메서드 앞의 주석). 따라서 RAILS_ENV=test bundle exec rails server로 인스턴스를 실행해 보았지만, EmberCli.enabled?는 여전히 true입니다.

/qunit에 실제로 접근할 수 있도록(아마도 EmberCLI를 비활성화해야 할 것 같습니다) 로컬 개발 서버를 실행하는 데 여러분은 어떤 접근 방식을 사용하고 계신가요? (물론 제가 명백한 것을 놓치고 있을 수도 있습니다.)

2개의 좋아요

새 경로는 /tests입니다. 원문을 업데이트하겠습니다. 감사합니다!

4개의 좋아요

좋아요, 감사합니다! 다음 장애물로 넘어가겠습니다:

이 특정 인수 테스트(acceptance test)로 가는 직접 링크는 오류(백트레이스 포함)를 반환합니다:

Error: No tests matched the module "Acceptance: Purple Tentacle".

실제로 “Module:” 선택 목록을 검색해 보았지만 “purple” 또는 "Purple"과 일치하는 항목을 찾을 수 없습니다. 플러그인이나 해당 플러그인의 테스트를 등록하는 시스템의 새로운 구성 요소가 여기에 누락되었을 수 있나요?

“Filter:” 텍스트 상자를 사용하여 "purple"을 검색하면 다음 URL로 이동합니다: http://localhost:4200/tests?filter=purple. 이 경우 다른 오류가 발생합니다:

Error: Could not find module `helpers/qunit-helpers` imported from `discourse/plugins//acceptance/purple-tentacle-test`
    at missingModule (http://localhost:4200/assets/vendor.js:259:11)

여기서 무엇이 잘못된 것인지에 대한 아이디어가 있으신가요?

부연 설명으로, /tests URL은 catch-all 라우트인 get "*url", to: 'permalinks#show'를 사용하여 실제로 Permalink.find_by_url을 통해 해결되나요? 그렇다면 Discourse 초기화 과정에서 /tests URL 매핑이 데이터베이스에 로드되는 시점은 언제인가요?

1개의 좋아요

@jlc, 가이드를 사용해 보시고 최신 정보를 공유해 주셔서 정말 감사합니다. :meow_heart:

수용성 테스트(acceptance test)에 사용하는 새로운 변경 사항을 반영하기 위해 OP의 예시 수용성 테스트에 몇 가지 수정을 가했습니다. 기본적으로 변경된 두 가지 사항은 다음과 같습니다.

  • import 문, 그리고
  • acceptance 내부의 needs 상수 사용

이로써 언급하신 대부분의 문제가 해결될 것입니다. 또한 여기의 needs 옵션 중 일부도 활용할 수 있습니다:

qunit-helpers 파일 전체를 살펴보는 것도 매우 유용할 것입니다!

2개의 좋아요