Skip to content

Commit 47c8eaa

Browse files
author
Bruno Oliveira
committed
chore: add integration tests
// TODO
1 parent 24ca467 commit 47c8eaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4048
-255
lines changed

.eslintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
packages/*/docs
22
node_modules
33
dist
4-
**/__tests__/*.node.test.ts
4+
**/__tests__/*.node.test.ts
5+
playwright
6+
coverage

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ module.exports = {
123123
'react-hooks/rules-of-hooks': 'error',
124124
'react-hooks/exhaustive-deps': 'warn',
125125
'tsdoc/syntax': 'warn',
126+
'@typescript-eslint/no-explicit-any': 'warn',
126127
},
127128
overrides: [
128129
// Disable all tsdoc checking in test files
129130
{
130-
files: ['*.test.*[t|j]s*', '*.fixtures.*[t|j]s*'],
131+
files: ['*.test.*[t|j]s*', '*.fixtures.*[t|j]s*', 'tests/e2e/**/*.*'],
131132
rules: {
132133
'tsdoc/syntax': 'off',
133134
// We use const xxx = () => {} many times in tests.

.github/workflows/CI.yml

Lines changed: 102 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CI
22

33
# Controls when the action will run. Triggers the workflow on push or pull request
4-
# events but only for the main and next branches
4+
# events but only for the main, next and v1 branches
55
on:
66
push:
77
branches:
@@ -17,33 +17,123 @@ on:
1717
- '**/docs/**'
1818
- '**.md'
1919

20-
# Setup concurrency to the ref (branch / tag) that triggered the workflow
2120
concurrency: ci-${{ github.ref }}
2221

23-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2422
jobs:
25-
# This workflow contains a single job called "CI"
26-
CI:
27-
# The type of runner that the job will run on
23+
# This job will run the minimal checks: linting, unit tests and type checking.
24+
BasicChecks:
25+
name: Basic Checks
26+
2827
runs-on: ubuntu-latest
2928
# Do not run if the pull request is a draft
3029
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
3130

32-
# Steps represent a sequence of tasks that will be executed as part of the job
3331
steps:
34-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
- uses: actions/checkout@v3
33+
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: '16'
37+
registry-url: 'https://registry.npmjs.org'
38+
scope: '@farfetch'
39+
cache: 'yarn'
40+
always-auth: true
41+
42+
- name: Install dependencies
43+
run: yarn install --ignore-engines --frozen-lockfile
44+
45+
- name: Lint
46+
run: yarn lint
47+
48+
- name: Unit Tests
49+
run: yarn test --ci
50+
51+
- name: Type checking
52+
run: yarn ci:types
53+
54+
# This job will run integration tests, possibly only the critical ones if the branch is master or next
55+
IntegrationTests:
56+
name: Integration Tests
57+
58+
runs-on: ubuntu-latest
59+
60+
env:
61+
PROXY_TARGET: ${{ secrets.E2E_TESTS_PROXY_TARGET }}
62+
TEST_ACCOUNT_USERNAME: ${{ secrets.E2E_TESTS_ACCOUNT_USERNAME }}
63+
TEST_ACCOUNT_PASSWORD: ${{ secrets.E2E_TESTS_ACCOUNT_PASSWORD }}
64+
65+
# Do not run if the pull request is a draft
66+
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
67+
68+
steps:
69+
- uses: actions/checkout@v3
70+
71+
- uses: actions/setup-node@v4
72+
with:
73+
node-version: '16'
74+
registry-url: 'https://registry.npmjs.org'
75+
scope: '@farfetch'
76+
cache: 'yarn'
77+
always-auth: true
78+
79+
- name: Install dependencies
80+
run: yarn install --ignore-engines --frozen-lockfile
81+
82+
- name: Install Playwright Browsers
83+
run: npx playwright install --with-deps
84+
85+
- name: Update version and build packages
86+
run: yarn ci:release --dry-run && yarn build && yarn build:copy-package-json
87+
88+
- name: Build test application
89+
run: yarn test:e2e:build
90+
91+
- name: Setup host alias
92+
run: |
93+
sudo echo "127.0.0.1 development.blackandwhite-ff.com" | sudo tee -a /etc/hosts
94+
95+
- name: Start server
96+
run: yarn test:e2e:server &
97+
98+
- name: Sleep to wait for server to start
99+
run: sleep 5
100+
101+
- name: Run critical tests
102+
run: yarn test:e2e:run:critical
103+
104+
- name: Run non critical tests
105+
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/next' }}
106+
run: yarn test:e2e:run:non-critical
107+
108+
- uses: actions/upload-artifact@v3
109+
if: always()
110+
with:
111+
name: playwright-report
112+
path: tests/e2e/report
113+
retention-days: 30
114+
115+
# This will make a release after the dependant checks are finished and
116+
# it is in a branch that allows publishing (master and next).
117+
Release:
118+
runs-on: ubuntu-latest
119+
120+
# Do not run if the pull request is a draft
121+
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
122+
123+
needs: [BasicChecks, IntegrationTests]
124+
steps:
35125
# Use fetch-depth: 0 so that all tags and branches are fetched
36126
# Use persist-credentials: false so that the make release step uses another personal access
37127
# token which has admin access and can push the version commit without the restriction
38128
# of creating a pull-request.
39-
- uses: actions/checkout@v2
129+
- uses: actions/checkout@v3
40130
with:
41131
fetch-depth: 0
42132
persist-credentials: false
43133

44-
- uses: actions/setup-node@v2
134+
- uses: actions/setup-node@v4
45135
with:
46-
node-version: '14'
136+
node-version: '16'
47137
registry-url: 'https://registry.npmjs.org'
48138
scope: '@farfetch'
49139
cache: 'yarn'
@@ -77,15 +167,6 @@ jobs:
77167
- name: Install dependencies
78168
run: yarn install --ignore-engines --frozen-lockfile
79169

80-
- name: Lint
81-
run: yarn lint
82-
83-
- name: Test
84-
run: yarn test --ci
85-
86-
- name: Type checking
87-
run: yarn ci:types
88-
89170
# Only make a release if it is a run of the 'main' or 'next' branches
90171
# or a pull request that contains a 'chore: make release' message
91172
- name: Make release
@@ -102,4 +183,4 @@ jobs:
102183
GIT_AUTHOR_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
103184
GIT_COMMITTER_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }}
104185
GIT_COMMITTER_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
105-
run: yarn ci:release
186+
run: yarn ci:release

.gitignore

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ junit.xml
1010
coverage/
1111
node_modules/
1212

13-
**/package-lock.json
14-
**/dist
15-
**/docs
16-
**/.cache
17-
!/docs/contributing
18-
19-
**/types/**/build
13+
package-lock.json
14+
dist/
15+
.cache/
2016

2117
.eslintcache
2218

2319
*.tsbuildinfo
20+
21+
build/
22+
playwright/
23+
report/

cert.pem

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIEnTCCAwWgAwIBAgIRANsUm+o6x+zXg4Y2aq0D1bgwDQYJKoZIhvcNAQELBQAw
3+
ga8xHjAcBgNVBAoTFW1rY2VydCBkZXZlbG9wbWVudCBDQTFCMEAGA1UECww5YnJ1
4+
bm8uYS5vbGl2ZWlyYUBGRlBUTU1QM1dDNzIwIChCcnVubyBBbGV4YW5kcmUgT2xp
5+
dmVpcmEpMUkwRwYDVQQDDEBta2NlcnQgYnJ1bm8uYS5vbGl2ZWlyYUBGRlBUTU1Q
6+
M1dDNzIwIChCcnVubyBBbGV4YW5kcmUgT2xpdmVpcmEpMB4XDTI0MDEwODA5NTcy
7+
OFoXDTI2MDQwODA4NTcyOFowbTEnMCUGA1UEChMebWtjZXJ0IGRldmVsb3BtZW50
8+
IGNlcnRpZmljYXRlMUIwQAYDVQQLDDlicnVuby5hLm9saXZlaXJhQEZGUFRNTVAz
9+
V0M3MjAgKEJydW5vIEFsZXhhbmRyZSBPbGl2ZWlyYSkwggEiMA0GCSqGSIb3DQEB
10+
AQUAA4IBDwAwggEKAoIBAQDWR/Yv5TyrHS4IQJzOSu21HpVYzZ+eClF5VOeyAwm+
11+
MVvKjgApoG9AOMqJAMF9qlWsAOGqRPiXRXE4Q2txXt125f+cwLK+K72QrGzgnNuN
12+
UYOU0nU42VWvrEf/1r7HT+qDgU/G0gS5ehFhSudGlzkWMEGnCeSjVci3QhZ6cqP3
13+
18ezPYiWGVm/L8QUM878Gh8hNGV05W/djp8FJuMT69AL7MZj5FHIy9+aDWeXl7M8
14+
M2kwNCwKqXwOeXfA6gsfz6YkMg/d8599GB9+yJNQAC9EbfqW76TezD7AJUWJ8qdw
15+
liXBMVx1qNTvs5F5I592b37e1NWwhbU/Pd4agoGuBnXfAgMBAAGjdTBzMA4GA1Ud
16+
DwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATAfBgNVHSMEGDAWgBSQcdAM
17+
4NXwIpdwJIxbn8hUuzyy0jArBgNVHREEJDAigiBkZXZlbG9wbWVudC5ibGFja2Fu
18+
ZHdoaXRlLWZmLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEANxSSLJaSlVeljh2JXiai
19+
qGxTBVLwBfcnkkSI1tF3IIFw0Lbjju6pDpi6RjQL1Q6TxjCS0a2LmZpnd6ofGH/X
20+
eCUo0cz04fygKSnhPJ/qG7qgh+rZuA9Nv7bkw0gFBiqGFAOm9e2P7p1RCU77tFPh
21+
mBNGRheiShtxdu47B9F39WwmOxNqPataM6XfGGhkJCI7qxF8VLngaLfyyi8zVd/u
22+
gAqw/6suXKY86kbcqOFJxQ+Z3IKMwvaetU83tRhYzn8bbO7ZyT0lEJ8OBStXY8sP
23+
Lxqa9c+BPBTd3TvjVyMo4OWGGkKi6kEswAKUnc8ebYDmj2YfQtesyD47q3uZ1fdU
24+
LaZETXaoqnuncKEPwez+jNDcU/qutrsXLxqcpzcZuMG5sKKb+qADkrqjwdA9QBG1
25+
rWadjJySkkRdiB+hvRxrT65aJ/QnHiesdGv2fXxW2Bk0PhW1MEUx5FBdxAx6q51o
26+
ZrYr3hbldC0IF0EsekX4H2e+Ul26p/1yBnp096rYd1Ia
27+
-----END CERTIFICATE-----

jest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ module.exports = {
2626
snapshotSerializers: ['./tests/axiosErrorSerializer.mts'],
2727
// The test environment that will be used for testing
2828
testEnvironment: 'jsdom',
29+
// Patterns to ignore
30+
testPathIgnorePatterns: ['/node_modules/', 'dist', 'e2e'],
2931
// The regexp pattern or array of patterns that Jest uses to detect test files
30-
testRegex: ['.+\\.test.[jt]s(x?)$', '!dist'],
32+
testRegex: ['.+\\.test.[jt]s(x?)$'],
3133
// Indicates whether the coverage information should be collected while executing the test
3234
collectCoverage: true,
3335
// An array of glob patterns indicating a set of files for which coverage information should be collected
@@ -48,6 +50,7 @@ module.exports = {
4850
'packages/react/src/analytics/integrations/Forter/loadForterScriptForSiteId.ts',
4951
'packages/redux/src/entities/schemas',
5052
'__fixtures__',
53+
'e2e',
5154
],
5255
// A map from regular expressions to module names that allow to stub out resources with a single module
5356
moduleNameMapper: {

key.pem

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDWR/Yv5TyrHS4I
3+
QJzOSu21HpVYzZ+eClF5VOeyAwm+MVvKjgApoG9AOMqJAMF9qlWsAOGqRPiXRXE4
4+
Q2txXt125f+cwLK+K72QrGzgnNuNUYOU0nU42VWvrEf/1r7HT+qDgU/G0gS5ehFh
5+
SudGlzkWMEGnCeSjVci3QhZ6cqP318ezPYiWGVm/L8QUM878Gh8hNGV05W/djp8F
6+
JuMT69AL7MZj5FHIy9+aDWeXl7M8M2kwNCwKqXwOeXfA6gsfz6YkMg/d8599GB9+
7+
yJNQAC9EbfqW76TezD7AJUWJ8qdwliXBMVx1qNTvs5F5I592b37e1NWwhbU/Pd4a
8+
goGuBnXfAgMBAAECggEBAL3vfXXI4TTfoYzpENT+r6Nqn4DeisyAYuWEb/dnH/y5
9+
LZ7mrZg4QESR0l0MEXZ9RIE5Ks5NY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NCrzTlN2gu/f4+OurFytkVmmAfgFYGZCkd0mSuu8rh
26+
8KT0A+VkDL/xUyAJ+0zwhddtf3vTdRKtbcMXXUfjlTrCmc+3vj952DLrkD5aCzFD
27+
nbCyQ8YrEUI9nU+JmrQWwsHR
28+
-----END PRIVATE KEY-----

package.json

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,32 @@
2020
],
2121
"license": "MIT",
2222
"engines": {
23-
"node": ">=14",
23+
"node": ">=16",
2424
"npm": ">=6.4.1"
2525
},
2626
"scripts": {
2727
"build": "lerna run --concurrency 1 --stream --scope \"@farfetch/*\" build",
2828
"build:watch": "lerna run --parallel --concurrency=9999 --scope \"@farfetch/*\" build:watch",
29+
"build:copy-package-json": "lerna run --parallel --concurrency=9999 --scope \"@farfetch/*\" build:copy-package-json",
2930
"clean": "scripts/clean.sh && yarn clean:build",
3031
"clean:build": "lerna run --concurrency 4 --no-bail --parallel --scope \"@farfetch/*\" clean",
3132
"lint": "npx eslint . --ext .js,.ts,.jsx,.tsx,.mts,.mjs,.cjs",
3233
"postinstall": "patch-package",
3334
"format": "prettier --write '**/*.{js,ts,jsx,tsx,mts,mjs,cjs,json,md}'",
3435
"test": "rimraf coverage && yarn clean:build && jest",
36+
"test:e2e:build": "cross-env TS_NODE_PROJECT=\"tests/e2e/tsconfig.json\" node --loader ts-node/esm node_modules/webpack-cli/bin/cli.js --config tests/e2e/webpack.config.ts",
37+
"test:e2e:server": "tests/e2e/scripts/start-local-server.sh",
38+
"test:e2e:run": "playwright test --config=tests/e2e/playwright.config.ts",
39+
"test:e2e:run:critical": "playwright test --config=tests/e2e/playwright.config.ts --project=critical-tests",
40+
"test:e2e:run:non-critical": "playwright test --config=tests/e2e/playwright.config.ts --project=non-critical-tests",
3541
"prepare": "husky install",
3642
"yalc:publish": "scripts/yalc-publish.sh",
3743
"yalc:push": "scripts/yalc-push.sh",
3844
"ci:types": "yarn ci:types:runtime && yarn ci:types:tests",
3945
"ci:types:runtime": "lerna run --concurrency 4 --no-bail --parallel --scope \"@farfetch/*\" ci:types",
4046
"ci:types:tests": "tsc -p tsconfig.ci.tests.json",
4147
"ci:release": "scripts/release.sh",
48+
"ci:release:dry-run": "yarn ci:release --dry-run",
4249
"dev:link": "lerna run --concurrency 1 --stream --scope \"@farfetch/*\" dev:link",
4350
"dev:unlink": "lerna exec --concurrency 1 --stream --scope \"@farfetch/*\" 'cd dist && yarn unlink'",
4451
"release:git": "scripts/release-git.sh"
@@ -50,6 +57,7 @@
5057
"@babel/preset-typescript": "^7.13.0",
5158
"@commitlint/cli": "^17.0.1",
5259
"@commitlint/config-conventional": "^17.0.0",
60+
"@playwright/test": "^1.40.1",
5361
"@testing-library/jest-dom": "^5.11.4",
5462
"@testing-library/react": "^13.3.0",
5563
"@types/invariant": "^2.2.34",
@@ -61,11 +69,15 @@
6169
"@types/redux-mock-store": "^1.0.3",
6270
"@types/url-parse": "^1.4.3",
6371
"@types/uuid": "3.4.0",
64-
"@typescript-eslint/eslint-plugin": "5.54.0",
65-
"@typescript-eslint/parser": "5.53.0",
72+
"@types/webpack-env": "^1.18.4",
73+
"@typescript-eslint/eslint-plugin": "6.21.0",
74+
"@typescript-eslint/parser": "6.21.0",
6675
"babel-eslint": "^10.1.0",
76+
"babel-loader": "^9.1.3",
6777
"browserslist-config-google": "^2.0.0",
6878
"core-js": "^3.6.5",
79+
"cross-env": "^7.0.3",
80+
"css-loader": "^6.9.1",
6981
"eslint": "^8.16.0",
7082
"eslint-config-prettier": "^8.5.0",
7183
"eslint-config-react-app": "^7.0.1",
@@ -81,26 +93,39 @@
8193
"faker": "^5.5.3",
8294
"fs-extra": "^10.1.0",
8395
"gitpkg": "^1.0.0-beta.4",
96+
"html-webpack-plugin": "^5.6.0",
8497
"husky": "^7.0.4",
8598
"jest": "^28.1.0",
8699
"jest-environment-jsdom": "^28.1.0",
87100
"jest-localstorage-mock": "^2.4.0",
88101
"jest-watch-typeahead": "^1.1.0",
89102
"lerna": "^5.0.0",
90103
"lint-staged": "^12.4.2",
104+
"local-web-server": "^5.3.0",
105+
"lodash-es": "^4.17.21",
91106
"msw": "^1.1.0",
92107
"patch-package": "^6.5.1",
108+
"postcss": "^8.4.33",
109+
"postcss-loader": "^8.0.0",
110+
"postcss-preset-env": "^9.3.0",
93111
"postinstall-postinstall": "^2.1.0",
94112
"prettier": "^2.6.2",
95113
"react": "^18.2.0",
96114
"react-dom": "^18.2.0",
115+
"react-router-dom": "^6.21.1",
116+
"redux-thunk": "2.4.2",
97117
"rimraf": "^3.0.2",
98-
"typescript": "5.0.2"
118+
"style-loader": "^3.3.4",
119+
"tailwindcss": "^3.4.1",
120+
"ts-node": "^10.9.2",
121+
"typescript": "5.3.3",
122+
"webpack": "^5.89.0",
123+
"webpack-cli": "^5.1.4"
99124
},
100125
"resolutions": {
101126
"@babel/core": "7.16.0",
102127
"@babel/preset-env": "7.16.4",
103-
"@typescript-eslint/eslint-plugin": "5.54.0",
128+
"@typescript-eslint/eslint-plugin": "6.21.0",
104129
"color-string": "^1.6.0",
105130
"css-what": "^5.0.1",
106131
"dot-prop": "^6.0.1",

0 commit comments

Comments
 (0)