merges master 10.1.5
This commit is contained in:
@@ -188,6 +188,30 @@ const RichTextFields: CollectionConfig = {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'blocks',
|
||||
type: 'blocks',
|
||||
blocks: [
|
||||
{
|
||||
slug: 'textBlock',
|
||||
fields: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'text',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
slug: 'richTextBlock',
|
||||
fields: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'richText',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -440,12 +464,32 @@ export const richTextBulletsDoc = {
|
||||
],
|
||||
};
|
||||
|
||||
export const richTextBlocks = [
|
||||
{
|
||||
blockType: 'textBlock',
|
||||
text: 'Regular text',
|
||||
},
|
||||
{
|
||||
blockType: 'richTextBlock',
|
||||
text: [
|
||||
{
|
||||
children: [
|
||||
{
|
||||
text: 'Rich text',
|
||||
},
|
||||
],
|
||||
type: 'h1',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
export const richTextDoc = {
|
||||
title: 'Rich Text',
|
||||
selectHasMany: ['one', 'five'],
|
||||
richText: generateRichText(),
|
||||
richTextReadOnly: generateRichText(),
|
||||
richTextCustomFields: generateRichText(),
|
||||
blocks: richTextBlocks,
|
||||
};
|
||||
|
||||
export default RichTextFields;
|
||||
|
||||
@@ -736,6 +736,25 @@ describe('fields', () => {
|
||||
const textField = await editLinkModal.locator('#field-text');
|
||||
await expect(textField).toHaveValue('Hello, I\'m a rich text field.');
|
||||
});
|
||||
test('should not take value from previous block', async () => {
|
||||
await navigateToRichTextFields();
|
||||
|
||||
// check first block value
|
||||
const textField = await page.locator('#field-blocks__0__text');
|
||||
await expect(textField).toHaveValue('Regular text');
|
||||
|
||||
// remove the first block
|
||||
const editBlock = await page.locator('#blocks-row-0 .popup-button');
|
||||
await editBlock.click();
|
||||
const removeButton = await page.locator('#blocks-row-0').getByRole('button', { name: 'Remove' });
|
||||
await expect(removeButton).toBeVisible();
|
||||
await removeButton.click();
|
||||
|
||||
// check new first block value
|
||||
const richTextField = await page.locator('#field-blocks__0__text');
|
||||
const richTextValue = await richTextField.innerText();
|
||||
await expect(richTextValue).toContain('Rich text');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -880,6 +899,19 @@ describe('fields', () => {
|
||||
test('should modify fields in relationship drawer', async () => {
|
||||
await page.goto(url.create);
|
||||
|
||||
// First fill out the relationship field, as it's required
|
||||
await page.locator('#relationship-add-new .relationship-add-new__add-button').click();
|
||||
await page.locator('#field-relationship .relationship-add-new__relation-button--text-fields').click();
|
||||
|
||||
await page.locator('#field-text').fill('something');
|
||||
|
||||
await page.locator('[id^=doc-drawer_text-fields_1_] #action-save').click();
|
||||
await expect(page.locator('.Toastify')).toContainText('successfully');
|
||||
await page.locator('[id^=close-drawer__doc-drawer_text-fields_1_]').click();
|
||||
await page.locator('#action-save').click();
|
||||
await expect(page.locator('.Toastify')).toContainText('successfully');
|
||||
|
||||
|
||||
// Create a new doc for the `relationshipHasMany` field
|
||||
await page.locator('#field-relationshipHasMany button.relationship-add-new__add-button').click();
|
||||
const textField2 = page.locator('[id^=doc-drawer_text-fields_1_] #field-text');
|
||||
@@ -898,12 +930,17 @@ describe('fields', () => {
|
||||
await page.keyboard.down('1');
|
||||
await page.keyboard.down('2');
|
||||
await page.keyboard.down('3');
|
||||
// save drawer
|
||||
await page.locator('[id^=doc-drawer_text-fields_1_] #action-save').click();
|
||||
await expect(page.locator('.Toastify')).toContainText('successfully');
|
||||
// TODO: uncomment this when the drawer is fixed
|
||||
// await page.locator('[id^=close-drawer__doc-drawer_text-fields_1_]').click();
|
||||
// await expect(page.locator('#field-relationshipHasMany .relationship--multi-value-label__text')).toContainText(`${value}123`);
|
||||
await expect(page.locator('#field-relationshipHasMany .relationship--multi-value-label__text')).toContainText(value);
|
||||
// close drawer
|
||||
await page.locator('[id^=close-drawer__doc-drawer_text-fields_1_]').click();
|
||||
// save document and reload
|
||||
await page.locator('#action-save').click();
|
||||
await expect(page.locator('.Toastify')).toContainText('successfully');
|
||||
await page.reload();
|
||||
// check if the value is saved
|
||||
await expect(page.locator('#field-relationshipHasMany .relationship--multi-value-label__text')).toContainText(`${value}123`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { IndexDirection, IndexOptions } from 'mongoose';
|
||||
import { GraphQLClient } from 'graphql-request';
|
||||
import { initPayloadTest } from '../helpers/configHelpers';
|
||||
import { RESTClient } from '../helpers/rest';
|
||||
import configPromise from '../uploads/config';
|
||||
@@ -11,10 +12,14 @@ import { blocksFieldSeedData } from './collections/Blocks';
|
||||
import { localizedTextValue, namedTabDefaultValue, namedTabText, tabsDoc, tabsSlug } from './collections/Tabs';
|
||||
import { defaultNumber, numberDoc } from './collections/Number';
|
||||
import { dateDoc } from './collections/Date';
|
||||
import type { PaginatedDocs } from '../../src/mongoose/types';
|
||||
import type { RichTextField } from './payload-types';
|
||||
|
||||
let client;
|
||||
let graphQLClient: GraphQLClient;
|
||||
let serverURL;
|
||||
let config;
|
||||
let token;
|
||||
|
||||
describe('Fields', () => {
|
||||
beforeAll(async () => {
|
||||
@@ -22,7 +27,9 @@ describe('Fields', () => {
|
||||
config = await configPromise;
|
||||
|
||||
client = new RESTClient(config, { serverURL, defaultSlug: 'point-fields' });
|
||||
await client.login();
|
||||
const graphQLURL = `${serverURL}${config.routes.api}${config.routes.graphQL}`;
|
||||
graphQLClient = new GraphQLClient(graphQLURL);
|
||||
token = await client.login();
|
||||
});
|
||||
|
||||
describe('text', () => {
|
||||
@@ -730,5 +737,21 @@ describe('Fields', () => {
|
||||
expect(typeof child.doc.value.id).toBe('string');
|
||||
expect(child.doc.value.items).toHaveLength(6);
|
||||
});
|
||||
|
||||
it('should respect rich text depth parameter', async () => {
|
||||
const query = `query {
|
||||
RichTextFields {
|
||||
docs {
|
||||
richText(depth: 2)
|
||||
}
|
||||
}
|
||||
}`;
|
||||
const response = await graphQLClient.request(query, {}, {
|
||||
Authorization: `JWT ${token}`,
|
||||
});
|
||||
const { docs }: PaginatedDocs<RichTextField> = response.RichTextFields;
|
||||
const uploadElement = docs[0].richText.find((el) => el.type === 'upload') as any;
|
||||
expect(uploadElement.value.media.filename).toStrictEqual('payload.png');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ import AutosavePosts from './collections/Autosave';
|
||||
import AutosaveGlobal from './globals/Autosave';
|
||||
import { devUser } from '../credentials';
|
||||
|
||||
let collectionLocalPostID;
|
||||
let collectionLocalPostID: string;
|
||||
let collectionLocalVersionID;
|
||||
|
||||
let graphQLURL;
|
||||
@@ -24,6 +24,7 @@ const globalSlug = AutosaveGlobal.slug;
|
||||
let globalLocalVersionID;
|
||||
let globalGraphQLVersionID;
|
||||
const globalGraphQLOriginalTitle = 'updated global title';
|
||||
const updatedTitle = 'Here is an updated post title in EN';
|
||||
|
||||
describe('Versions', () => {
|
||||
beforeAll(async () => {
|
||||
@@ -47,41 +48,52 @@ describe('Versions', () => {
|
||||
graphQLClient = new GraphQLClient(graphQLURL, { headers: { Authorization: `JWT ${token}` } });
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
// First: delete potential existing versions from previous tests
|
||||
if (collectionLocalPostID) {
|
||||
await payload.delete({
|
||||
collection,
|
||||
id: collectionLocalPostID,
|
||||
});
|
||||
}
|
||||
|
||||
// now: initialize
|
||||
const autosavePost = await payload.create({
|
||||
collection,
|
||||
data: {
|
||||
title: 'Here is an autosave post in EN',
|
||||
description: '345j23o4ifj34jf54g',
|
||||
},
|
||||
});
|
||||
collectionLocalPostID = autosavePost.id;
|
||||
|
||||
const updatedPost: {
|
||||
title: string
|
||||
_status?: string
|
||||
} = await payload.update({
|
||||
id: collectionLocalPostID,
|
||||
collection,
|
||||
data: {
|
||||
title: updatedTitle,
|
||||
},
|
||||
});
|
||||
|
||||
const versions = await payload.findVersions({
|
||||
collection,
|
||||
});
|
||||
|
||||
collectionLocalVersionID = versions.docs[0].id;
|
||||
});
|
||||
|
||||
describe('Collections - Local', () => {
|
||||
describe('Create', () => {
|
||||
it('should allow a new version to be created and updated', async () => {
|
||||
const autosavePost = await payload.create({
|
||||
const updatedPost = await payload.findByID({
|
||||
collection,
|
||||
data: {
|
||||
title: 'Here is an autosave post in EN',
|
||||
description: '345j23o4ifj34jf54g',
|
||||
},
|
||||
});
|
||||
|
||||
collectionLocalPostID = autosavePost.id;
|
||||
|
||||
const updatedTitle = 'Here is an updated post title in EN';
|
||||
|
||||
const updatedPost: {
|
||||
title: string
|
||||
_status?: string
|
||||
} = await payload.update({
|
||||
id: collectionLocalPostID,
|
||||
collection,
|
||||
data: {
|
||||
title: updatedTitle,
|
||||
},
|
||||
});
|
||||
|
||||
expect(updatedPost.title).toBe(updatedTitle);
|
||||
expect(updatedPost._status).toStrictEqual('draft');
|
||||
|
||||
const versions = await payload.findVersions({
|
||||
collection,
|
||||
});
|
||||
|
||||
collectionLocalVersionID = versions.docs[0].id;
|
||||
|
||||
expect(collectionLocalVersionID).toBeDefined();
|
||||
});
|
||||
|
||||
@@ -173,8 +185,32 @@ describe('Versions', () => {
|
||||
});
|
||||
|
||||
describe('Restore', () => {
|
||||
it('should versions be in correct order', async () => {
|
||||
const somePost = await payload.create({
|
||||
collection,
|
||||
data: {
|
||||
title: 'first post',
|
||||
description: 'description 1',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const updatedPost = await payload.update({
|
||||
collection,
|
||||
id: collectionLocalPostID,
|
||||
data: {
|
||||
title: 'This should be the latest version',
|
||||
},
|
||||
});
|
||||
|
||||
const versions = await payload.findVersions({
|
||||
collection,
|
||||
});
|
||||
|
||||
expect(versions.docs[0].version.title).toBe(updatedPost.title);
|
||||
});
|
||||
it('should allow a version to be restored', async () => {
|
||||
const title2 = 'Here is an updated post title in EN';
|
||||
const title2 = 'Another updated post title in EN';
|
||||
|
||||
const updatedPost = await payload.update({
|
||||
collection,
|
||||
@@ -186,6 +222,14 @@ describe('Versions', () => {
|
||||
|
||||
expect(updatedPost.title).toBe(title2);
|
||||
|
||||
// Make sure it was updated correctly
|
||||
const draftFromUpdatedPost = await payload.findByID({
|
||||
collection,
|
||||
id: collectionLocalPostID,
|
||||
draft: true,
|
||||
});
|
||||
expect(draftFromUpdatedPost.title).toBe(title2);
|
||||
|
||||
const versions = await payload.findVersions({
|
||||
collection,
|
||||
});
|
||||
@@ -196,6 +240,7 @@ describe('Versions', () => {
|
||||
id: versions.docs[1].id,
|
||||
});
|
||||
|
||||
|
||||
expect(restoredVersion.title).toBeDefined();
|
||||
|
||||
const latestDraft = await payload.findByID({
|
||||
@@ -221,16 +266,14 @@ describe('Versions', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const updatedTitle = 'Here is a draft post with a patched title';
|
||||
|
||||
collectionLocalPostID = originalPublishedPost.id;
|
||||
const patchedTitle = 'Here is a draft post with a patched title';
|
||||
|
||||
await payload.update({
|
||||
id: collectionLocalPostID,
|
||||
id: originalPublishedPost.id,
|
||||
collection,
|
||||
locale: 'en',
|
||||
data: {
|
||||
title: updatedTitle,
|
||||
title: patchedTitle,
|
||||
},
|
||||
draft: true,
|
||||
});
|
||||
@@ -239,7 +282,7 @@ describe('Versions', () => {
|
||||
|
||||
// second update to existing draft
|
||||
await payload.update({
|
||||
id: collectionLocalPostID,
|
||||
id: originalPublishedPost.id,
|
||||
collection,
|
||||
locale: 'es',
|
||||
data: {
|
||||
@@ -250,18 +293,18 @@ describe('Versions', () => {
|
||||
|
||||
const publishedPost = await payload.findByID({
|
||||
collection,
|
||||
id: collectionLocalPostID,
|
||||
id: originalPublishedPost.id,
|
||||
});
|
||||
|
||||
const draftPost = await payload.findByID({
|
||||
collection,
|
||||
locale: 'all',
|
||||
id: collectionLocalPostID,
|
||||
id: originalPublishedPost.id,
|
||||
draft: true,
|
||||
});
|
||||
|
||||
expect(publishedPost.title).toBe(originalTitle);
|
||||
expect(draftPost.title.en).toBe(updatedTitle);
|
||||
expect(draftPost.title.en).toBe(patchedTitle);
|
||||
expect(draftPost.title.es).toBe(spanishTitle);
|
||||
});
|
||||
});
|
||||
@@ -534,12 +577,39 @@ describe('Versions', () => {
|
||||
});
|
||||
|
||||
describe('Collections - GraphQL', () => {
|
||||
beforeEach(async () => {
|
||||
// First: delete potential existing versions from previous tests
|
||||
if (collectionGraphQLPostID) {
|
||||
await payload.delete({
|
||||
collection,
|
||||
id: collectionGraphQLPostID,
|
||||
});
|
||||
}
|
||||
|
||||
const description = 'autosave description';
|
||||
|
||||
const query = `mutation {
|
||||
createAutosavePost(data: {title: "${collectionGraphQLOriginalTitle}", description: "${description}"}) {
|
||||
id
|
||||
title
|
||||
description
|
||||
createdAt
|
||||
updatedAt
|
||||
_status
|
||||
}
|
||||
}`;
|
||||
|
||||
const response = await graphQLClient.request(query);
|
||||
|
||||
const data = response.createAutosavePost;
|
||||
collectionGraphQLPostID = data.id;
|
||||
});
|
||||
describe('Create', () => {
|
||||
it('should allow a new doc to be created with draft status', async () => {
|
||||
const description = 'autosave description';
|
||||
const description2 = 'other autosave description';
|
||||
|
||||
const query = `mutation {
|
||||
createAutosavePost(data: {title: "${collectionGraphQLOriginalTitle}", description: "${description}"}) {
|
||||
createAutosavePost(data: {title: "${'Some other title'}", description: "${description2}"}) {
|
||||
id
|
||||
title
|
||||
description
|
||||
@@ -552,20 +622,19 @@ describe('Versions', () => {
|
||||
const response = await graphQLClient.request(query);
|
||||
|
||||
const data = response.createAutosavePost;
|
||||
collectionGraphQLPostID = data.id;
|
||||
|
||||
expect(data._status).toStrictEqual('draft');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Read', () => {
|
||||
const updatedTitle = 'updated title';
|
||||
const updatedTitle2 = 'updated title';
|
||||
|
||||
beforeAll(async () => {
|
||||
beforeEach(async () => {
|
||||
// modify the post to create a new version
|
||||
// language=graphQL
|
||||
const update = `mutation {
|
||||
updateAutosavePost(id: "${collectionGraphQLPostID}", data: {title: "${updatedTitle}"}) {
|
||||
updateAutosavePost(id: "${collectionGraphQLPostID}", data: {title: "${updatedTitle2}"}) {
|
||||
title
|
||||
updatedAt
|
||||
createdAt
|
||||
@@ -603,11 +672,10 @@ describe('Versions', () => {
|
||||
const response = await graphQLClient.request(query);
|
||||
|
||||
const data = response.versionAutosavePost;
|
||||
collectionGraphQLVersionID = data.id;
|
||||
|
||||
expect(data.id).toBeDefined();
|
||||
expect(data.parent.id).toStrictEqual(collectionGraphQLPostID);
|
||||
expect(data.version.title).toStrictEqual(updatedTitle);
|
||||
expect(data.version.title).toStrictEqual(updatedTitle2);
|
||||
});
|
||||
|
||||
it('should allow read of versions by querying version content', async () => {
|
||||
@@ -630,7 +698,6 @@ describe('Versions', () => {
|
||||
|
||||
const data = response.versionsAutosavePosts;
|
||||
const doc = data.docs[0];
|
||||
collectionGraphQLVersionID = doc.id;
|
||||
|
||||
expect(doc.id).toBeDefined();
|
||||
expect(doc.parent.id).toStrictEqual(collectionGraphQLPostID);
|
||||
@@ -639,8 +706,44 @@ describe('Versions', () => {
|
||||
});
|
||||
|
||||
describe('Restore', () => {
|
||||
beforeEach(async () => {
|
||||
// modify the post to create a new version
|
||||
// language=graphQL
|
||||
const update = `mutation {
|
||||
updateAutosavePost(id: "${collectionGraphQLPostID}", data: {title: "${collectionGraphQLOriginalTitle}"}) {
|
||||
title
|
||||
updatedAt
|
||||
createdAt
|
||||
}
|
||||
}`;
|
||||
await graphQLClient.request(update);
|
||||
|
||||
// language=graphQL
|
||||
const query = `query {
|
||||
versionsAutosavePosts(where: { parent: { equals: "${collectionGraphQLPostID}" } }) {
|
||||
docs {
|
||||
id
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
const response = await graphQLClient.request(query);
|
||||
|
||||
collectionGraphQLVersionID = response.versionsAutosavePosts.docs[0].id;
|
||||
});
|
||||
it('should allow a version to be restored', async () => {
|
||||
// update a versionsPost
|
||||
// Update it
|
||||
const update = `mutation {
|
||||
updateAutosavePost(id: "${collectionGraphQLPostID}", data: {title: "${'Wrong title'}"}) {
|
||||
title
|
||||
updatedAt
|
||||
createdAt
|
||||
}
|
||||
}`;
|
||||
await graphQLClient.request(update);
|
||||
|
||||
|
||||
// restore a versionsPost
|
||||
const restore = `mutation {
|
||||
restoreVersionAutosavePost(id: "${collectionGraphQLVersionID}") {
|
||||
title
|
||||
@@ -663,32 +766,38 @@ describe('Versions', () => {
|
||||
});
|
||||
|
||||
describe('Globals - Local', () => {
|
||||
beforeEach(async () => {
|
||||
const title2 = 'Here is an updated global title in EN';
|
||||
await payload.updateGlobal({
|
||||
slug: globalSlug,
|
||||
data: {
|
||||
title: 'Test Global',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const updatedGlobal = await payload.updateGlobal({
|
||||
slug: globalSlug,
|
||||
data: {
|
||||
title: title2,
|
||||
},
|
||||
});
|
||||
|
||||
const versions = await payload.findGlobalVersions({
|
||||
slug: globalSlug,
|
||||
});
|
||||
|
||||
globalLocalVersionID = versions.docs[0].id;
|
||||
});
|
||||
describe('Create', () => {
|
||||
it('should allow a new version to be created', async () => {
|
||||
await payload.updateGlobal({
|
||||
slug: globalSlug,
|
||||
data: {
|
||||
title: 'Test Global',
|
||||
},
|
||||
});
|
||||
|
||||
const title2 = 'Here is an updated global title in EN';
|
||||
|
||||
const updatedGlobal = await payload.updateGlobal({
|
||||
const updatedGlobal = await payload.findGlobal({
|
||||
slug: globalSlug,
|
||||
data: {
|
||||
title: title2,
|
||||
},
|
||||
});
|
||||
|
||||
expect(updatedGlobal.title).toBe(title2);
|
||||
expect(updatedGlobal._status).toStrictEqual('draft');
|
||||
|
||||
const versions = await payload.findGlobalVersions({
|
||||
slug: globalSlug,
|
||||
});
|
||||
|
||||
globalLocalVersionID = versions.docs[0].id;
|
||||
expect(globalLocalVersionID).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -746,7 +855,7 @@ describe('Versions', () => {
|
||||
|
||||
describe('Restore', () => {
|
||||
it('should allow a version to be restored', async () => {
|
||||
const title2 = 'Here is an updated title in EN';
|
||||
const title2 = 'Another updated title in EN';
|
||||
|
||||
const updatedGlobal = await payload.updateGlobal({
|
||||
slug: globalSlug,
|
||||
@@ -757,11 +866,19 @@ describe('Versions', () => {
|
||||
|
||||
expect(updatedGlobal.title).toBe(title2);
|
||||
|
||||
// Make sure it was updated correctly
|
||||
const foundUpdatedGlobal = await payload.findGlobal({
|
||||
slug: globalSlug,
|
||||
draft: true,
|
||||
});
|
||||
expect(foundUpdatedGlobal.title).toBe(title2);
|
||||
|
||||
|
||||
const versions = await payload.findGlobalVersions({
|
||||
slug: globalSlug,
|
||||
});
|
||||
|
||||
globalLocalVersionID = versions.docs[0].id;
|
||||
globalLocalVersionID = versions.docs[1].id;
|
||||
|
||||
const restore = await payload.restoreGlobalVersion({
|
||||
slug: globalSlug,
|
||||
@@ -797,13 +914,13 @@ describe('Versions', () => {
|
||||
draft: true,
|
||||
});
|
||||
|
||||
const updatedTitle = 'Here is a draft global with a patched title';
|
||||
const updatedTitle2 = 'Here is a draft global with a patched title';
|
||||
|
||||
await payload.updateGlobal({
|
||||
slug: globalSlug,
|
||||
locale: 'en',
|
||||
data: {
|
||||
title: updatedTitle,
|
||||
title: updatedTitle2,
|
||||
},
|
||||
draft: true,
|
||||
});
|
||||
@@ -812,7 +929,7 @@ describe('Versions', () => {
|
||||
slug: globalSlug,
|
||||
locale: 'es',
|
||||
data: {
|
||||
title: updatedTitle,
|
||||
title: updatedTitle2,
|
||||
},
|
||||
draft: true,
|
||||
});
|
||||
@@ -824,8 +941,8 @@ describe('Versions', () => {
|
||||
});
|
||||
|
||||
expect(publishedGlobal.title).toBe(originalTitle);
|
||||
expect(updatedGlobal.title.en).toBe(updatedTitle);
|
||||
expect(updatedGlobal.title.es).toBe(updatedTitle);
|
||||
expect(updatedGlobal.title.en).toBe(updatedTitle2);
|
||||
expect(updatedGlobal.title.es).toBe(updatedTitle2);
|
||||
});
|
||||
|
||||
it('should allow a draft to be published', async () => {
|
||||
@@ -840,52 +957,51 @@ describe('Versions', () => {
|
||||
draft: true,
|
||||
});
|
||||
|
||||
const updatedTitle = 'Now try to publish';
|
||||
const updatedTitle2 = 'Now try to publish';
|
||||
|
||||
const result = await payload.updateGlobal({
|
||||
slug: globalSlug,
|
||||
data: {
|
||||
title: updatedTitle,
|
||||
title: updatedTitle2,
|
||||
_status: 'published',
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.title).toBe(updatedTitle);
|
||||
expect(result.title).toBe(updatedTitle2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Globals - GraphQL', () => {
|
||||
describe('Read', () => {
|
||||
beforeAll(async () => {
|
||||
// language=graphql
|
||||
const update = `mutation {
|
||||
updateAutosaveGlobal(draft: true, data: {
|
||||
title: "${globalGraphQLOriginalTitle}"
|
||||
}) {
|
||||
_status
|
||||
title
|
||||
}
|
||||
}`;
|
||||
await graphQLClient.request(update);
|
||||
beforeAll(async () => {
|
||||
// language=graphql
|
||||
const update = `mutation {
|
||||
updateAutosaveGlobal(draft: true, data: {
|
||||
title: "${globalGraphQLOriginalTitle}"
|
||||
}) {
|
||||
_status
|
||||
title
|
||||
}
|
||||
}`;
|
||||
await graphQLClient.request(update);
|
||||
|
||||
// language=graphQL
|
||||
const query = `query {
|
||||
versionsAutosaveGlobal(where: { version__title: { equals: "${globalGraphQLOriginalTitle}" } }) {
|
||||
docs {
|
||||
id
|
||||
version {
|
||||
title
|
||||
}
|
||||
// language=graphQL
|
||||
const query = `query {
|
||||
versionsAutosaveGlobal(where: { version__title: { equals: "${globalGraphQLOriginalTitle}" } }) {
|
||||
docs {
|
||||
id
|
||||
version {
|
||||
title
|
||||
}
|
||||
}
|
||||
}`;
|
||||
}
|
||||
}`;
|
||||
|
||||
const response = await graphQLClient.request(query);
|
||||
|
||||
globalGraphQLVersionID = response.versionsAutosaveGlobal.docs[0].id;
|
||||
});
|
||||
const response = await graphQLClient.request(query);
|
||||
|
||||
globalGraphQLVersionID = response.versionsAutosaveGlobal.docs[0].id;
|
||||
});
|
||||
describe('Read', () => {
|
||||
it('should allow read of versions by version id', async () => {
|
||||
// language=graphql
|
||||
const query = `query {
|
||||
@@ -900,7 +1016,6 @@ describe('Versions', () => {
|
||||
const response = await graphQLClient.request(query);
|
||||
|
||||
const data = response.versionAutosaveGlobal;
|
||||
globalGraphQLVersionID = data.id;
|
||||
|
||||
expect(data.id).toBeDefined();
|
||||
expect(data.version.title).toStrictEqual(globalGraphQLOriginalTitle);
|
||||
@@ -923,7 +1038,6 @@ describe('Versions', () => {
|
||||
|
||||
const data = response.versionsAutosaveGlobal;
|
||||
const doc = data.docs[0];
|
||||
globalGraphQLVersionID = doc.id;
|
||||
|
||||
expect(doc.id).toBeDefined();
|
||||
expect(doc.version.title).toStrictEqual(globalGraphQLOriginalTitle);
|
||||
|
||||
Reference in New Issue
Block a user