import { click, visit } from "@ember/test-helpers"; import { cloneJSON } from "discourse-common/lib/object"; import topicFixtures from "discourse/tests/fixtures/topic"; import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { test } from "qunit"; acceptance("Lightbox", function (needs) { needs.user(); needs.pretender((server, helper) => { const topicResponse = cloneJSON(topicFixtures["/t/280/1.json"]); topicResponse.post_stream.posts[0].cooked += ``; server.get("/t/280.json", () => helper.response(topicResponse)); server.get("/t/280/:post_number.json", () => helper.response(topicResponse) ); }); test("Shows download and direct URL", async function (assert) { await visit("/t/internationalization-localization/280"); await click(".lightbox"); assert.equal( query(".mfp-title").textContent, "image · 1500×842 234 KB · download · original image" ); assert.equal( query(".image-source-link:nth-child(1)").href, "http://discourse.local/uploads/default/ad768537789cdf4679a18161ac0b0b6f0f4ccf9e" ); assert.equal( query(".image-source-link:nth-child(2)").href, `${document.location.origin}/images/d-logo-sketch.png` ); await click(".mfp-close"); }); });