mirror of
https://github.com/strapi/strapi.git
synced 2025-08-18 13:45:25 +00:00
Cleanup tests
This commit is contained in:
parent
3c70b18451
commit
b93b4e105d
@ -13,7 +13,7 @@ const selectFields = doc => _.pick(doc, ['id', 'name']);
|
|||||||
const documentModel = {
|
const documentModel = {
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: 'title',
|
name: 'name',
|
||||||
params: {
|
params: {
|
||||||
appearance: {
|
appearance: {
|
||||||
WYSIWYG: false,
|
WYSIWYG: false,
|
||||||
@ -126,7 +126,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
documents: [],
|
documents: [],
|
||||||
};
|
};
|
||||||
const labelsPayload = [{ name: 'label 1' }, { name: 'label 2' }];
|
const labelsPayload = [{ name: 'label 1' }, { name: 'label 2' }];
|
||||||
const documentsPayload = [{ title: 'document 1' }, { title: 'document 2' }];
|
const documentsPayload = [{ name: 'document 1' }, { name: 'document 2' }];
|
||||||
|
|
||||||
test.each(labelsPayload)('Create label %o', async label => {
|
test.each(labelsPayload)('Create label %o', async label => {
|
||||||
const res = await graphqlQuery({
|
const res = await graphqlQuery({
|
||||||
@ -189,7 +189,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
mutation createDocument($input: createDocumentInput) {
|
mutation createDocument($input: createDocumentInput) {
|
||||||
createDocument(input: $input) {
|
createDocument(input: $input) {
|
||||||
document {
|
document {
|
||||||
title
|
name
|
||||||
labels {
|
labels {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -230,7 +230,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
{
|
{
|
||||||
documents {
|
documents {
|
||||||
id
|
id
|
||||||
title
|
name
|
||||||
labels {
|
labels {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -245,10 +245,12 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
expect(res.statusCode).toBe(200);
|
expect(res.statusCode).toBe(200);
|
||||||
expect(body).toMatchObject({
|
expect(body).toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
documents: documentsPayload.map(document => ({
|
documents: expect.arrayContaining(
|
||||||
|
documentsPayload.map(document => ({
|
||||||
...selectFields(document),
|
...selectFields(document),
|
||||||
labels: data.labels.map(selectFields),
|
labels: expect.arrayContaining(data.labels.map(selectFields)),
|
||||||
})),
|
}))
|
||||||
|
),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -265,7 +267,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
name
|
name
|
||||||
documents {
|
documents {
|
||||||
id
|
id
|
||||||
title
|
name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,10 +279,12 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
expect(res.statusCode).toBe(200);
|
expect(res.statusCode).toBe(200);
|
||||||
expect(body).toMatchObject({
|
expect(body).toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
labels: labelsPayload.map(label => ({
|
labels: expect.arrayContaining(
|
||||||
|
labelsPayload.map(label => ({
|
||||||
...selectFields(label),
|
...selectFields(label),
|
||||||
documents: data.documents.map(selectFields),
|
documents: expect.arrayContaining(data.documents.map(selectFields)),
|
||||||
})),
|
}))
|
||||||
|
),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -294,7 +298,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
{
|
{
|
||||||
documents(where: { labels: { name_contains: "label 1" } }) {
|
documents(where: { labels: { name_contains: "label 1" } }) {
|
||||||
id
|
id
|
||||||
title
|
name
|
||||||
labels {
|
labels {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -307,7 +311,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
expect(res.statusCode).toBe(200);
|
expect(res.statusCode).toBe(200);
|
||||||
expect(res.body).toMatchObject({
|
expect(res.body).toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
documents: data.documents,
|
documents: expect.arrayContaining(data.documents),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -320,7 +324,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
updateDocument(input: $input) {
|
updateDocument(input: $input) {
|
||||||
document {
|
document {
|
||||||
id
|
id
|
||||||
title
|
name
|
||||||
labels {
|
labels {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -383,7 +387,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
{
|
{
|
||||||
documents {
|
documents {
|
||||||
id
|
id
|
||||||
title
|
name
|
||||||
labels {
|
labels {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -398,10 +402,12 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
expect(res.statusCode).toBe(200);
|
expect(res.statusCode).toBe(200);
|
||||||
expect(body).toMatchObject({
|
expect(body).toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
documents: data.documents.map(document => ({
|
documents: expect.arrayContaining(
|
||||||
|
data.documents.map(document => ({
|
||||||
...selectFields(document),
|
...selectFields(document),
|
||||||
labels: [],
|
labels: [],
|
||||||
})),
|
}))
|
||||||
|
),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -413,7 +419,7 @@ describe('Test Graphql Relations API End to End', () => {
|
|||||||
mutation deleteDocument($input: deleteDocumentInput) {
|
mutation deleteDocument($input: deleteDocumentInput) {
|
||||||
deleteDocument(input: $input) {
|
deleteDocument(input: $input) {
|
||||||
document {
|
document {
|
||||||
title
|
name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ const test = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const database = process.argv.length > 2 ? process.argv.slice(2).join(' ') : databases.mongo;
|
const database = process.argv.length > 2 ? process.argv.slice(2).join(' ') : databases.postgres;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await cleanTestApp(appName);
|
await cleanTestApp(appName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user