DEV: Fix failing click-track tests.

This commit is contained in:
Bianca Nenciu 2019-05-07 13:53:45 +03:00
parent 4bbb34f7cb
commit 71fb8a4195
6 changed files with 35 additions and 45 deletions

View File

@ -93,7 +93,7 @@ export default {
let trackPromise = Ember.RSVP.resolve();
if (tracking) {
if (navigator.sendBeacon) {
if (!Ember.testing && navigator.sendBeacon) {
const data = new FormData();
data.append("url", href);
data.append("post_id", postId);

View File

@ -4,7 +4,7 @@ acceptance("Click Track", {});
QUnit.test("Do not track mentions", async assert => {
/* global server */
server.get("/clicks/track", () => assert.ok(false));
server.post("/clicks/track", () => assert.ok(false));
await visit("/t/internationalization-localization/280");
assert.ok(invisible("#user-card"), "card should not appear");

View File

@ -138,7 +138,7 @@ export default function() {
return response({ topic_list: { topics: [] } });
});
this.get("/clicks/track", success);
this.post("/clicks/track", success);
this.get("/search", request => {
if (request.queryParams.q === "posts") {

View File

@ -62,11 +62,10 @@ QUnit.test("tracks internal URLs", async assert => {
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
assert.ok(
request.url.indexOf(
server.post("/clicks/track", request => {
assert.equal(
request.requestBody,
"url=http%3A%2F%2Fdiscuss.domain.com&post_id=42&topic_id=1337"
) !== -1
);
done();
});
@ -79,11 +78,10 @@ QUnit.test("tracks external URLs", async assert => {
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
assert.ok(
request.url.indexOf(
server.post("/clicks/track", request => {
assert.equal(
request.requestBody,
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
) !== -1
);
done();
});
@ -99,11 +97,10 @@ QUnit.test(
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
assert.ok(
request.url.indexOf(
server.post("/clicks/track", request => {
assert.equal(
request.requestBody,
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
) !== -1
);
done();
});

View File

@ -56,10 +56,8 @@ QUnit.test("tracks internal URLs", async assert => {
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
assert.ok(
request.url.indexOf("url=http%3A%2F%2Fdiscuss.domain.com") !== -1
);
server.post("/clicks/track", request => {
assert.equal(request.requestBody, "url=http%3A%2F%2Fdiscuss.domain.com");
done();
});
@ -71,11 +69,10 @@ QUnit.test("tracks external URLs", async assert => {
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
assert.ok(
request.url.indexOf(
server.post("/clicks/track", request => {
assert.equal(
request.requestBody,
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
) !== -1
);
done();
});
@ -88,11 +85,10 @@ QUnit.test("tracks external URLs in other posts", async assert => {
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
assert.ok(
request.url.indexOf(
server.post("/clicks/track", request => {
assert.equal(
request.requestBody,
"url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331"
) !== -1
);
done();
});

View File

@ -54,11 +54,10 @@ QUnit.test("tracks internal URLs", async assert => {
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
server.post("/clicks/track", request => {
assert.ok(
request.url.indexOf(
request.requestBody,
"url=http%3A%2F%2Fdiscuss.domain.com&post_id=42&topic_id=1337"
) !== -1
);
done();
});
@ -75,7 +74,7 @@ QUnit.test("does not track attachments", async assert => {
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
/* global server */
server.get("/clicks/track", () => assert.ok(false));
server.post("/clicks/track", () => assert.ok(false));
assert.ok(track(generateClickEventOn(".attachment")));
});
@ -85,11 +84,10 @@ QUnit.test("tracks external URLs", async assert => {
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
server.post("/clicks/track", request => {
assert.ok(
request.url.indexOf(
request.requestBody,
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
) !== -1
);
done();
});
@ -105,11 +103,10 @@ QUnit.test(
const done = assert.async();
/* global server */
server.get("/clicks/track", request => {
server.post("/clicks/track", request => {
assert.ok(
request.url.indexOf(
request.requestBody,
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
) !== -1
);
done();
});