2023-09-05 05:50:05 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "Theme qunit testing", type: :system do
|
2023-09-11 16:12:37 +08:00
|
|
|
let!(:theme_without_tests) { Fabricate(:theme, name: "no-tests-guy") }
|
2023-09-05 05:50:05 +08:00
|
|
|
let!(:theme_with_test) do
|
2023-09-11 16:12:37 +08:00
|
|
|
t = Fabricate(:theme, name: "Theme With Tests")
|
2023-09-05 05:50:05 +08:00
|
|
|
t.set_field(target: :tests_js, type: :js, name: "acceptance/some-test.js", value: <<~JS)
|
|
|
|
import { module, test } from "qunit";
|
|
|
|
|
|
|
|
module("theme test", function () {
|
|
|
|
test("it works", function (assert) {
|
|
|
|
assert.true(true)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
JS
|
2023-09-11 16:12:37 +08:00
|
|
|
t.build_remote_theme(remote_url: "https://example.com/mytheme")
|
2023-09-05 05:50:05 +08:00
|
|
|
t.save!
|
|
|
|
t
|
|
|
|
end
|
|
|
|
|
2023-09-11 16:12:37 +08:00
|
|
|
it "lists themes and can run tests by id, name and url" do
|
2023-09-05 05:50:05 +08:00
|
|
|
visit "/theme-qunit"
|
|
|
|
|
2023-09-11 16:12:37 +08:00
|
|
|
expect(page).to have_css("a[href^='/theme-qunit?id=']", count: 1)
|
|
|
|
|
2023-09-05 05:50:05 +08:00
|
|
|
find("a[href=\"/theme-qunit?id=#{theme_with_test.id}\"]").click
|
|
|
|
|
|
|
|
success_count = find("#qunit-testresult-display .passed").text
|
|
|
|
expect(success_count).to eq("1")
|
2023-09-11 16:12:37 +08:00
|
|
|
|
|
|
|
visit "/theme-qunit?name=#{theme_with_test.name}"
|
|
|
|
success_count = find("#qunit-testresult-display .passed").text
|
|
|
|
expect(success_count).to eq("1")
|
|
|
|
|
|
|
|
visit "/theme-qunit?url=#{theme_with_test.remote_theme.remote_url}"
|
|
|
|
success_count = find("#qunit-testresult-display .passed").text
|
|
|
|
expect(success_count).to eq("1")
|
2023-09-05 05:50:05 +08:00
|
|
|
end
|
|
|
|
end
|