Fix lint and cypress

This commit is contained in:
roschaefer 2020-01-29 00:51:04 +01:00
parent f9c42ab2a5
commit 910f122087
4 changed files with 249 additions and 168 deletions

View File

@ -935,132 +935,252 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
await Factory.buildList('user', 30) await Factory.buildList('user', 30)
await Factory.buildList( 'post', 30, { await Factory.buildList(
'post',
30,
{
image: faker.image.unsplash.objects(), image: faker.image.unsplash.objects(),
}, { },
{
categoryIds: ['cat1'], categoryIds: ['cat1'],
author: jennyRostock, author: jennyRostock,
}) },
)
await Factory.buildList('comment', 6, {}, { await Factory.buildList(
'comment',
6,
{},
{
author: jennyRostock, author: jennyRostock,
postId: 'p2', postId: 'p2',
}) },
)
await Factory.buildList('comment', 4, {}, { await Factory.buildList(
'comment',
4,
{},
{
author: jennyRostock, author: jennyRostock,
postId: 'p15', postId: 'p15',
}) },
)
await Factory.buildList( 'comment', 2, {}, { await Factory.buildList(
'comment',
2,
{},
{
author: jennyRostock, author: jennyRostock,
postId: 'p4', postId: 'p4',
}) },
)
await Factory.buildList('post', 21, { await Factory.buildList(
'post',
21,
{
image: faker.image.unsplash.buildings(), image: faker.image.unsplash.buildings(),
}, { },
{
author: peterLustig, author: peterLustig,
}) },
)
await Factory.buildList('comment', 3, {}, { await Factory.buildList(
'comment',
3,
{},
{
author: peterLustig, author: peterLustig,
postId: 'p4', postId: 'p4',
}) },
)
await Factory.buildList('comment', 5, {}, { await Factory.buildList(
'comment',
5,
{},
{
author: peterLustig, author: peterLustig,
postId: 'p14', postId: 'p14',
}) },
)
await Factory.buildList('comment', 6, {}, { await Factory.buildList(
'comment',
6,
{},
{
author: peterLustig, author: peterLustig,
postId: 'p0', postId: 'p0',
}) },
)
await Factory.buildList( 'post', 11, { await Factory.buildList(
'post',
11,
{
image: faker.image.unsplash.food(), image: faker.image.unsplash.food(),
}, { },
{
author: dewey, author: dewey,
}) },
)
await Factory.buildList( 'comment', 7, {}, { await Factory.buildList(
'comment',
7,
{},
{
author: dewey, author: dewey,
postId: 'p2', postId: 'p2',
}) },
)
await Factory.buildList( 'comment', 5, {}, { await Factory.buildList(
'comment',
5,
{},
{
author: dewey, author: dewey,
postId: 'p6', postId: 'p6',
}) },
)
await Factory.buildList( 'comment', 2, {}, { await Factory.buildList(
'comment',
2,
{},
{
author: dewey, author: dewey,
postId: 'p9', postId: 'p9',
}) },
)
await Factory.buildList('post', 16, { await Factory.buildList(
'post',
16,
{
image: faker.image.unsplash.technology(), image: faker.image.unsplash.technology(),
}, { },
{
author: louie, author: louie,
}) },
)
await Factory.buildList('comment', 4, {}, { await Factory.buildList(
'comment',
4,
{},
{
postId: 'p1', postId: 'p1',
author: louie, author: louie,
}) },
)
await Factory.buildList('comment', 8, {}, { await Factory.buildList(
'comment',
8,
{},
{
author: louie, author: louie,
postId: 'p10', postId: 'p10',
}) },
)
await Factory.buildList('comment', 5, {}, { await Factory.buildList(
'comment',
5,
{},
{
author: louie, author: louie,
postId: 'p13', postId: 'p13',
}) },
)
await Factory.buildList('post', 45, { await Factory.buildList(
'post',
45,
{
image: faker.image.unsplash.people(), image: faker.image.unsplash.people(),
}, { },
{
author: bobDerBaumeister, author: bobDerBaumeister,
}) },
)
await Factory.buildList('comment', 2, {}, { await Factory.buildList(
'comment',
2,
{},
{
author: bobDerBaumeister, author: bobDerBaumeister,
postId: 'p2', postId: 'p2',
}) },
)
await Factory.buildList( 'comment', 3, {}, { await Factory.buildList(
'comment',
3,
{},
{
author: bobDerBaumeister, author: bobDerBaumeister,
postId: 'p12', postId: 'p12',
}) },
)
await Factory.buildList( 'comment', 7, {}, { await Factory.buildList(
'comment',
7,
{},
{
author: bobDerBaumeister, author: bobDerBaumeister,
postId: 'p13', postId: 'p13',
}) },
)
await Factory.buildList( 'post', 8, { await Factory.buildList(
'post',
8,
{
image: faker.image.unsplash.nature(), image: faker.image.unsplash.nature(),
}, { },
{
author: huey, author: huey,
}) },
)
await Factory.buildList('comment', 6, {}, { await Factory.buildList(
'comment',
6,
{},
{
author: huey, author: huey,
postId: 'p0', postId: 'p0',
}) },
)
await Factory.buildList( 'comment', 8, {}, { await Factory.buildList(
'comment',
8,
{},
{
author: huey, author: huey,
postId: 'p13', postId: 'p13',
}) },
)
await Factory.buildList('comment', 9, {}, { await Factory.buildList(
'comment',
9,
{},
{
author: huey, author: huey,
postId: 'p15', postId: 'p15',
}) },
)
await Factory.build('donations') await Factory.build('donations')
/* eslint-disable-next-line no-console */ /* eslint-disable-next-line no-console */

View File

@ -42,26 +42,18 @@ Given("I am logged in as the muted user", () => {
}); });
Given("we have a selection of categories", () => { Given("we have a selection of categories", () => {
cy.createCategories("cat0", "just-for-fun"); cy.factory().build('category', { id: "cat0", slug: "just-for-fun" });
}); });
Given("we have a selection of tags and categories as well as posts", () => { Given("we have a selection of tags and categories as well as posts", () => {
cy.createCategories("cat12", "cat121", "cat122")
.factory()
.build("tag", {
id: "Ecology"
})
.build("tag", {
id: "Nature"
})
.build("tag", {
id: "Democracy"
});
cy.factory() cy.factory()
.build("user", { .build('category', { id: 'cat12', name: "Just For Fun", icon: "smile", })
id: 'a1' .build('category', { id: 'cat121', name: "Happiness & Values", icon: "heart-o"})
}) .build('category', { id: 'cat122', name: "Health & Wellbeing", icon: "medkit"})
.build("tag", { id: "Ecology" })
.build("tag", { id: "Nature" })
.build("tag", { id: "Democracy" })
.build("user", { id: 'a1' })
.build("post", {}, { .build("post", {}, {
authorId: 'a1', authorId: 'a1',
tagIds: ["Ecology", "Nature", "Democracy"], tagIds: ["Ecology", "Nature", "Democracy"],
@ -71,20 +63,14 @@ Given("we have a selection of tags and categories as well as posts", () => {
authorId: 'a1', authorId: 'a1',
tagIds: ["Nature", "Democracy"], tagIds: ["Nature", "Democracy"],
categoryIds: ["cat121"] categoryIds: ["cat121"]
});
cy.factory()
.build("user", {
id: 'a2'
}) })
.build("user", { id: 'a2' })
.build("post", {}, { .build("post", {}, {
authorId: 'a2', authorId: 'a2',
tagIds: ['Nature', 'Democracy'], tagIds: ['Nature', 'Democracy'],
categoryIds: ["cat12"] categoryIds: ["cat12"]
}); })
cy.factory()
.build("post", {}, { .build("post", {}, {
authorId: narratorParams.id,
tagIds: ['Democracy'], tagIds: ['Democracy'],
categoryIds: ["cat122"] categoryIds: ["cat122"]
}) })
@ -95,12 +81,12 @@ Given("we have the following user accounts:", table => {
cy.factory().build("user", { cy.factory().build("user", {
...params, ...params,
...termsAndConditionsAgreedVersion ...termsAndConditionsAgreedVersion
}); }, params);
}); });
}); });
Given("I have a user account", () => { Given("I have a user account", () => {
cy.factory().build("user", narratorParams); cy.factory().build("user", narratorParams, loginCredentials);
}); });
Given("my user account has the role {string}", role => { Given("my user account has the role {string}", role => {
@ -197,16 +183,16 @@ Given("we have the following posts in our database:", table => {
icon: "smile" icon: "smile"
}) })
table.hashes().forEach(({ table.hashes().forEach((attributesOrOptions, i) => {
...postAttributes cy.factory().build("post", {
}, i) => { ...attributesOrOptions,
postAttributes = { deleted: Boolean(attributesOrOptions.deleted),
...postAttributes, disabled: Boolean(attributesOrOptions.disabled),
deleted: Boolean(postAttributes.deleted), pinned: Boolean(attributesOrOptions.pinned),
disabled: Boolean(postAttributes.disabled), }, {
pinned: Boolean(postAttributes.pinned), ...attributesOrOptions,
} categoryIds: ['cat-456']
cy.factory().build("post", postAttributes, { categoryIds: ['cat-456'] }); });
}) })
}); });
@ -476,13 +462,11 @@ Given("I follow the user {string}", name => {
}); });
Given('"Spammy Spammer" wrote a post {string}', title => { Given('"Spammy Spammer" wrote a post {string}', title => {
cy.createCategories("cat21") cy.factory()
.factory()
.build("post", { .build("post", {
title, title,
}, { }, {
authorId: 'annoying-user', authorId: 'annoying-user',
categoryIds: ["cat21"]
}); });
}); });
@ -500,13 +484,11 @@ Then("nobody is following the user profile anymore", () => {
}); });
Given("I wrote a post {string}", title => { Given("I wrote a post {string}", title => {
cy.createCategories(`cat213`, title) cy.factory()
.factory()
.build("post", { .build("post", {
title, title,
}, { }, {
authorId: narratorParams.id, authorId: narratorParams.id,
categoryIds: ["cat213"]
}); });
}); });

View File

@ -75,27 +75,6 @@ Cypress.Commands.add("openPage", page => {
cy.visit(`/${page}`); cy.visit(`/${page}`);
}); });
Cypress.Commands.add("createCategories", (id, slug) => {
cy.factory()
.build("category", {
id: `${id}`,
name: "Just For Fun",
slug: `${slug}`,
icon: "smile"
})
.build("category", {
id: `${id}1`,
name: "Happiness & Values",
icon: "heart-o"
})
.build("category", {
id: `${id}2`,
name: "Health & Wellbeing",
icon: "medkit"
});
});
Cypress.Commands.add( Cypress.Commands.add(
'authenticateAs', 'authenticateAs',
async ({email, password}) => { async ({email, password}) => {

View File

@ -40,8 +40,8 @@ Cypress.Commands.add('factory', () => {
Cypress.Commands.add( Cypress.Commands.add(
'build', 'build',
{ prevSubject: true }, { prevSubject: true },
async (factory, node, properties, options) => { async (factory, name, atrributes, options) => {
await Factory.build(node, properties, options) await Factory.build(name, atrributes, options)
return factory return factory
} }
) )