Skip to content

Commit 9c54c97

Browse files
committed
[Auto Generated]
1 parent 789bd16 commit 9c54c97

7 files changed

Lines changed: 93 additions & 48 deletions

File tree

azure-pipelines.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,40 @@ variables:
1515
- group: ado-gh-sync-vg # contains GITHUB_APP_ID and GITHUB_APP_INSTALLATION_ID
1616

1717
jobs:
18+
# ---- Gate: run unit tests + enforce 90% coverage BEFORE anything is built/synced ----
19+
- job: Test
20+
displayName: 'Unit tests & 90% coverage gate'
21+
container: node18
22+
steps:
23+
- checkout: self
24+
25+
- script: |
26+
set -euo pipefail
27+
28+
echo "Installing dependencies (incl. devDependencies for jest/ts-jest)..."
29+
NODE_ENV=development npm install
30+
31+
echo "Running unit tests with enforced 90% coverage threshold..."
32+
# 'npm run test' runs jest with coverageThreshold=90 in jest.config.js.
33+
# Jest exits non-zero if ANY test fails OR if coverage falls below 90%,
34+
# which fails this step -> fails this job -> the GitHubSync job is skipped.
35+
npm run test
36+
37+
echo "Generating coverage summary (coverage/coverage_output.json)..."
38+
npm run coverage:output
39+
displayName: 'Run tests (fails if any test fails or coverage < 90%)'
40+
41+
- task: PublishCodeCoverageResults@1
42+
displayName: 'Publish code coverage report'
43+
condition: succeededOrFailed()
44+
inputs:
45+
codeCoverageTool: 'Cobertura'
46+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
47+
48+
# ---- Build / GitHub sync: only runs if the Test gate above passed ----
1849
- job: GitHubSync
50+
dependsOn: Test
51+
condition: succeeded()
1952
container: node18
2053
steps:
2154
- checkout: self

github_app_jwt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3ODEwNzcxNzQsImV4cCI6MTc4MTA3Nzc0NCwiaXNzIjoiMzA1NjEyNSJ9.F6aJlt2C9X1GjvW1m-IRgWoMeRCGPHngcJ6-VQBho3sz4xkfp3POzdtx26q8nJXHqNnSuoW-FYdJEVIi_DT9i9O1mEmQxV7M8CW-O_ddir6PzXwhIgLzZ3Gx6H2KaDo2VIoxc0yWvBpW6DzxtuwhyJE3DHDI_j4Tq708edXj79ngzOATec1DglZFshrnU_sJGRQStnkq_tQH1-lcY_J89G9beeDSFU2d9NBrtCLz40Djz-2ZBaVujBK02vCYHxzvJV9U2hCEEVKpRBreP73YsaUE7xpH4G2oVlCxzeLqpJb5UeEQsvgCFmDRHpKf_EftxpDOt6NLnjSSpJEpRsSm2Q
1+
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3ODE2MDkxNzEsImV4cCI6MTc4MTYwOTc0MSwiaXNzIjoiMzA1NjEyNSJ9.xk-cptzRZBMXuz5SEfwpM72f8IVNbczr-mCJrqxb4zzoadLDvqNH39LQPW5RlOyBUo3WWlGdHqWmNV4mb496nF494QsjD7gIY0-IzcTlJEdKhRExlhsl6bAR8wbtrHPs9uN576jgbaZxtsHdkS94fMnQPATAbzD5RtijP67fpk2RE1xr7YoMWxLcgRI_1cQFDKW4VpAyWdagtT7jqczUbiBEi35kdaKjWXkg3shFL3IpitZ7qHJeKh1U6wUbtcfEY3rNFCMxLShLRH35xquLUQZhCZbtW5lNjyfPDYMNwuMeO2968_ZhGOD9u5JxJkDKUCD4XWxKU-f9oLW_Gsk-9A

lib/store/index.d.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,9 @@ declare class ApplicationStore {
1616
PaymentGateways: Record<string, any>;
1717
private domain;
1818
private authorizationHeader;
19-
/** orderingSource provided via the constructor (initialised by react-starter). */
20-
private constructorOrderingSource;
21-
/** orderingSource provided at runtime via setOrderingSource (called by skyfire). */
22-
private skyfireOrderingSource;
23-
/**
24-
* Effective ordering source. The constructor value (react-starter / theme)
25-
* takes priority; if it is falsy we fall back to the value set via
26-
* setOrderingSource (skyfire), and if both are falsy we default to
27-
* 'storefront'.
28-
*/
29-
get orderingSource(): string;
30-
/** orderingSourceType — 'storefront' when an ordering source is present. */
31-
get orderingSourceType(): string;
19+
orderingSource: string;
20+
/** orderingSourceType — set to 'storefront' when orderingSource is set. */
21+
orderingSourceType: string;
3222
private serverCookies;
3323
private start_upload_query;
3424
private complete_upload_query;
@@ -38,7 +28,6 @@ declare class ApplicationStore {
3828
private encodeCookie;
3929
setServerCookies(cookies?: Record<string, string>): void;
4030
setI18nDetails(cookieValue: any): void;
41-
setOrderingSource(orderingSource: string): void;
4231
observeStore(getter: Function, onChange: Function): void;
4332
private readonly gqlModifier;
4433
mutations: {

lib/store/index.js

Lines changed: 12 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/store/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"test": "jest --config jest.config.js --json --outputFile='./coverage/coverage.json'",
1818
"test:uifunction": "jest --config jest.config.js --json --outputFile='./coverage/coverage.json' src/__tests__/store/modules/graphqlModifications.test.ts src/__tests__/store/index.test.ts src/__tests__/store/slices/payment.test.ts",
1919
"test:coverage": "jest --coverage",
20+
"coverage:output": "node scripts/coverage-output.js",
21+
"test:report": "npm run test; npm run coverage:output",
2022
"doc": "typedoc --plugin typedoc-plugin-missing-exports --plugin typedoc-plugin-markdown",
2123
"local": "webpack --watch",
2224
"generate": "graphql-codegen",

scripts/coverage-output.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
// Jest writes its test-results JSON here (via: jest --json --outputFile=./coverage/coverage.json)
5+
const coverage = fs.readFileSync(
6+
path.resolve(__dirname, '../coverage/coverage.json'),
7+
'utf8',
8+
);
9+
10+
if (
11+
coverage
12+
&& JSON.parse(coverage).numFailedTests === 0
13+
&& JSON.parse(coverage).numFailedTestSuites === 0
14+
&& JSON.parse(coverage).numPendingTestSuites === 0
15+
&& JSON.parse(coverage).numPendingTests === 0
16+
&& JSON.parse(coverage).numPassedTests === JSON.parse(coverage).numTotalTests
17+
) {
18+
// Istanbul json-summary reporter writes the per-file + total summary here.
19+
let data = fs.readFileSync(
20+
path.resolve(__dirname, '../coverage/coverage-summary.json'),
21+
'utf8',
22+
);
23+
data = JSON.parse(data).total;
24+
let output = {
25+
coverage_pct: data.lines.pct,
26+
lines_total: data.lines.total,
27+
lines_covered: data.lines.covered,
28+
branch_pct: data.branches.pct,
29+
branches_covered: data.branches.covered,
30+
branches_total: data.branches.total,
31+
};
32+
output = JSON.stringify(output, null, 2);
33+
fs.writeFileSync(
34+
path.join(__dirname, '../coverage/', 'coverage_output.json'),
35+
output,
36+
'utf8',
37+
);
38+
console.log('dumped coverage_output.json');
39+
} else {
40+
console.error('coverage_output.json not generated');
41+
}

0 commit comments

Comments
 (0)