Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
const { randomUUID } = require('node:crypto');
|
|
|
|
async function pickOne(ctx, { label, sql, params }) {
|
|
const rows = await ctx.db.query(sql, params);
|
|
if (!rows.length) throw new Error(`Fixture requires ${label} in DB (tenant=${ctx.config.tenantId}).`);
|
|
return rows[0];
|
|
}
|
|
|
|
module.exports = async function run(ctx) {
|
|
const tenantId = ctx.config.tenantId;
|
|
const marker = '[fixture email-provider-connected-notify]';
|
|
|
|
const user = await pickOne(ctx, {
|
|
label: 'a user',
|
|
sql: `select user_id from users where tenant = $1 order by created_at asc limit 1`,
|
|
params: [tenantId]
|
|
});
|
|
|
|
const providerId = `fixture-provider-${randomUUID()}`;
|
|
await ctx.http.request('/api/workflow/events', {
|
|
method: 'POST',
|
|
json: {
|
|
eventName: 'EMAIL_PROVIDER_CONNECTED',
|
|
correlationKey: providerId,
|
|
payloadSchemaRef: 'payload.EmailProviderConnected.v1',
|
|
payload: {
|
|
providerId,
|
|
providerType: 'google',
|
|
providerName: 'Fixture Provider',
|
|
mailbox: 'fixture-mailbox@example.com',
|
|
connectedAt: new Date().toISOString(),
|
|
fixtureNotifyUserId: user.user_id
|
|
}
|
|
}
|
|
});
|
|
|
|
const runRow = await ctx.waitForRun({ startedAfter: ctx.triggerStartedAt });
|
|
if (runRow.status !== 'SUCCEEDED') {
|
|
const steps = await ctx.getRunSteps(runRow.run_id);
|
|
throw new Error(`Expected run SUCCEEDED, got ${runRow.status}. Steps: ${JSON.stringify(ctx.summarizeSteps(steps))}`);
|
|
}
|
|
|
|
const notifications = await ctx.db.query(
|
|
`
|
|
select internal_notification_id, title, message
|
|
from internal_notifications
|
|
where tenant = $1 and user_id = $2
|
|
order by created_at desc
|
|
limit 25
|
|
`,
|
|
[tenantId, user.user_id]
|
|
);
|
|
|
|
const found = notifications.find(
|
|
(n) => typeof n.title === 'string' && n.title.includes(marker) && typeof n.message === 'string' && n.message.includes(providerId)
|
|
);
|
|
if (!found) {
|
|
throw new Error(`Expected an internal notification containing "${marker}" and providerId for user ${user.user_id}. Found ${notifications.length} notification(s).`);
|
|
}
|
|
};
|
|
|