Skip to content

Commit 91d87f8

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

39 files changed

+4004
-231
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
jsx: true,
1515
},
1616
},
17+
ignorePatterns: ['dist', 'node_modules', 'playwright', 'coverage'],
1718
plugins: ['sort-imports-es6-autofix', 'eslint-plugin-tsdoc', 'prettier'],
1819
rules: {
1920
curly: 'error',
@@ -123,11 +124,12 @@ module.exports = {
123124
'react-hooks/rules-of-hooks': 'error',
124125
'react-hooks/exhaustive-deps': 'warn',
125126
'tsdoc/syntax': 'warn',
127+
'@typescript-eslint/no-explicit-any': 'warn',
126128
},
127129
overrides: [
128130
// Disable all tsdoc checking in test files
129131
{
130-
files: ['*.test.*[t|j]s*', '*.fixtures.*[t|j]s*'],
132+
files: ['*.test.*[t|j]s*', '*.fixtures.*[t|j]s*', 'tests/e2e/**/*.*'],
131133
rules: {
132134
'tsdoc/syntax': 'off',
133135
// We use const xxx = () => {} many times in tests.

.github/workflows/CI.yml

Lines changed: 98 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,119 @@ 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+
SimpleChecks:
2825
runs-on: ubuntu-latest
2926
# Do not run if the pull request is a draft
3027
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
3128

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

44-
- uses: actions/setup-node@v2
130+
- uses: actions/setup-node@v4
45131
with:
46-
node-version: '14'
132+
node-version: '16'
47133
registry-url: 'https://registry.npmjs.org'
48134
scope: '@farfetch'
49135
cache: 'yarn'
@@ -77,15 +163,6 @@ jobs:
77163
- name: Install dependencies
78164
run: yarn install --ignore-engines --frozen-lockfile
79165

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-
89166
# Only make a release if it is a run of the 'main' or 'next' branches
90167
# or a pull request that contains a 'chore: make release' message
91168
- name: Make release
@@ -102,4 +179,4 @@ jobs:
102179
GIT_AUTHOR_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
103180
GIT_COMMITTER_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }}
104181
GIT_COMMITTER_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
105-
run: yarn ci:release
182+
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-----

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+
MIIEvgIBADANBgkqhki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z61bEj2+MbQBgUwRPpmNOnTslPlRoDH0FFEYm89a9CoF6hDqJGwWcf5RVpc8m46
19+
tVGxns/IHyMCgYBiDzz18YCNenn7Ec3loKs/ocwi5uo57JX6GauZ3q8DZLvEeCwn
20+
aUahktbk8lobbFiL3mAjP5gNisNAqG36EcCd16IL5EfXJpiuUyfueF1pjsd4PkWP
21+
bWkH4EmlnruQB38PnBF04Rm7ELy0TdJgMJSBnEfesVEB7vALoII8JYsKMQKBgCB9
22+
DEqLpIvYc5oIGB9W+b1s66pPxMOfl7cL4RNV3rvn9qhb63GGQl1H7982eSBfZemR
23+
BHAjgdqLLi7zBop5PL0WxaMMl/6d2gmMqyDHxP4XEWWnaWmjYovEZ6PVkIsGHoLD
24+
A/D7Y3pXvn8OmnotOVgJWS4zHucre5TCZy01D3MXAoGBAKuf56LxUjgyGK5LnXvN
25+
4aC50epwdHPwR6iCAA87p/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",

packages/redux/src/checkout/reducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ const convertCheckoutOrder = (
165165
) {
166166
return srcValue;
167167
}
168+
169+
return undefined;
168170
};
169171

170172
const tempMergedState = {};

packages/redux/src/search/reducer/searchDidYouMean.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import * as actionTypes from '../actionTypes.js';
22
import type { AnyAction } from 'redux';
3-
import type {
4-
SearchHash as Hash,
5-
SearchDidYouMeanState,
6-
} from '../types/index.js';
3+
import type { SearchDidYouMeanState } from '../types/index.js';
74

8-
export const INITIAL_STATE: Record<Hash, SearchDidYouMeanState> = {};
5+
export const INITIAL_STATE: SearchDidYouMeanState = {};
96

107
const searchDidYouMeanReducer = (state = INITIAL_STATE, action: AnyAction) => {
118
switch (action.type) {
@@ -35,7 +32,7 @@ const searchDidYouMeanReducer = (state = INITIAL_STATE, action: AnyAction) => {
3532
[action.meta.hash]: {
3633
result: action.payload.result,
3734
isLoading: false,
38-
error: false,
35+
error: null,
3936
query: action.meta.query,
4037
},
4138
};

0 commit comments

Comments
 (0)