Skip to content

Commit

Permalink
test: Add PDF service in E2E
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed May 26, 2023
1 parent 21a7e56 commit 029443a
Show file tree
Hide file tree
Showing 13 changed files with 19,237 additions and 41,965 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ env:
FRONTEND_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend
API_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend/opencollective-api
IMAGES_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend/opencollective-images
PDF_FOLDER: /home/runner/work/opencollective-frontend/opencollective-frontend/opencollective-pdf
TERM: xterm
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
STRIPE_WEBHOOK_KEY: ${{ secrets.STRIPE_WEBHOOK_KEY }}
Expand Down Expand Up @@ -137,6 +138,12 @@ jobs:
repository: opencollective/opencollective-images
path: opencollective-images

- name: Checkout (PDF)
uses: actions/checkout@v3
with:
repository: opencollective/opencollective-pdf
path: opencollective-pdf

# Prepare API

- name: Restore node_modules (api)
Expand Down Expand Up @@ -173,6 +180,24 @@ jobs:
working-directory: opencollective-images
run: npm run build

# Prepare PDF

- name: Restore node_modules (pdf)
uses: actions/cache@v3
id: pdf-node-modules
with:
path: opencollective-pdf/node_modules
key: ${{ runner.os }}-pdf-node-modules-${{ hashFiles('opencollective-pdf/package-lock.json') }}

- name: Install dependencies (pdf)
working-directory: opencollective-pdf
if: steps.pdf-node-modules.outputs.cache-hit != 'true'
run: npm ci --prefer-offline --no-audit

- name: Build (pdf)
working-directory: opencollective-pdf
run: npm run build

# Prepare Frontend

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

# Seed DB

- name: Setup DB
run: ./scripts/setup_db.sh

# Run tests

- name: Run E2E with Cypress
run: ./scripts/run_e2e_tests.sh
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ coverage
.nyc_output
test/cypress/screenshots
test/cypress/videos
test/cypress/downloads
dist
stage
*.swp
Expand Down
9 changes: 8 additions & 1 deletion components/CreateGiftCardsSuccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ export default class CreateGiftCardsSuccess extends React.Component {
})}
>
{({ loading, downloadFile }) => (
<StyledButton minWidth={270} m={2} buttonSize="large" loading={loading} onClick={downloadFile}>
<StyledButton
minWidth={270}
m={2}
buttonSize="large"
loading={loading}
onClick={downloadFile}
data-cy="download-gift-cards-btn"
>
<Printer size="1em" />
&nbsp;
<FormattedMessage id="CreateGiftCardsSuccess.Download" defaultMessage="Download cards" />
Expand Down
1 change: 1 addition & 0 deletions components/expenses/ExpenseAttachedFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const ExpenseAttachedFiles = ({ files, onRemove, showInvoice, collective, expens
size={88}
showFileName
fileName={intl.formatMessage({ defaultMessage: 'Download expense' })}
data-cy="download-expense-invoice-btn"
/>
)}
</ExpenseInvoiceDownloadHelper>
Expand Down
5 changes: 5 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// eslint-disable-next-line node/no-unpublished-require
const { defineConfig } = require('cypress');
const { readPdf } = require('./test/cypress/scripts/read-pdf.ts');
const { listDownloads } = require('./test/cypress/scripts/list-downloads.ts');

module.exports = defineConfig({
experimentalMemoryManagement: true,
Expand All @@ -21,6 +23,7 @@ module.exports = defineConfig({
fixturesFolder: 'test/cypress/fixtures',
screenshotsFolder: 'test/cypress/screenshots',
videosFolder: 'test/cypress/videos',
downloadsFolder: 'test/cypress/downloads',
e2e: {
setupNodeEvents(on, config) {
// eslint-disable-next-line node/no-unpublished-require
Expand All @@ -38,6 +41,8 @@ module.exports = defineConfig({
console.log(...message); // eslint-disable-line no-console
return null;
},
readPdf,
listDownloads,
});

config.baseUrl = process.env.WEBSITE_URL || 'http://localhost:3000';
Expand Down
Loading

0 comments on commit 029443a

Please sign in to comment.