Skip to content

Commit

Permalink
chore: update schema tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelab committed Jun 27, 2024
1 parent 6eba226 commit cf84240
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 49 deletions.
10 changes: 8 additions & 2 deletions tests/schema/specs/blocks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ test('Blocks', async () => {
__typename
... on MediaImage {
__typename
source
alt
}
... on MediaVideo {
__typename
url
}
}
}
Expand Down Expand Up @@ -92,10 +95,10 @@ test('Blocks', async () => {
}
}
{
complete: _loadDrupalPage(id: "a397ca48-8fad-411e-8901-0eba2feb989c") {
complete: viewPage(path: "/en/blocks-complete") {
...Blocks
}
minimal: _loadDrupalPage(id: "ceb9b2a7-4c4c-4084-ada9-d5f6505d466b") {
minimal: viewPage(path: "/en/blocks-minimal") {
...Blocks
}
}
Expand Down Expand Up @@ -132,13 +135,16 @@ test('Blocks', async () => {
"caption": "Media image",
"media": {
"__typename": "MediaImage",
"alt": "A beautiful landscape.",
"source": "{"src":"http:\\/\\/127.0.0.1:8000\\/sites\\/default\\/files\\/2023-04\\/landscape.jpg","width":2200,"height":1414,"originalSrc":"http:\\/\\/127.0.0.1:8000\\/sites\\/default\\/files\\/2023-04\\/landscape.jpg"}",
},
},
{
"__typename": "BlockMedia",
"caption": "Media video",
"media": {
"__typename": "MediaVideo",
"url": "http://127.0.0.1:8000/sites/default/files/2023-06/video_mp4_belt.mp4",
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions tests/schema/specs/content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ test('Page', async () => {
}
}
{
complete: _loadDrupalPage(id: "ef80e284-154b-41fd-9317-154b0a175299") {
complete: viewPage(path: "/en/page-complete") {
...Page
}
minimal: _loadDrupalPage(id: "17626bb4-557f-48fc-b869-ae566f4ceae6") {
minimal: viewPage(path: "/en/page-minimal") {
...Page
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/schema/specs/links.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fetch } from '../lib.js';
test('Links', async () => {
const result = await fetch(gql`
{
page: _loadDrupalPage(id: "25086be7-ca5f-4ff8-9695-b9c71a676d4e") {
page: viewPage(path: "/en/page-links") {
content {
__typename
... on BlockMarkup {
Expand Down
44 changes: 0 additions & 44 deletions tests/schema/specs/media.spec.ts

This file was deleted.

48 changes: 48 additions & 0 deletions tests/schema/specs/ssg-pages.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import gql from 'noop-tag';
import { describe, expect, it } from 'vitest';

import { fetch } from '../lib.js';

describe('SSG pages', () => {
it('returns limited results', async () => {
const result = await fetch(gql`
{
ssgPages(args: "pageSize=2&type=page") {
rows {
path
}
total
}
}
`);
expect(result.data.ssgPages.total).toBeGreaterThan(2);
expect(result.data.ssgPages.rows.length).toBe(2);
});

it('respects pagination', async () => {
const resultA = await fetch(gql`
{
ssgPages(args: "pageSize=1&page=2&type=page") {
rows {
path
}
}
}
`);
const resultB = await fetch(gql`
{
ssgPages(args: "pageSize=2&type=page") {
rows {
path
}
}
}
`);

expect(resultA.data.ssgPages.rows.length).toBe(1);
expect(resultB.data.ssgPages.rows.length).toBe(2);
expect(resultA.data.ssgPages.rows[0].path).toBe(
resultB.data.ssgPages.rows[1].path,
);
});
});
27 changes: 27 additions & 0 deletions tests/schema/specs/string-translations.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import gql from 'noop-tag';
import { expect, test } from 'vitest';

import { fetch } from '../lib.js';

test('string translations', async () => {
const result = await fetch(gql`
{
stringTranslations {
source
translation
language
}
}
`);
expect(result.data).toMatchInlineSnapshot(`
{
"stringTranslations": [
{
"language": "de",
"source": "Company name",
"translation": "Drupal Company",
},
],
}
`);
});

0 comments on commit cf84240

Please sign in to comment.