Skip to content

Commit

Permalink
Merge pull request #924 from ONEARMY/master
Browse files Browse the repository at this point in the history
v1.0.4
  • Loading branch information
BenGamma authored Mar 28, 2020
2 parents 65a8cb1 + 7547845 commit 1d0f37e
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 527 deletions.
5 changes: 1 addition & 4 deletions cypress/fixtures/seed/howtos.json
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,6 @@
],
"text": "Alright so before starting, here some basics to check out and prepare first.\n\nFor this technique you will need:\nMachines: Shredder (or already shredded plastic), Extrusion machine, Oven\nTools: Scissors / Knife, Pliers, Weighing scales and two containers, Silicone oil, Clamps, Spanner\nMaterials: Polystyrene and pigment\n\nIf you haven't extruded beams before, learn more in the How-to \"Make a mould for beams\".\n(https://community.preciousplastic.com/how-to/make-a-mould-for-extruding-beams)",
"_animationKey": "unique1",
"caption": "",
"title": "Get ready"
},
{
Expand All @@ -2020,7 +2019,6 @@
],
"text": "When melting plastic, bad fumes can be released. In order to work safer, make sure to use a breathing mask with ABEK filters to prevent inhaling possibly toxic fumes. Special attention on plastics like PS (polystyrene) and PVC. Also when handling with heated elements and plastic we recommend to wear working gloves.\n\nRecommended safety equipment: ABEK mask, gloves and glasses",
"_animationKey": "unique2",
"caption": "",
"title": "Stay safe"
},
{
Expand All @@ -2038,8 +2036,7 @@
}
],
"text": "Selecting the right material is crucial when it comes to aesthetics. What properties does the material have, what colour is it? \nAs PS stays transparent in the recycling process, it has the perfect quality to make a light. Collect your clean PS, which is typically found in old CD and cassette cases. Make sure to shred enough, the required amount will vary depending on the size of your mould.",
"_animationKey": "unique3",
"caption": ""
"_animationKey": "unique3"
},
{
"text": "Now we use pigment to add colour to the transparent polystyrene. You can find it online (search for 'pigment for polystyrene'), but do check out if you can find it in a local shop. Using pigment has the advantage that it keeps the translucency of your material. If you only have access to coloured PS plastic, you will probably not get the same effect (unless the plastic is also translucent), so this will need some testing.\n
Start by cutting one pellet of pigment into smaller pieces. The pigment we use (___) has a really strong affect so you only need a small amount to mix with.",
Expand Down
18 changes: 2 additions & 16 deletions cypress/integration/howto/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('[How To]', () => {
stepNumber: number,
title: string,
description: string,
caption: string,
images: string[],
) => {
const stepIndex = stepNumber - 1
Expand All @@ -42,9 +41,6 @@ describe('[How To]', () => {
cy.get('[data-cy=step-description]')
.clear()
.type(`Description for step ${stepNumber}`)
cy.get('[data-cy=step-caption]')
.clear()
.type('What a step caption')
cy.step('Uploading pics')
const hasExistingPics =
Cypress.$($step).find('[data-cy=delete-step-img]').length > 0
Expand Down Expand Up @@ -76,7 +72,6 @@ describe('[How To]', () => {
const expected = {
_createdBy: 'howto_creator',
_deleted: false,
caption: 'Intro caption goes here ...',
description: 'After creating, the how-to will be deleted',
difficulty_level: 'Medium',
time: '1-2 weeks',
Expand All @@ -95,7 +90,6 @@ describe('[How To]', () => {
steps: [
{
_animationKey: 'unique1',
caption: 'What a step caption',
images: [
{
contentType: 'image/jpeg',
Expand All @@ -115,7 +109,6 @@ describe('[How To]', () => {
},
{
_animationKey: 'unique2',
caption: 'What a step caption',
images: [],
text: 'Description for step 2',
title: 'Step 2 is easy',
Expand Down Expand Up @@ -144,14 +137,13 @@ describe('[How To]', () => {
selectDifficultLevel(expected.difficulty_level as Difficulty)

cy.get('[data-cy=intro-description]').type(expected.description)
cy.get('[data-cy=intro-caption]').type(expected.caption)
cy.step('Upload a cover for the intro')
cy.get('[data-cy=intro-cover]')
.find(':file')
.uploadFiles('images/howto-intro.jpg')

expected.steps.forEach((step, index) => {
fillStep(index + 1, step.title, step.text, step.caption, [
fillStep(index + 1, step.title, step.text, [
'images/howto-step-pic1.jpg',
'images/howto-step-pic2.jpg',
])
Expand Down Expand Up @@ -185,7 +177,6 @@ describe('[How To]', () => {
const expected = {
_createdBy: 'howto_editor',
_deleted: false,
caption: 'Caption edited!',
description: 'After editing, all changes are reverted',
difficulty_level: 'Hard',
files: [],
Expand All @@ -202,7 +193,6 @@ describe('[How To]', () => {
steps: [
{
_animationKey: 'unique1',
caption: 'What a step caption',
images: [
{
contentType: 'image/jpeg',
Expand All @@ -222,7 +212,6 @@ describe('[How To]', () => {
},
{
_animationKey: 'unique3',
caption: 'What a step caption',
images: [
{
contentType: 'image/jpeg',
Expand Down Expand Up @@ -277,9 +266,6 @@ describe('[How To]', () => {
cy.get('[data-cy=intro-description]')
.clear()
.type(expected.description)
cy.get('[data-cy=intro-caption]')
.clear()
.type(expected.caption)

cy.step('Update a new cover for the intro')

Expand All @@ -292,7 +278,7 @@ describe('[How To]', () => {
deleteStep(2)

expected.steps.forEach((step, index) => {
fillStep(index + 1, step.title, step.text, step.caption, [
fillStep(index + 1, step.title, step.text, [
'images/howto-step-pic1.jpg',
'images/howto-step-pic2.jpg',
])
Expand Down
5 changes: 1 addition & 4 deletions cypress/support/custom-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const eqHowto = (chaiObj, utils) => {
const {
_createdBy,
_deleted,
caption,
description,
difficulty_level,
slug,
Expand All @@ -29,7 +28,6 @@ const eqHowto = (chaiObj, utils) => {
expect(subject, 'Basic info').to.containSubset({
_createdBy,
_deleted,
caption,
description,
difficulty_level,
slug,
Expand All @@ -53,10 +51,9 @@ const eqHowto = (chaiObj, utils) => {
const eqHowtoStep = (chaiObj, utils) => {
function compare(this: any, expected: any, index: number) {
const subject: IHowtoStep = this._obj
const { _animationKey, caption, text, title } = expected
const { _animationKey, text, title } = expected
expect(subject, `Step ${index} with info`).to.containSubset({
_animationKey,
caption,
text,
title,
})
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Firestore } from './db/firebase'
*/

before(() => {
indexedDB.deleteDatabase('OneArmyCache')
cy.clearLocalStorage('CLear local storage and indexDB')
cy.wrap('Initialising Database').then({ timeout: 60000 }, doc => {
// large initial timeout in case server slow to respond
return new Cypress.Promise(async resolve => {
Expand Down
11 changes: 7 additions & 4 deletions functions/src/Integrations/firebase-discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ export const notifyPinAccepted = functions.firestore
.document('v3_mappins/{pinId}')
.onWrite(async (change, context) => {
const info = change.after.exists ? change.after.data() : null
if (info === null || info.moderation !== 'accepted') {
const prevInfo = change.before.exists ? change.before.data() : null
const beenAccepted =
prevInfo !== null ? prevInfo.moderation === 'accepted' : null
if (info === null || info.moderation !== 'accepted' || beenAccepted) {
return
}
const { _id, type } = info
await axios
.post(DISCORD_WEBHOOK_URL, {
content: `📍 *New ${type}* pin from ${_id}. \n Location here ${SITE_URL}/map/#${_id}`,
content: `📍 *New ${type}* pin from ${_id}. \n Location here <${SITE_URL}/map/#${_id}>`,
})
.then(handleResponse, handleErr)
.catch(handleErr)
Expand All @@ -34,7 +37,7 @@ export const notifyHowToAccepted = functions.firestore
await axios
.post(DISCORD_WEBHOOK_URL, {
content: `📓 Yeah! New How To **${title}** by *${_createdBy}*
check it out: ${SITE_URL}/how-to/${slug}`,
check it out: <${SITE_URL}/how-to/${slug}>`,
})
.then(handleResponse, handleErr)
.catch(handleErr)
Expand All @@ -53,7 +56,7 @@ export const notifyEventAccepted = functions.firestore
await axios
.post(DISCORD_WEBHOOK_URL, {
content: `📅 Jeej new event in **${location}** by *${user}* posted here:
${url}`,
<${url}>`,
})
.then(handleResponse, handleErr)
.catch(handleErr)
Expand Down
4 changes: 3 additions & 1 deletion functions/src/Integrations/firebase-slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const notifyNewPin = functions.firestore
.document('v3_mappins/{pinId}')
.onWrite((change, context) => {
const info = change.after.exists ? change.after.data() : null
if (info === null || info.moderation !== 'awaiting-moderation') {
const prevInfo = change.before.exists ? change.before.data() : null
const prevModeration = (prevInfo !== null) ? prevInfo.moderation : null;
if (info === null || info.moderation !== 'awaiting-moderation' || prevModeration === 'awaiting-moderation') {
return
}

Expand Down
3 changes: 0 additions & 3 deletions src/models/howto.models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ export interface IHowtoStep extends IHowToStepFormInput {
images: Array<IUploadedFileMeta | null>
title: string
text: string
caption?: string
_animationKey?: string
}

export interface IHowToStepFormInput {
images: Array<IUploadedFileMeta | IConvertedFileMeta | null>
title: string
text: string
caption?: string
_animationKey?: string
}

Expand All @@ -46,5 +44,4 @@ export interface IHowtoFormInput extends IModerable {
slug: string
// note, tags will remain optional as if populated {} will be stripped by db (firestore)
tags?: ISelectedTags
caption?: string
}
8 changes: 0 additions & 8 deletions src/pages/Howto/Content/Common/Howto.form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,6 @@ export class HowtoForm extends React.Component<IProps, IState> {
This image should be landscape. We advise
1280x960px
</Text>
<Flex mt={2}>
<Field
name="caption"
data-cy={'intro-caption'}
component={InputField}
placeholder="Insert Caption"
/>
</Flex>
</Flex>
</Flex>
</Flex>
Expand Down
Loading

0 comments on commit 1d0f37e

Please sign in to comment.