Skip to content

Commit

Permalink
ci: [BLA-1118] Unit test cases should run in pipeline (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwapriya authored Jan 24, 2025
1 parent 7404f97 commit 5fae8f5
Show file tree
Hide file tree
Showing 189 changed files with 48 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ jobs:
./packages/**/node_modules
key: modules-${{ hashFiles('package-lock.json') }}

- name: Install Dependencies
run: npm ci

- name: Build
run: npm run build

- name: Lint
run: npm run lint

- name: Test
run: npm test
run: npm run test
continue-on-error: false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build-react-components": "npm run build --workspace=@otto-de/b2b-react-components",
"build": "npm-run-all build-tokens build-core-components build-react-components",
"lint": "npm run lint --workspace=@otto-de/b2b-core-components",
"test": "npm run test --workspace=@otto-de/b2b-core-components",
"test": "node test-runner.js",
"prepare": "node scripts/prepare.mjs",
"preinstall": "npx force-resolutions"
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion packages/core-components/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module.exports = {
},
"transformIgnorePatterns": [
"node_modules/(?!variables/.*)"
]
],
bail: true,
}
1 change: 1 addition & 0 deletions packages/core-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"build:icons": "node scripts/generate-icon-types.mjs",
"start": "stencil build --dev --watch --serve --config stencil-dev.config.ts",
"test": "stencil test --spec --e2e",
"test-ci": "stencil test --spec --e2e --ci",
"test.watch": "stencil test --spec --e2e --watch",
"generate": "stencil generate",
"lint": "eslint \"src/**/*{.ts,.tsx}\" && stylelint \"src/**/*{.scss,.css}\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,17 @@ describe('B2B-Radio-Group', () => {
expect(error).not.toBeDefined;
});

it('should use label slot if provided', async () => {
await page.setContent(`
it('should use label slot if provided ', async () => {
const slotPage = await newE2EPage();
await slotPage.setContent(`
<b2b-radio-group name="test-group">
<span slot="label">Custom label</span>
<b2b-radio-button label="one" value="one" name="test-group" id="one" hint="test" error="test"></b2b-radio-button>
<b2b-radio-button label="two" value="two" name="test-group" id="two"</b2b-radio-button>
</b2b-radio-group>
`);

const element = await page.find('span');
const element = await slotPage.find('span');

expect(element).toEqualText('Custom label');
});
Expand Down
5 changes: 3 additions & 2 deletions packages/core-components/src/components/radio/radio.e2e.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ describe('b2b-radio', () => {
});

it('should use label slot if provided', async () => {
await page.setContent(`
const slotPage = await newE2EPage();
await slotPage.setContent(`
<b2b-radio-button value="one">
<span slot="label">Custom label</span>
</b2b-radio-button>`);

const element = await page.find('span');
const element = await slotPage.find('span');

expect(element).toEqualText('Custom label');
});
Expand Down
4 changes: 4 additions & 0 deletions packages/core-components/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ export const config: Config = {
],
}),
],
testing: {
browserArgs: ['--no-sandbox', '--disable-setuid-sandbox'],
browserHeadless: true,
},
};
27 changes: 27 additions & 0 deletions test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { exec } = require('child_process');

const stencilTestCommand = 'npm run test --workspace=@otto-de/b2b-core-components';

exec(stencilTestCommand, (error, stdout, stderr) => {
console.log(stdout);
console.error(stderr);

console.log('STDOUT:', stdout);
console.log('STDERR:', stderr);

const testFailureRegex = /Tests:.*\bfailed\b|Test Suites:.*\bfailed\b/i;

const hasFailures = testFailureRegex.test(stdout) || testFailureRegex.test(stderr);

if (hasFailures) {
console.error('Test failures detected!');
process.exit(1);
} else if (error) {
console.error('Test command execution failed!');
console.error(error.message);
process.exit(1);
} else {
console.log('All tests passed successfully!');
process.exit(0);
}
});
2 changes: 1 addition & 1 deletion test.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use playwright image as a base

FROM mcr.microsoft.com/playwright:v1.49.0-jammy AS playwright
FROM mcr.microsoft.com/playwright:v1.50.0-jammy AS playwright


WORKDIR /b2b
Expand Down

0 comments on commit 5fae8f5

Please sign in to comment.