Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5ec4be3
feat: supports contributors on research item #2006
thisislawatts Nov 25, 2022
d5f0dba
fix: use ternary rather than conditional
thisislawatts Feb 19, 2023
5d66df0
test: switch to query via testId
thisislawatts Feb 19, 2023
0f53627
chore: refactor to move user notifications into store
thisislawatts Mar 7, 2023
a68d745
feat: notify contributors #2143
thisislawatts Mar 7, 2023
9788c26
fix: move initialization boolean inside component
AlfonsoGhislieri Mar 8, 2023
c2aaf60
fix: moved boolean initialization inside reasearch description
AlfonsoGhislieri Mar 8, 2023
35fd3dd
chore: removed console log
AlfonsoGhislieri Mar 8, 2023
5438eab
chore: removed unecessary spacing
AlfonsoGhislieri Mar 8, 2023
e8f1b68
chore: added cypress end to end testing for views
AlfonsoGhislieri Mar 19, 2023
80eeb7d
chore: enforce arrow style functions in SPA
thisislawatts Mar 19, 2023
52454b9
chore(style): auto format to use arrow functions
thisislawatts Mar 19, 2023
fca42bc
chore: throw error in lint as warnings will fail build
thisislawatts Mar 19, 2023
107946a
fix: handle removing first item from Contact and links
thisislawatts Feb 26, 2023
031559b
test: add e2e coverage for editing contact and links item
thisislawatts Feb 26, 2023
cbb12d8
chore: add linting to catch alerts
thisislawatts Mar 12, 2023
8a22e93
fix: remove delete button from ProfileLinkField when it is the only item
thisislawatts Mar 13, 2023
162bebe
fix: remove disabled attr
thisislawatts Mar 15, 2023
de2334e
chore: added tests for research viewcounter
AlfonsoGhislieri Mar 20, 2023
d1d8ba4
chore: removed unused variable
AlfonsoGhislieri Mar 21, 2023
5ad0360
chore: prevent console log
thisislawatts Mar 19, 2023
12fdec8
Merge pull request #2146 from AlfonsoGhislieri/fix-2115-views-not-ini…
davehakkens Mar 21, 2023
49bd749
Merge pull request #2128 from ONEARMY/fix/removing-first-item-of-array
davehakkens Mar 21, 2023
39abc72
chore: introduce logger instead of using console.log
thisislawatts Mar 19, 2023
3a59076
Merge branch 'master' into feat/support-contributors-on-research-item
chrismclarke Mar 22, 2023
bd5493d
Merge branch 'master' of https://github.com/ONEARMY/community-platfor…
chrismclarke Mar 22, 2023
5acb276
chore: lint fix
chrismclarke Mar 22, 2023
9d735d2
Merge pull request #2007 from ONEARMY/feat/support-contributors-on-re…
chrismclarke Mar 22, 2023
8420278
Merge branch 'master' into chore/remove-console-log
chrismclarke Mar 22, 2023
84c10e8
Merge pull request #2148 from ONEARMY/chore/remove-console-log
chrismclarke Mar 22, 2023
210f9da
chore: address filename formatting
thisislawatts Mar 21, 2023
d9c2a18
chore: rename AbstractDatabaseClient
thisislawatts Mar 21, 2023
cf8e8f0
chore: rename Admin components
thisislawatts Mar 21, 2023
219c19f
chore: ignore types
thisislawatts Mar 21, 2023
3bbf3b0
chore: ignore service-worker
thisislawatts Mar 21, 2023
c49bf0e
chore: explicitly name Precious Plastic user model
thisislawatts Mar 21, 2023
af74776
chore: formatting
thisislawatts Mar 21, 2023
76f1fdd
chore: ignore docusauraus github
thisislawatts Mar 22, 2023
3e1f44d
Merge pull request #2152 from ONEARMY/chore/address-filename-formatting
chrismclarke Mar 22, 2023
5d98bf4
Merge branch 'master' of https://github.com/ONEARMY/community-platfor…
chrismclarke Mar 22, 2023
315de33
Merge pull request #2149 from ONEARMY/chore/enforce-arrow-style-funct…
chrismclarke Mar 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}
},
"rules": {
"no-alert": "error",
"sort-class-members/sort-class-members": [
"error",
{
Expand All @@ -41,7 +42,7 @@
"import/no-named-as-default": "off",
"max-classes-per-file": "error",
"no-useless-escape": "off",
"react/display-name": "warn",
"react/display-name": "error",
"react/jsx-no-target-blank": "warn",
// https://github.com/standard/eslint-config-standard-with-typescript/issues/248
"react/no-deprecated": "warn",
Expand Down Expand Up @@ -84,29 +85,7 @@
"camelCase": true,
"pascalCase": true
},
// TODO - most can be renamed although holding off until after #1501 and #1533 merged
"ignore": [
"docusaurus.config.gh-pages.js",
"install-clean.ts",
"SWUpdateNotification.tsx",
"react-app-env.d.ts",
"service-worker.ts",
"AbstractDBClient.ts",
"react-firebase-file-uploader.d.ts",
"reset-staging-site.ts",
"post-cra-build.ts",
"user_pp.mock.tsx",
"user_pp.models.tsx",
"admin-subheader.tsx",
"admin-approvals.tsx",
"admin-howtos.tsx",
"admin-mappins.tsx",
"admin-research-detail.tsx",
"admin-research.tsx",
"admin-tags.tsx",
"admin-user-detail.tsx",
"admin-users.tsx"
]
"ignore": ["react-app-env.d.ts", "service-worker.ts"]
}
],
"@typescript-eslint/no-empty-function": "off",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reset-staging-site.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Action to allow trigger of the firebase project migration script, used to reset the staging site
# For more info see the script file (/scripts/maintenance/reset-staging-site)
# For more info see the script file (/scripts/maintenance/resetStagingSite.ts)
name: Reset Staging Site
on:
# Run weekly on a Sunday at 02:00
Expand Down Expand Up @@ -42,4 +42,4 @@ jobs:
env:
ONEARMY_MIGRATOR_SERVICE_ACCOUNT_JSON: ${{secrets.ONEARMY_MIGRATOR_SERVICE_ACCOUNT_JSON}}
- name: Run db migration script
run: ts-node --project scripts/tsconfig.json scripts/maintenance/reset-staging-site.ts
run: ts-node --project scripts/tsconfig.json scripts/maintenance/resetStagingSite.ts.ts
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-prefer-arrow-functions": "^3.1.4",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-sort-class-members": "^1.15.2",
"eslint-plugin-unicorn": "^36.0.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/components/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
{
"files": ["**/*.stories.tsx"],
"rules": {
"import/no-default-export": "off"
"import/no-default-export": "off",
"no-alert": "off"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export const ArticleCallToAction = (props: Props) => {
sx={{ ml: 1 }}
/>
</Text>
{props.contributors && (
{props.contributors && props?.contributors.length ? (
<Text
data-testid="ArticleCallToAction: contributors"
variant="quiet"
sx={{ display: 'block', mt: 2, textAlign: 'center' }}
sx={{ display: 'block', mt: 2, textAlign: 'center', fontSize: 2 }}
>
With contributions from:{' '}
{props.contributors.map((contributor, key) => (
Expand All @@ -39,14 +40,12 @@ export const ArticleCallToAction = (props: Props) => {
user={contributor}
isVerified={contributor.isVerified}
sx={{
fontSize: '16px',
color: 'grey',
mr: 1,
}}
/>
))}
</Text>
)}
) : null}
<Heading sx={{ my: 4 }}>Like what you see? 👇</Heading>
<Flex
sx={{
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/ViewsCounter/ViewsCounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface IProps {

export const ViewsCounter = (props: IProps) => (
<Flex
data-cy={'ViewsCounter'}
px={2}
py={1}
mb={1}
Expand Down
23 changes: 23 additions & 0 deletions packages/cypress/src/integration/howto/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ describe('[How To]', () => {

cy.get(`[data-cy="comments-form"]`).should('not.exist')
})

it('[Views only visible for beta-testers]', () => {
cy.visit(specificHowtoUrl)
cy.step(`ViewsCounter should not be visible`)
cy.get('[data-cy="ViewsCounter"]').should('not.exist')
})
})

describe('[By Authenticated]', () => {
Expand Down Expand Up @@ -200,6 +206,23 @@ describe('[How To]', () => {
})
})

describe('[By Beta-Tester]', () => {
it('[Views show on multiple howtos]', () => {
cy.login('demo_beta_tester@example.com', 'demo_beta_tester')

cy.step('Views show on first howto')
cy.visit(specificHowtoUrl)
cy.get('[data-cy="ViewsCounter"]').should('exist')

cy.step('Go back')
cy.get('[data-cy="go-back"]:eq(0)').as('topBackButton').click()

cy.step('Views show on second howto')
cy.visit('/how-to/make-glass-like-beams')
cy.get('[data-cy="ViewsCounter"]').should('exist')
})
})

it('[By Owner]', () => {
cy.step('Edit button is available to the owner')
cy.visit(specificHowtoUrl)
Expand Down
67 changes: 50 additions & 17 deletions packages/cypress/src/integration/research/read.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
describe('[Research]', () => {
const SKIP_TIMEOUT = { timeout: 300 }
const totalResearchCount = 1
const totalResearchCount = 2

describe('[List research articles]', () => {
const researchArticleUrl = '/research/qwerty'
beforeEach(() => {
cy.visit('/research')
})
Expand All @@ -14,24 +13,58 @@ describe('[Research]', () => {
cy.get('[data-cy="ResearchListItem"]')
.its('length')
.should('be.eq', totalResearchCount)
})
})

describe('[Read a research article]', () => {
const researchArticleUrl = '/research/qwerty'
beforeEach(() => {
cy.visit('/research')
})

cy.step('Research cards has basic info')
cy.get(
`[data-cy="ResearchListItem"] a[href="${researchArticleUrl}"]`,
).within(() => {
cy.contains('qwerty').should('be.exist')
cy.contains('event_reader').should('be.exist')
cy.get('[data-cy="ItemUpdateText"]').contains('1').should('be.exist')
describe('[By Everyone]', () => {
it('[See all info]', () => {
cy.step('Research cards has basic info')
cy.get(
`[data-cy="ResearchListItem"] a[href="${researchArticleUrl}"]`,
).within(() => {
cy.contains('qwerty').should('be.exist')
cy.contains('event_reader').should('be.exist')
cy.get('[data-cy="ItemUpdateText"]').contains('1').should('be.exist')
})

cy.step(
`Open Research details when click on a Research ${researchArticleUrl}`,
)
cy.get(
`[data-cy="ResearchListItem"] a[href="${researchArticleUrl}"]`,
SKIP_TIMEOUT,
).click()
cy.url().should('include', researchArticleUrl)
})

it('[Views only visible for beta-testers]', () => {
cy.step(`ViewsCounter should not be visible`)
cy.visit(researchArticleUrl)
cy.get('[data-cy="ViewsCounter"]').should('not.exist')
})
})

cy.step(
`Open Research details when click on a Research ${researchArticleUrl}`,
)
cy.get(
`[data-cy="ResearchListItem"] a[href="${researchArticleUrl}"]`,
SKIP_TIMEOUT,
).click()
cy.url().should('include', researchArticleUrl)
describe('[Beta-tester]', () => {
it('[Views show on multiple research articles]', () => {
cy.login('demo_beta_tester@example.com', 'demo_beta_tester')

cy.step('Views show on first research article')
cy.visit(researchArticleUrl)
cy.get('[data-cy="ViewsCounter"]').should('exist')

cy.step('Go back')
cy.get('[data-cy="go-back"]:eq(0)').as('topBackButton').click()

cy.step('Views show on second research article')
cy.visit('/research/A%20test%20research')
cy.get('[data-cy="ViewsCounter"]').should('exist')
})
})
})
})
46 changes: 45 additions & 1 deletion packages/cypress/src/integration/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('[Settings]', () => {
.click()
}

const addContactLink = (link: ILink) => {
const addContactLink = (link: Omit<ILink, 'key'>) => {
if (link.index > 0) {
// click the button to add another set of input fields
cy.get('[data-cy=add-link]').click()
Expand Down Expand Up @@ -359,6 +359,50 @@ describe('[Settings]', () => {
.should('eqSettings', expected)
})
})

it('[Edit Contact and Links]', () => {
cy.login('settings_member_new@test.com', 'test1234')
cy.step('Go to User Settings')
cy.clickMenuItem(UserMenuItem.Settings)

addContactLink({
index: 1,
label: 'social',
url: 'https://social.network',
})

// Remove first item
cy.get('[data-cy="delete-link-0"]').last().trigger('click')

cy.get('[data-cy="Link.field: Modal"]').should('be.visible')

cy.get('[data-cy="Link.field: Delete"]').trigger('click')

cy.get('[data-cy=save]').click()
cy.get('[data-cy=save]').should('not.be.disabled')

// Assert
cy.queryDocuments(
DbCollectionName.users,
'userName',
'==',
expected.userName,
).then((docs) => {
cy.log('queryDocs', docs)
expect(docs.length).to.equal(1)
cy.wrap(null)
.then(() => docs[0])
.should('eqSettings', {
...expected,
links: [
{
label: 'social',
url: 'https://social.network',
},
],
})
})
})
})

describe('[Focus Machine Builder]', () => {
Expand Down
14 changes: 14 additions & 0 deletions packages/documentation/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"rules": {
"unicorn/filename-case": [
"error",
{
"cases": {
"camelCase": true,
"pascalCase": true
},
"ignore": ["docusaurus.config.gh-pages.js"]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Currently this can be done in a semi-automated way using a script in the scripts

```
cd scripts
ts-node ./maintenance/reset-staging-site.ts
ts-node ./maintenance/resetStagingSite.ts
```

:::note
This script requires access to a service worker with specific permissions for source and target projects, and intermediate storage buckets.
:::

For more information about the script and known limitations see the source code at [scripts/maintenance/reset-staging-site.ts](https://github.com/ONEARMY/community-platform/blob/master/scripts/maintenance/reset-staging-site.ts).
For more information about the script and known limitations see the source code at [scripts/maintenance/resetStagingSite.ts](https://github.com/ONEARMY/community-platform/blob/master/scripts/maintenance/resetStagingSite.ts).

The script is currently run weekly via the github action, see the source code at [.github/workflows/reset-staging-site.yml](https://github.com/ONEARMY/community-platform/blob/master/.github/workflows/reset-staging-site.yml))
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const COLLECTION_IDS = Object.values(DB_ENDPOINTS)
*
* Example execution
* ```
ts-node --project scripts/tsconfig.json scripts/maintenance/reset-staging-site.ts
ts-node --project scripts/tsconfig.json scripts/maintenance/resetStagingSite.ts.ts
```
Also available as a github action in the /.github/reset-staging-site.yml
*/
Expand Down
4 changes: 2 additions & 2 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "oa-scripts",
"version": "1.0.0",
"scripts": {
"install:clean": "ts-node ./install-clean.ts",
"post-cra-build": "ts-node ./post-cra-build.ts"
"install:clean": "ts-node ./installClean.ts",
"post-cra-build": "ts-node ./postCraBuild.ts"
},
"dependencies": {
"cheerio": "^1.0.0-rc.10",
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions shared/mocks/data/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,19 @@ export const research = {
},
],
},
'0up6oJCTT3M9bDYx34Et': {
_created: '2023-02-27T22:08:25.999Z',
_createdBy: 'test user',
_deleted: false,
_id: '0up6oJCTT3M9bDYx34Et',
_modified: '2023-03-01T19:12:11.271Z',
creatorCountry: 'it',
description: 'A test!',
moderation: 'accepted',
slug: 'A test research',
tags: {
h1wCs0o9j60lkw3AYPB1: true,
},
title: 'A test research',
},
}
15 changes: 15 additions & 0 deletions src/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rules": {
"no-console": "error",
"prefer-arrow-functions/prefer-arrow-functions": [
"error",
{
"classPropertiesAllowed": false,
"disallowPrototype": false,
"returnStyle": "unchanged",
"singleReturnOnly": false
}
]
},
"plugins": ["prefer-arrow-functions"]
}
Loading