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!) {
node(id: $id) {
... on CookieBanner {
categories(first: 10) {
consentCategories(first: 10) {
totalCount
edges {
node {
@@ -176,7 +176,7 @@ func TestCookieBanner_Create(t *testing.T) {
var result struct {
Node struct {
Categories struct {
ConsentCategories struct {
TotalCount int `json:"totalCount"`
Edges []struct {
Node struct {
@@ -185,16 +185,16 @@ func TestCookieBanner_Create(t *testing.T) {
Kind string `json:"kind"`
} `json:"node"`
} `json:"edges"`
} `json:"categories"`
} `json:"consentCategories"`
} `json:"node"`
}
err := owner.Execute(query, map[string]any{"id": bannerID}, &result)
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)
for _, e := range result.Node.Categories.Edges {
for _, e := range result.Node.ConsentCategories.Edges {
kinds[e.Node.Kind] = true
}
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!) {
node(id: $id) {
... on CookieBanner {
categories(first: 20) {
consentCategories(first: 20) {
edges {
node {
id
@@ -328,14 +328,14 @@ func TestCookieCategory_Delete(t *testing.T) {
var listResult struct {
Node struct {
Categories struct {
Edges []struct {
Node struct {
ID string `json:"id"`
Kind string `json:"kind"`
} `json:"node"`
} `json:"edges"`
} `json:"categories"`
ConsentCategories struct {
Edges []struct {
Node struct {
ID string `json:"id"`
Kind string `json:"kind"`
} `json:"node"`
} `json:"edges"`
} `json:"consentCategories"`
} `json:"node"`
}
@@ -343,7 +343,7 @@ func TestCookieCategory_Delete(t *testing.T) {
require.NoError(t, err)
var necessaryCategoryID string
for _, e := range listResult.Node.Categories.Edges {
for _, e := range listResult.Node.ConsentCategories.Edges {
if e.Node.Kind == "NECESSARY" {
necessaryCategoryID = e.Node.ID
break
@@ -420,7 +420,7 @@ func TestCookieCategory_List(t *testing.T) {
query($id: ID!) {
node(id: $id) {
... on CookieBanner {
categories(first: 20, orderBy: {field: RANK, direction: ASC}) {
consentCategories(first: 20, orderBy: {field: RANK, direction: ASC}) {
totalCount
edges {
node {
@@ -440,19 +440,19 @@ func TestCookieCategory_List(t *testing.T) {
var result struct {
Node struct {
Categories struct {
TotalCount int `json:"totalCount"`
Edges []struct {
Node struct {
ID string `json:"id"`
Rank int `json:"rank"`
} `json:"node"`
} `json:"edges"`
PageInfo struct {
HasNextPage bool `json:"hasNextPage"`
HasPreviousPage bool `json:"hasPreviousPage"`
} `json:"pageInfo"`
} `json:"categories"`
ConsentCategories struct {
TotalCount int `json:"totalCount"`
Edges []struct {
Node struct {
ID string `json:"id"`
Rank int `json:"rank"`
} `json:"node"`
} `json:"edges"`
PageInfo struct {
HasNextPage bool `json:"hasNextPage"`
HasPreviousPage bool `json:"hasPreviousPage"`
} `json:"pageInfo"`
} `json:"consentCategories"`
} `json:"node"`
}
@@ -460,13 +460,13 @@ func TestCookieCategory_List(t *testing.T) {
require.NoError(t, err)
// 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)
for i := 1; i < len(result.Node.Categories.Edges); i++ {
for i := 1; i < len(result.Node.ConsentCategories.Edges); i++ {
assert.GreaterOrEqual(t,
result.Node.Categories.Edges[i].Node.Rank,
result.Node.Categories.Edges[i-1].Node.Rank,
result.Node.ConsentCategories.Edges[i].Node.Rank,
result.Node.ConsentCategories.Edges[i-1].Node.Rank,
)
}
})