Comments (7)
This has been released as part of CLI 10.0.1
.
from zapier-platform.
Yeah, great question! once the fix is deployed (which, pre-warning, can take some time) and you've got the update, then your tests with cursors will use the actual cursor endpoints and perform just like production code will. The apptester generates (short-lived) cursors for each call to appTester(...
(so each test gets its own cursor)
If you (understandably) want to fix your tests right now you can edit this function in your local node_modules
to be return true
:
zapier-platform/packages/core/src/tools/create-app-tester.js
Lines 13 to 18 in 658171f
that's in node_modules/zapier-platform-core/src/tools/create-app-tester.js
That'll mean that all your tests will be able to use triggers (even when they shouldn't), but that's the easiest guaranteed fix. That'll keep working until you re-install node_modules
, but it'll at least unblock you.
from zapier-platform.
Wanted to check in on the status of this. Is this in fact a bug?
We're having the same issue. Our application is moving from offset-based pagination to cursor-based pagination. Our resources are set to canPaginate: true
. It was easy to implement perform
to get and set the cursor as needed.
However, when using createAppTester
, we are now getting
Invalid cursor operation. `z.cursor` can only be used in `perform` methods of polling triggers and when `canPaginate` is `true`.
It seems like this is supported by the app tester is incorrectly raising an issue here. Is that the case? Is there anything we can do to work around this in the meantime?
from zapier-platform.
I think it's just an issue with createAppTester
and resources w/ paginating triggers.
If you don't mind, could you post your appTester(...
line for the trigger that doesn't work? That'll help me narrow this down.
from zapier-platform.
Thanks @xavdid !
The test itself is basically:
const bundle = {
...fake bundle stuff
};
...
bundle.meta.page = 2;
const results = await appTester(App.resources.column.list.operation.perform, bundle);
And the definition of the resource in question is:
async function performListColumns(z: ZObject, bundle: Bundle): Promise<any[]> {
const {documentId, tableId} = bundle.inputData;
const response = await listColumns({
z,
bundle,
documentId,
tableId,
pageToken: bundle.meta.page ? await z.cursor.get() : undefined,
});
if (response.nextPageToken) {
await z.cursor.set(response.nextPageToken);
}
return response.items;
}
export const ColumnResource = {
key: 'column' as 'column',
noun: 'Column',
list: {
display: {
label: 'New Column',
description: 'Triggers when a new column is added to the selected table.',
hidden: true,
},
operation: {
canPaginate: true,
inputFields: [
{
key: 'documentId',
required: true,
label: 'Document',
dynamic: 'documentList.id.name',
altersDynamicFields: true,
},
{
key: 'tableId',
required: true,
label: 'Table',
dynamic: 'tableList.id.name',
altersDynamicFields: true,
helpText: 'Changes to your document may take a little time to show up here.',
},
],
perform: performListColumns,
sample: {
items: [
{
id: 'c-abc123',
name: 'Column A',
href: 'https://coda.io/apis/v1/docs/12345/tables/grid-abc123/columns/c-abc123',
},
{
id: 'c-def456',
name: 'Column B',
href: 'https://coda.io/apis/v1/docs/12345/tables/grid-abc123/columns/c-def456',
},
],
},
},
},
sample: {
id: 'c-102sdfn28',
name: 'Column A',
href: 'https://coda.io/apis/v1/docs/12345/tables/grid-abc123/columns/c-102sdfn28',
},
outputFields: [
{key: 'id', label: 'ID'},
{key: 'name', label: 'Name'},
{key: 'href', label: 'Link'},
{key: 'calculated', label: 'Calculated'},
{key: 'display', label: 'Display'},
],
};
from zapier-platform.
nice! the appTester(App.resources.column.list.operation.perform, bundle);
is the key here - that's the correct test code, but it's running afoul of the lines caleb linked in the OP. I'll get this fixed!
from zapier-platform.
Very much appreciate the quick response time here, thanks!
Relatedly, once fixed, is there a way to mock/hack setting z.cursor
in the test? It's obviously easy to pass in an arbitrary bundle, but to meaningfully test cursor-based pagination one would need to set the cursor to something non-empty. But that seems like it's all within the bowels of the app tester.
from zapier-platform.
Related Issues (20)
- Error: "https://zapier.com/api/platform/cli/check" returned "400" saying "App must validate against schema before running app checks" HOT 5
- Node 14 LTS reaches the EOL at 2023-04-30 HOT 2
- `Zipping projects and dependencies` does not like certain tokens/features of more recent Node versions HOT 5
- [Bug]: Testing out the new bug report form!
- [Feature Request]: Add support to RequestSchema to createAppTester HOT 1
- [Feature Request]: Upgrade "node-fetch" library HOT 3
- [Bug]: ResizeObserver - loop limit exceeded HOT 1
- [Bug]: zapier push fails with npm workspaces HOT 5
- [Bug]: throwing `new z.errors.RefreshAuthError()` doesn't retry `performUnsubscribe`
- [Bug]: BaseHttpResponse.headers incorrectly typed HOT 1
- [Feature Request]: Dropdown with multi-select options
- [Bug]: `issueFeatureUpdates` is not iterable HOT 1
- [Bug]: `zapier build` follows invalid symlinks when copying HOT 3
- [Bug]: Cannot use z.cursor inside triggers code
- [Bug]: z.request when raw is true does not include buffer method on response object HOT 3
- [Bug]: createAppTester's typescript types do not account for http request objects
- [Feature Request]: Add support for `update` key in `resources` definition HOT 1
- [Bug]: Build fails for ESM modules HOT 1
- [Bug]: CLI zapier push results in EBUSY HOT 4
- [Bug]: zappier push throws "spawn EINVAL" error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zapier-platform.