Fix e2e tests for consentCategories rename

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-05 11:15:52 +04:00
parent 39db90168c
commit 23e1186f0d
2 changed files with 33 additions and 33 deletions

View File

@@ -159,7 +159,7 @@ func TestCookieBanner_Create(t *testing.T) {
query($id: ID!) { query($id: ID!) {
node(id: $id) { node(id: $id) {
... on CookieBanner { ... on CookieBanner {
categories(first: 10) { consentCategories(first: 10) {
totalCount totalCount
edges { edges {
node { node {
@@ -176,7 +176,7 @@ func TestCookieBanner_Create(t *testing.T) {
var result struct { var result struct {
Node struct { Node struct {
Categories struct { ConsentCategories struct {
TotalCount int `json:"totalCount"` TotalCount int `json:"totalCount"`
Edges []struct { Edges []struct {
Node struct { Node struct {
@@ -185,16 +185,16 @@ func TestCookieBanner_Create(t *testing.T) {
Kind string `json:"kind"` Kind string `json:"kind"`
} `json:"node"` } `json:"node"`
} `json:"edges"` } `json:"edges"`
} `json:"categories"` } `json:"consentCategories"`
} `json:"node"` } `json:"node"`
} }
err := owner.Execute(query, map[string]any{"id": bannerID}, &result) err := owner.Execute(query, map[string]any{"id": bannerID}, &result)
require.NoError(t, err) require.NoError(t, err)
assert.Greater(t, result.Node.Categories.TotalCount, 0) assert.Greater(t, result.Node.ConsentCategories.TotalCount, 0)
kinds := make(map[string]bool) kinds := make(map[string]bool)
for _, e := range result.Node.Categories.Edges { for _, e := range result.Node.ConsentCategories.Edges {
kinds[e.Node.Kind] = true kinds[e.Node.Kind] = true
} }
assert.True(t, kinds["NECESSARY"], "should have a NECESSARY category") assert.True(t, kinds["NECESSARY"], "should have a NECESSARY category")

View File

@@ -313,7 +313,7 @@ func TestCookieCategory_Delete(t *testing.T) {
query($id: ID!) { query($id: ID!) {
node(id: $id) { node(id: $id) {
... on CookieBanner { ... on CookieBanner {
categories(first: 20) { consentCategories(first: 20) {
edges { edges {
node { node {
id id
@@ -328,14 +328,14 @@ func TestCookieCategory_Delete(t *testing.T) {
var listResult struct { var listResult struct {
Node struct { Node struct {
Categories struct { ConsentCategories struct {
Edges []struct { Edges []struct {
Node struct { Node struct {
ID string `json:"id"` ID string `json:"id"`
Kind string `json:"kind"` Kind string `json:"kind"`
} `json:"node"` } `json:"node"`
} `json:"edges"` } `json:"edges"`
} `json:"categories"` } `json:"consentCategories"`
} `json:"node"` } `json:"node"`
} }
@@ -343,7 +343,7 @@ func TestCookieCategory_Delete(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
var necessaryCategoryID string var necessaryCategoryID string
for _, e := range listResult.Node.Categories.Edges { for _, e := range listResult.Node.ConsentCategories.Edges {
if e.Node.Kind == "NECESSARY" { if e.Node.Kind == "NECESSARY" {
necessaryCategoryID = e.Node.ID necessaryCategoryID = e.Node.ID
break break
@@ -420,7 +420,7 @@ func TestCookieCategory_List(t *testing.T) {
query($id: ID!) { query($id: ID!) {
node(id: $id) { node(id: $id) {
... on CookieBanner { ... on CookieBanner {
categories(first: 20, orderBy: {field: RANK, direction: ASC}) { consentCategories(first: 20, orderBy: {field: RANK, direction: ASC}) {
totalCount totalCount
edges { edges {
node { node {
@@ -440,7 +440,7 @@ func TestCookieCategory_List(t *testing.T) {
var result struct { var result struct {
Node struct { Node struct {
Categories struct { ConsentCategories struct {
TotalCount int `json:"totalCount"` TotalCount int `json:"totalCount"`
Edges []struct { Edges []struct {
Node struct { Node struct {
@@ -452,7 +452,7 @@ func TestCookieCategory_List(t *testing.T) {
HasNextPage bool `json:"hasNextPage"` HasNextPage bool `json:"hasNextPage"`
HasPreviousPage bool `json:"hasPreviousPage"` HasPreviousPage bool `json:"hasPreviousPage"`
} `json:"pageInfo"` } `json:"pageInfo"`
} `json:"categories"` } `json:"consentCategories"`
} `json:"node"` } `json:"node"`
} }
@@ -460,13 +460,13 @@ func TestCookieCategory_List(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// Default categories + 2 custom ones // Default categories + 2 custom ones
assert.GreaterOrEqual(t, result.Node.Categories.TotalCount, 4) assert.GreaterOrEqual(t, result.Node.ConsentCategories.TotalCount, 4)
// Verify ordering (ranks should be ascending) // Verify ordering (ranks should be ascending)
for i := 1; i < len(result.Node.Categories.Edges); i++ { for i := 1; i < len(result.Node.ConsentCategories.Edges); i++ {
assert.GreaterOrEqual(t, assert.GreaterOrEqual(t,
result.Node.Categories.Edges[i].Node.Rank, result.Node.ConsentCategories.Edges[i].Node.Rank,
result.Node.Categories.Edges[i-1].Node.Rank, result.Node.ConsentCategories.Edges[i-1].Node.Rank,
) )
} }
}) })