Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix test for pagination cursor #1138

Merged
merged 10 commits into from
Sep 4, 2024
Merged

test: fix test for pagination cursor #1138

merged 10 commits into from
Sep 4, 2024

Conversation

VebjornG
Copy link
Contributor

In the previous test of the pagination cursor in alert-api, 1001 alerts was created. This created 504s, so we reduced that number to 50.
Ticket.

@VebjornG VebjornG requested a review from a team as a code owner August 26, 2024 10:58
@VebjornG VebjornG changed the title fix: Fix test for pagination cursor fix: fix test for pagination cursor Aug 26, 2024

expect((await alerts).length).toBeGreaterThan(1000);
expect((await alerts).length).toBe(50);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this tests pagination. Aren't we just fetching 50 alerts without pagination here?
Also autoPagingToArray({ limit: 50 }); will not provide a limit query param to the API as this is logic for the SDK. If you want to send a limit query param to the API, then it should be here:

const alerts = client.alerts.list({..., limit: 25})`

Copy link
Contributor

@BugGambit BugGambit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is not a fix as specified in the PR title and commit.
From the end-users point of view, this PR doesn't fix any bugs.

The proper prefix is test

See the contribution docs: https://github.com/cognitedata/cognite-sdk-js/blob/master/CONTRIBUTING.md#making-changes

@VebjornG VebjornG changed the title fix: fix test for pagination cursor test: fix test for pagination cursor Aug 26, 2024
@@ -244,55 +245,34 @@ describe('alerts api', () => {
property: 'createdTime',
order: 'desc',
},
cursor: '',
});
expect(response.items.length).toBe(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No alarm has been created at this point, so why is this expected?
Is it coming from a previous test?

Copy link

@vincent-cognite vincent-cognite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you are testing the pagination correctly. I am not sure I understand how the test is structured though...

@VebjornG VebjornG dismissed BugGambit’s stale review September 4, 2024 08:55

the problems were fixed

@VebjornG VebjornG merged commit a3e9106 into master Sep 4, 2024
9 checks passed
@VebjornG VebjornG deleted the vebjorn/fix-test branch September 4, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants