Skip to content

Commit

Permalink
test: Test ssr server returns 500 status code when api request return…
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyber authored Oct 16, 2023
1 parent 810956d commit a2ee373
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
43 changes: 16 additions & 27 deletions .github/workflows/ci-continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,6 @@ jobs:
- name: Run unit tests
run: |
ci-scripts/unit-tests.sh
build-libs:
# TODO: For Testing SSR Epic only, remove job before merge
name: CI - Build Libraries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: |
node_modules
projects/storefrontapp-e2e-cypress/node_modules
~/.cache/Cypress
key: nodemodules-${{ github.event.pull_request.base.sha }}
restore-keys: nodemodules-${{ github.event.pull_request.base.sha }}
- name: Package installation
run: npm ci
- name: Build Libraries
run: |
npm run build:libs
sonarqube_scan:
name: CI - SonarQube Scan
runs-on: ubuntu-latest
Expand Down Expand Up @@ -114,6 +87,22 @@ jobs:
- name: Run linting validation
run: |
ci-scripts/validate-lint.sh
# TODO: For testing ssr-tests epic only. Remove before merging to ssr error handling epic.
ssr_tests:
name: SSR tests (for testing ssr-tests epic only)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Package installation
run: npm ci
- name: Build SSR Server
run: npm run build:libs && npm run build && npm run build:ssr:local-http
- name: Run SSR tests
run: npm run test:ssr:ci --verbose
ci_result:
needs: [unit_tests, sonarqube_scan, linting]
name: CI - Result
Expand Down
2 changes: 1 addition & 1 deletion projects/ssr-tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test-jest": {
"executor": "nx:run-commands",
"options": {
"command": "npm run test",
"command": "npm run test --verbose",
"cwd": "projects/ssr-tests"
}
}
Expand Down
6 changes: 1 addition & 5 deletions projects/ssr-tests/src/ssr-testing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ describe('SSR E2E', () => {
// TODO: Test incomplete
xit('should receive 404 response when page is not existing', () => {});

// TODO: Test incomplete
xit('should receive 500 error response with request', async () => {
it('should receive 500 error response when a backend API returned server error', async () => {
proxy = await ProxyServer.startProxyServer({
target: BACKEND_BASE_URL,
throwStatus: 500,
});
proxy.on('proxyRes', function (proxyRes: any) {
proxyRes.statusCode = 500;
});
const response: any = await ProxyServer.sendRequest('/');
expect(response.statusCode).toEqual(500);
});
Expand Down

0 comments on commit a2ee373

Please sign in to comment.