From 065035631c908ae66ab4f5310620637eecf12e70 Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Fri, 18 Oct 2024 11:46:27 +0100 Subject: [PATCH] Check JSONAPI sorting (#1234) ### What Wasn't sure what was implemented, added some tests, it's working. This PR is stacked on top of https://github.com/hasura/v3-engine/pull/1233 V3_GIT_ORIGIN_REV_ID: fbfce6dd8ce325c5a1659db2755a09c7728030f2 --- .../jsonapi/tests/passing/ordering/Artist.txt | 1 + .../passing/reversed-ordering/Artist.txt | 1 + ...en_tests__result@ordering__Artist.txt.snap | 72 +++++++++++++++++++ ..._result@reversed-ordering__Artist.txt.snap | 72 +++++++++++++++++++ ...sts__result@select_model__Artist.txt.snap} | 0 ...ts__result@select_model__Authors.txt.snap} | 0 6 files changed, 146 insertions(+) create mode 100644 v3/crates/jsonapi/tests/passing/ordering/Artist.txt create mode 100644 v3/crates/jsonapi/tests/passing/reversed-ordering/Artist.txt create mode 100644 v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@ordering__Artist.txt.snap create mode 100644 v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@reversed-ordering__Artist.txt.snap rename v3/crates/jsonapi/tests/snapshots/{jsonapi_golden_tests__result@Artist.txt.snap => jsonapi_golden_tests__result@select_model__Artist.txt.snap} (100%) rename v3/crates/jsonapi/tests/snapshots/{jsonapi_golden_tests__result@Authors.txt.snap => jsonapi_golden_tests__result@select_model__Authors.txt.snap} (100%) diff --git a/v3/crates/jsonapi/tests/passing/ordering/Artist.txt b/v3/crates/jsonapi/tests/passing/ordering/Artist.txt new file mode 100644 index 00000000000..ae1a3a8056e --- /dev/null +++ b/v3/crates/jsonapi/tests/passing/ordering/Artist.txt @@ -0,0 +1 @@ +fields[Artist]=ArtistId,Name&page[offset]=0&page[limit]=5&sort=Name diff --git a/v3/crates/jsonapi/tests/passing/reversed-ordering/Artist.txt b/v3/crates/jsonapi/tests/passing/reversed-ordering/Artist.txt new file mode 100644 index 00000000000..7a834c6ef93 --- /dev/null +++ b/v3/crates/jsonapi/tests/passing/reversed-ordering/Artist.txt @@ -0,0 +1 @@ +fields[Artist]=ArtistId,Name&page[offset]=0&page[limit]=5&sort=-Name diff --git a/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@ordering__Artist.txt.snap b/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@ordering__Artist.txt.snap new file mode 100644 index 00000000000..abff95cce5e --- /dev/null +++ b/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@ordering__Artist.txt.snap @@ -0,0 +1,72 @@ +--- +source: crates/jsonapi/tests/jsonapi_golden_tests.rs +expression: result +input_file: crates/jsonapi/tests/passing/ordering/Artist.txt +--- +DocumentData { + data: Some( + Multiple( + [ + Resource { + _type: "default_Artist", + id: "1", + attributes: { + "ArtistId": Number(230), + "Name": String("Aaron Copland & London Symphony Orchestra"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "2", + attributes: { + "ArtistId": Number(202), + "Name": String("Aaron Goldberg"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "3", + attributes: { + "ArtistId": Number(215), + "Name": String("Academy of St. Martin in the Fields Chamber Ensemble & Sir Neville Marriner"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "4", + attributes: { + "ArtistId": Number(222), + "Name": String("Academy of St. Martin in the Fields, John Birch, Sir Neville Marriner & Sylvia McNair"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "5", + attributes: { + "ArtistId": Number(214), + "Name": String("Academy of St. Martin in the Fields & Sir Neville Marriner"), + }, + relationships: None, + links: None, + meta: None, + }, + ], + ), + ), + included: None, + links: None, + meta: None, + jsonapi: None, +} diff --git a/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@reversed-ordering__Artist.txt.snap b/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@reversed-ordering__Artist.txt.snap new file mode 100644 index 00000000000..0d8e115dc55 --- /dev/null +++ b/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@reversed-ordering__Artist.txt.snap @@ -0,0 +1,72 @@ +--- +source: crates/jsonapi/tests/jsonapi_golden_tests.rs +expression: result +input_file: crates/jsonapi/tests/passing/reversed-ordering/Artist.txt +--- +DocumentData { + data: Some( + Multiple( + [ + Resource { + _type: "default_Artist", + id: "1", + attributes: { + "ArtistId": Number(155), + "Name": String("Zeca Pagodinho"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "2", + attributes: { + "ArtistId": Number(212), + "Name": String("Yo-Yo Ma"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "3", + attributes: { + "ArtistId": Number(168), + "Name": String("Youssou E'Dour"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "4", + attributes: { + "ArtistId": Number(255), + "Name": String("Yehudi Menuhin"), + }, + relationships: None, + links: None, + meta: None, + }, + Resource { + _type: "default_Artist", + id: "5", + attributes: { + "ArtistId": Number(181), + "Name": String("Xis"), + }, + relationships: None, + links: None, + meta: None, + }, + ], + ), + ), + included: None, + links: None, + meta: None, + jsonapi: None, +} diff --git a/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@Artist.txt.snap b/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@select_model__Artist.txt.snap similarity index 100% rename from v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@Artist.txt.snap rename to v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@select_model__Artist.txt.snap diff --git a/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@Authors.txt.snap b/v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@select_model__Authors.txt.snap similarity index 100% rename from v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@Authors.txt.snap rename to v3/crates/jsonapi/tests/snapshots/jsonapi_golden_tests__result@select_model__Authors.txt.snap