Developing Discourse Plugins - Part 6 - Add acceptance tests

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!

https://github.com/discourse/discourse/blob/cd0403174dd88b0d1619ee7a53b42bc600bd69d1/lib/plugin/instance.rb#L463

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 in Discourse ? It’s just sitting in the plugins folder like the others.

Any idea how this is possible ?

ガイドに従おうとしているのですが、最初につまずいてしまいました。/qunit にまったくアクセスできません。(これは、開発について学ぶためにローカルマシンにDiscourseをデプロイするアプローチと基本的に同じである Install Discourse on Ubuntu or Debian for Development にも関連しているようです。しかし、このガイドが私の障害を引き起こしたプロンプトなので、ここに記載しようと思いました。) アクセスを試みると、「そのページは存在しないか、プライベートです」という応答があります。

/qunit ルートのコントローラー (discourse/app/controllers/qunit_controller.rb at 166fe3bb34f99bd0baa613726486ce0f13c7a992 · discourse/discourse · GitHub) には、それが「# 非Ember CLIテスト/開発でのみ使用」であると記載されています(そのメソッドの前のコメント)。そのため、RAILS_ENV=test bundle exec rails server でインスタンスを実行しようとしましたが、EmberCli.enabled? は依然として true です。

/qunit に実際にアクセスできるように、ローカル開発サーバーを実行するために皆さんが使用しているアプローチは何ですか?(おそらく EmberCLI を無効にすることが含まれるでしょう。)(私は明らかに何か明白なことを見落としているかもしれません。)

「いいね!」 2

新しいパスは/testsです。OPを更新します。ありがとうございます!

「いいね!」 4

素晴らしい、ありがとうございます!次の障害に進みます。

この特定の受け入れテストへの直接リンクは、エラー(バックトレース付き)を返します。

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はキャッチオール get \"*url\", to: 'permalinks#show' ルートを使用しており、それゆえ Permalink.find_by_url で実際に解決されますか?もしそうなら、Discourseの初期化のどの時点で /tests URLマッピングがデータベースにロードされますか?

@jlc、私たちのガイドをお試しいただき、最新情報をお知らせいただきありがとうございます。:meow_heart:

OPの例の受け入れテストを、受け入れテストに使用しているいくつかの新しい変更を反映するようにいくつか変更しました。基本的に、2つの変更点は次のとおりです。

  • インポート、および
  • acceptance内でのneeds定数の使用

これにより、言及されている問題のほとんどが解決されるはずです。また、needsオプションのいくつかをここで使用することもできます。

qunit-helpersファイル全体を確認することも非常に役立ちます!

「いいね!」 1