Skip to content

Commit

Permalink
fix test webhooks header authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
CamilleLegeron committed Jul 3, 2024
1 parent 7baa089 commit 67cb040
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/nbrowser/WebhookPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ describe('WebhookPage', function () {
await setField(1, 'Name', 'Test Webhook');
await setField(1, 'Memo', 'Test Memo');
await setField(1, 'Filter for changes in these columns (semicolon-separated ids)', 'A; B');
await setField(1, 'Header Authorization', 'Bearer 1234');
await gu.waitForServer();
await driver.navigate().refresh();
await waitForWebhookPage();
await gu.waitToPass(async () => {
assert.equal(await getField(1, 'Name'), 'Test Webhook');
assert.equal(await getField(1, 'Memo'), 'Test Memo');
assert.equal(await getField(1, 'Filter for changes in these columns (semicolon-separated ids)'), 'A;B');
assert.equal(await getField(1, 'Header Authorization'), 'Bearer 1234');
});
// Make sure the webhook is actually working.
await docApi.addRows('Table1', {A: ['zig'], B: ['zag']});
Expand All @@ -118,6 +116,27 @@ describe('WebhookPage', function () {
assert.lengthOf((await docApi.getRows('Table2')).A, 0);
});

it('can create webhook with persistant header authorization', async function () {
// The webhook won't work because the header auth doesn't match the api key of the current test user.
await openWebhookPage();
await setField(1, 'Event Types', 'add\nupdate\n');
await setField(1, 'URL', `http://${host}/api/docs/${doc.id}/tables/Table2/records?flat=1`);
await setField(1, 'Table', 'Table1');
await gu.waitForServer();
await driver.navigate().refresh();
await waitForWebhookPage();
await setField(1, 'Header Authorization', 'Bearer 1234');
await gu.waitForServer();
await driver.navigate().refresh();
await waitForWebhookPage();
await gu.waitToPass(async () => {
assert.equal(await getField(1, 'Header Authorization'), 'Bearer 1234');
});
await gu.getDetailCell({col:'Header Authorization', rowNum: 1}).click();
await gu.enterCell(Key.DELETE, Key.ENTER);
await gu.waitForServer();
});

it('can create two webhooks', async function () {
await openWebhookPage();
await setField(1, 'Event Types', 'add\nupdate\n');
Expand Down

0 comments on commit 67cb040

Please sign in to comment.