32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
// A non-system org can arm a schedule trigger: the schedule source's built-in
|
|
// mapping is readable there, so a binding on it is accepted. The editor's own
|
|
// schedule list is instance-only, so the binding is written over the API.
|
|
const assert = require('node:assert/strict');
|
|
const { ORG, ABSENT, selectOrg } = require('./helpers/org-helpers.cjs');
|
|
|
|
module.exports = async ({ page, go, shot, tolerate }) => {
|
|
tolerate(ABSENT);
|
|
await go('/');
|
|
assert.equal((await selectOrg(page, ORG.beta)).status(), 204);
|
|
await go('/workflows/feasibility');
|
|
const origin = new URL(page.url()).origin;
|
|
const headers = { 'X-Archie-CSRF': '1', Origin: origin };
|
|
const created = await page.request.post(`${origin}/api/bindings`, {
|
|
headers,
|
|
data: {
|
|
name: 'e2e schedule trigger', matcher: { source: 'schedule' }, mapping_id: 'schedule-fired',
|
|
filter: 'schedule_id == "issue-discovery"', workflow: 'feasibility', repo_param: '', owner: '', repo: '', inputs: {},
|
|
},
|
|
});
|
|
try {
|
|
assert.equal(created.status(), 201, `binding on the built-in schedule mapping refused: ${await created.text()}`);
|
|
const binding = await created.json();
|
|
assert.equal(binding.org_id, ORG.beta);
|
|
await go('/workflows/feasibility');
|
|
await page.getByText('Starts when').first().waitFor();
|
|
await shot('beta-trigger');
|
|
} finally {
|
|
if (created.ok()) await page.request.delete(`${origin}/api/bindings/${(await created.json()).id}`, { headers });
|
|
}
|
|
};
|