WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 22b452a

Browse files
authored
Merge pull request #113 from azerothcore/feat/e2e-tests-and-fix-npm
feat: update dependencies and implemented e2e tests
2 parents 1fc477b + 693fd5e commit 22b452a

17 files changed

+660
-249
lines changed

.github/workflows/e2e.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: E2E
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
test-e2e:
11+
runs-on: ubuntu-latest
12+
env:
13+
CI: true
14+
NODE_OPTIONS: --openssl-legacy-provider
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '18'
23+
24+
- name: Show Node/npm versions
25+
run: |
26+
node -v
27+
npm -v
28+
29+
- name: Setup Chrome
30+
uses: browser-actions/setup-chrome@v1
31+
32+
- name: Cache npm
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.npm
36+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-npm-
39+
40+
- name: Install dependencies
41+
run: npm ci --no-audit --no-fund
42+
43+
- name: Prepare E2E config and data fixtures
44+
run: |
45+
mkdir -p src/assets/data
46+
cat > src/assets/config.json << 'JSON'
47+
{
48+
"perPage": 50,
49+
"pageSize": 8,
50+
"usePreGeneratedFile": true,
51+
"preGeneratedFileUrl": "assets/data/catalogue.json",
52+
"globalSearch": false,
53+
"tabs": {
54+
"All Modules": {
55+
"topic": "e2e-topic",
56+
"org": "e2e-org",
57+
"path": "/module"
58+
}
59+
}
60+
}
61+
JSON
62+
cat > src/assets/data/catalogue.json << 'JSON'
63+
{
64+
"organizations": {
65+
"e2e-org": {
66+
"e2e-topic": []
67+
}
68+
}
69+
}
70+
JSON
71+
72+
- name: Run unit tests (headless)
73+
run: npm run test-ci -- --browsers=ChromeHeadless
74+
75+
- name: Run E2E tests (Protractor, headless)
76+
run: npm run e2e -- --configuration=e2e --webdriver-update=false

angular.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@
6565
}
6666
]
6767
}
68+
,
69+
"e2e": {
70+
"fileReplacements": [
71+
{
72+
"replace": "src/environments/environment.ts",
73+
"with": "src/environments/environment.e2e.ts"
74+
}
75+
]
76+
}
6877
}
6978
},
7079
"serve": {
@@ -75,6 +84,9 @@
7584
"configurations": {
7685
"production": {
7786
"browserTarget": "git-catalogue:build:production"
87+
},
88+
"e2e": {
89+
"browserTarget": "git-catalogue:build:e2e"
7890
}
7991
}
8092
},
@@ -128,6 +140,9 @@
128140
"configurations": {
129141
"production": {
130142
"devServerTarget": "git-catalogue:serve:production"
143+
},
144+
"e2e": {
145+
"devServerTarget": "git-catalogue:serve:e2e"
131146
}
132147
}
133148
}
@@ -138,4 +153,4 @@
138153
"cli": {
139154
"analytics": false
140155
}
141-
}
156+
}

e2e/protractor.conf.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ exports.config = {
1313
'./src/**/*.e2e-spec.ts'
1414
],
1515
capabilities: {
16-
browserName: 'chrome'
16+
browserName: 'chrome',
17+
chromeOptions: process.env.CI ? {
18+
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage', '--window-size=1280,720']
19+
} : {}
1720
},
1821
directConnect: true,
22+
chromeDriver: '/usr/bin/chromedriver', // Use system chromedriver
23+
seleniumAddress: null, // Force direct connection
1924
baseUrl: 'http://localhost:4200/',
2025
framework: 'jasmine',
2126
jasmineNodeOpts: {
@@ -29,4 +34,4 @@ exports.config = {
2934
});
3035
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
3136
}
32-
};
37+
};

e2e/src/app.e2e-spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,21 @@ describe('workspace-project App', () => {
1414

1515
afterEach(async () => {
1616
// Assert that there are no errors emitted from the browser
17+
// Filter out network-related errors that are expected in CI environments
1718
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
18-
expect(logs).not.toContain(jasmine.objectContaining({
19-
level: logging.Level.SEVERE,
20-
} as logging.Entry));
19+
const filteredLogs = logs.filter(entry => {
20+
if (entry.level !== logging.Level.SEVERE) return false;
21+
22+
// Filter out network-related errors (fonts, external resources)
23+
const message = entry.message || '';
24+
const isNetworkError = message.includes('net::ERR_NAME_NOT_RESOLVED') ||
25+
message.includes('Failed to load resource') ||
26+
message.includes('fonts.googleapis.com') ||
27+
message.includes('fonts.gstatic.com');
28+
29+
return !isNetworkError;
30+
});
31+
32+
expect(filteredLogs).toEqual([]);
2133
});
2234
});

0 commit comments

Comments
 (0)