Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions e2e/harness.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ class Context {
async count(query) {
return Number(this.sql(query));
}
/** Clicks the server stored for a link, split by its bot classification. */
async humanClicks(link) {
return this.count(`SELECT count(*) FROM click_events WHERE link_id = ${this.q(link.id)} AND NOT is_bot`);
}
async botClicks(link) {
return this.count(`SELECT count(*) FROM click_events WHERE link_id = ${this.q(link.id)} AND is_bot`);
}

async installsSinceStart() {
return this.count(`SELECT count(*) FROM install_events WHERE created_at BETWEEN ${this.q(this.startedAt)}::timestamp AND now() AT TIME ZONE 'utc' AND sdk_name = ${this.q(this.device.sdkName)}`);
}
Expand Down
8 changes: 8 additions & 0 deletions e2e/scenarios.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const scenarios = [
await t.click(link);
await t.dbCheck('the browser click is recorded', async () =>
(await t.count(`SELECT count(*) FROM click_events WHERE link_id = ${t.q(link.id)}`)) >= 1);
await t.dbCheck('the browser click counts as human', async () => (await t.botClicks(link)) === 0,
async () => `${await t.botClicks(link)} stored as bot`);

const first = await t.launch();
const init = first.one('initResult');
Expand Down Expand Up @@ -100,6 +102,9 @@ export const scenarios = [
t.check('stored parameters arrive', data?.customParameters?.productId === '9');
t.check('parameters on the tapped URL arrive', data?.customParameters?.campaign === 'spring');
t.check('the callback runs on the main thread', opened[0]?.thread === 'main', opened[0]?.thread);
await t.dbCheck('the open is stored as one human click', async () => (await t.humanClicks(link)) === 1
&& (await t.botClicks(link)) === 0,
async () => `${await t.humanClicks(link)} human, ${await t.botClicks(link)} bot`);
},
},

Expand All @@ -113,6 +118,9 @@ export const scenarios = [
const opened = entries.all('deepLink');
t.check('onDeepLink fires once', opened.length === 1, `fired ${opened.length} times`);
t.check('with the link', opened[0]?.deepLinkData?.shortCode === link.shortCode);
await t.dbCheck('the open is stored as one human click', async () => (await t.humanClicks(link)) === 1
&& (await t.botClicks(link)) === 0,
async () => `${await t.humanClicks(link)} human, ${await t.botClicks(link)} bot`);
},
},

Expand Down
Loading