Skip to content

Commit 404d71f

Browse files
committed
test: Add PDF service in E2E
1 parent 21a7e56 commit 404d71f

15 files changed

Lines changed: 19526 additions & 42064 deletions

.github/workflows/e2e.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ env:
2525
FRONTEND_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend
2626
API_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend/opencollective-api
2727
IMAGES_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend/opencollective-images
28+
PDF_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend/opencollective-pdf
2829
TERM: xterm
2930
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3031
STRIPE_WEBHOOK_KEY: ${{ secrets.STRIPE_WEBHOOK_KEY }}
@@ -137,6 +138,12 @@ jobs:
137138
repository: opencollective/opencollective-images
138139
path: opencollective-images
139140

141+
- name: Checkout (PDF)
142+
uses: actions/checkout@v3
143+
with:
144+
repository: opencollective/opencollective-pdf
145+
path: opencollective-pdf
146+
140147
# Prepare API
141148

142149
- name: Restore node_modules (api)
@@ -173,6 +180,24 @@ jobs:
173180
working-directory: opencollective-images
174181
run: npm run build
175182

183+
# Prepare PDF
184+
185+
- name: Restore node_modules (pdf)
186+
uses: actions/cache@v3
187+
id: pdf-node-modules
188+
with:
189+
path: opencollective-pdf/node_modules
190+
key: ${{ runner.os }}-pdf-node-modules-${{ hashFiles('opencollective-pdf/package-lock.json') }}
191+
192+
- name: Install dependencies (pdf)
193+
working-directory: opencollective-pdf
194+
if: steps.pdf-node-modules.outputs.cache-hit != 'true'
195+
run: npm ci --prefer-offline --no-audit
196+
197+
- name: Build (pdf)
198+
working-directory: opencollective-pdf
199+
run: npm run build
200+
176201
# Prepare Frontend
177202

178203
- name: Restore node_modules (frontend)
@@ -218,9 +243,13 @@ jobs:
218243
if: steps.next-build.outputs.cache-hit != 'true'
219244
run: npm run build
220245

246+
# Seed DB
247+
221248
- name: Setup DB
222249
run: ./scripts/setup_db.sh
223250

251+
# Run tests
252+
224253
- name: Run E2E with Cypress
225254
run: ./scripts/run_e2e_tests.sh
226255
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ coverage
1212
.nyc_output
1313
test/cypress/screenshots
1414
test/cypress/videos
15+
test/cypress/downloads
1516
dist
1617
stage
1718
*.swp

components/CreateGiftCardsSuccess.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,14 @@ export default class CreateGiftCardsSuccess extends React.Component {
105105
})}
106106
>
107107
{({ loading, downloadFile }) => (
108-
<StyledButton minWidth={270} m={2} buttonSize="large" loading={loading} onClick={downloadFile}>
108+
<StyledButton
109+
minWidth={270}
110+
m={2}
111+
buttonSize="large"
112+
loading={loading}
113+
onClick={downloadFile}
114+
data-cy="download-gift-cards-btn"
115+
>
109116
<Printer size="1em" />
110117
&nbsp;
111118
<FormattedMessage id="CreateGiftCardsSuccess.Download" defaultMessage="Download cards" />

components/expenses/ExpenseAttachedFiles.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const ExpenseAttachedFiles = ({ files, onRemove, showInvoice, collective, expens
3232
size={88}
3333
showFileName
3434
fileName={intl.formatMessage({ defaultMessage: 'Download expense' })}
35+
data-cy="download-expense-invoice-btn"
3536
/>
3637
)}
3738
</ExpenseInvoiceDownloadHelper>

components/transactions/TransactionDetails.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,18 @@ const TransactionDetails = ({ displayActions, transaction, onMutationSuccess })
272272
<StyledButton
273273
buttonSize="small"
274274
loading={loadingInvoice}
275-
onClick={downloadInvoiceWith({ transactionUuid: uuid, toCollectiveSlug: toAccount.slug })}
275+
onClick={downloadInvoiceWith({
276+
transactionUuid: uuid,
277+
toCollectiveSlug: toAccount.slug,
278+
createdAt: transaction.createdAt,
279+
})}
276280
minWidth={140}
277281
background="transparent"
278282
textTransform="capitalize"
279283
ml={2}
280284
mb={2}
281285
px="unset"
286+
data-cy="download-transaction-receipt-btn"
282287
>
283288
{expense && <FormattedMessage id="DownloadInvoice" defaultMessage="Download invoice" />}
284289
{order && <FormattedMessage id="DownloadReceipt" defaultMessage="Download receipt" />}

cypress.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// eslint-disable-next-line node/no-unpublished-require
22
const { defineConfig } = require('cypress');
3+
const { readPdf } = require('./test/cypress/scripts/read-pdf.ts');
4+
const { listDownloads } = require('./test/cypress/scripts/list-downloads.ts');
35

46
module.exports = defineConfig({
57
experimentalMemoryManagement: true,
@@ -21,6 +23,7 @@ module.exports = defineConfig({
2123
fixturesFolder: 'test/cypress/fixtures',
2224
screenshotsFolder: 'test/cypress/screenshots',
2325
videosFolder: 'test/cypress/videos',
26+
downloadsFolder: 'test/cypress/downloads',
2427
e2e: {
2528
setupNodeEvents(on, config) {
2629
// eslint-disable-next-line node/no-unpublished-require
@@ -38,6 +41,8 @@ module.exports = defineConfig({
3841
console.log(...message); // eslint-disable-line no-console
3942
return null;
4043
},
44+
readPdf,
45+
listDownloads,
4146
});
4247

4348
config.baseUrl = process.env.WEBSITE_URL || 'http://localhost:3000';

0 commit comments

Comments
 (0)