Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: sonar integration #1624

Draft
wants to merge 37 commits into
base: vue3-update-rc
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7ee26f7
test: fix semantic queries test
diegopf Aug 27, 2024
1a9c3e2
test: use queries preview composable
annacv Aug 28, 2024
4db3c4e
fix e2e tests
diegopf Aug 28, 2024
266b0b8
fix e2e tests
diegopf Aug 28, 2024
6846f89
test: rm unneeded reset in queries preview composable
annacv Aug 29, 2024
db46343
test: fix facets module tests
lauramargar Sep 2, 2024
51c2727
test: fix semantics module tests
lauramargar Sep 3, 2024
338ebf6
test: wip
lauramargar Sep 4, 2024
92ff1a5
test: preselected-filters in progress
albertjcuac Sep 4, 2024
3772b5f
test: WIP stopped tests
annacv Sep 4, 2024
c234273
test: fix test sheets of filter components
joseacabaneros Sep 4, 2024
f3965cc
test: fix search-input test
albertjcuac Sep 5, 2024
cb77b90
test: fix renderless-extra-params test
albertjcuac Sep 5, 2024
e6212e9
test: fix clear-history-queries test sheet
joseacabaneros Sep 5, 2024
cc19ef2
test: fix related-tags test sheets
joseacabaneros Sep 5, 2024
ac0f6da
test: fix next-query test
albertjcuac Sep 5, 2024
a2ca5d8
test: fix x-installer test sheet
joseacabaneros Sep 5, 2024
0491262
test: fix default-api test sheet
joseacabaneros Sep 5, 2024
7f32411
test: fix test sheets related with vue-global-events third party depe…
joseacabaneros Sep 5, 2024
0921cdb
test: fix actions test sheet of related-tags module
joseacabaneros Sep 6, 2024
fe97947
test: fix identifier-results test sheet
joseacabaneros Sep 10, 2024
21d1f91
test: fix results-list test sheet and forward slots in the component …
joseacabaneros Sep 11, 2024
6578942
test: fix banners-list test sheet and forward slots in the component …
joseacabaneros Sep 11, 2024
603efb6
test: fix promoted-list test sheet and forward slots in the component…
joseacabaneros Sep 11, 2024
16d7a53
test: fix next-queries test sheet
joseacabaneros Sep 11, 2024
a1e3f75
test: fix selected-filters test sheet
lauramargar Sep 12, 2024
b0ef676
test: fix query-preview test sheet
joseacabaneros Sep 12, 2024
0a53b9a
test: reactivate skipped test in history-query and clean up
joseacabaneros Sep 12, 2024
dc3f148
fix: PR comments
joseacabaneros Sep 13, 2024
4798db3
test: fix search-input unit test
joseacabaneros Sep 13, 2024
36f0091
test: fix next-queries-list test sheet
joseacabaneros Sep 16, 2024
0a8d8d0
test: fix minor issue with query-preview-list test sheet
joseacabaneros Sep 16, 2024
23095f6
test: active and fix linter for tests
joseacabaneros Sep 16, 2024
53dfa69
test(e2e): fix e2e tests
joseacabaneros Sep 17, 2024
025e8ab
test(e2e): revert hierarchical-filter e2e changes
joseacabaneros Sep 17, 2024
d08a5b4
test(e2e-components): rewrite all e2e components to accomplish vue3
joseacabaneros Sep 23, 2024
c628431
ci(sonar): integrate sonar in project
joseacabaneros Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ jobs:
timeout-minutes: 15
uses: ./.github/actions/run-e2e-tests

- name: Load Motive Shared Actions
uses: daspn/private-actions-checkout@v2
with:
app_id: ${{ secrets.MOTIVE_PRIVATE_ACTIONS_APP_ID }}
app_private_key: ${{ secrets.MOTIVE_PRIVATE_ACTIONS_APP_PRIVATE_KEY }}
configure_git: true
actions_list: '[ "empathyco/platform-motive-ci-library@v5" ]'
checkout_base_path: ./.loaded_actions/actions

- name: Sonar scanner
uses: ./.loaded_actions/actions/platform-motive-ci-library/node/sonarqube
env:
BROWSERSLIST_IGNORE_OLD_DATA: 'true'
with:
IS_PR: 'true'
BRANCH_NAME: main
CHANGE_BRANCH: ${{ github.event.pull_request.head.ref }}
CHANGE_TARGET: ${{ github.event.pull_request.base.ref }}
CHANGE_ID: ${{ github.event.number }}
REPO_NAME: ${{ github.event.repository.name }}

- name: release
if:
${{ github.ref_name == 'main' && github.actor != 'support-empathy' &&
Expand Down
13 changes: 4 additions & 9 deletions packages/x-components/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
module.exports = {
extends: ['plugin:@empathyco/x/all'],
// TODO - Reactivate linter for unit and e2e tests once they pass.
ignorePatterns: [
'cypress.config.ts',
'**/__tests__/**/*.spec.ts',
'**/tests/**/*.spec.ts',
'**/__tests__/**/utils.ts',
'**/tests/**/utils.ts'
],
ignorePatterns: ['cypress.config.ts'],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.eslint.json'
Expand Down Expand Up @@ -43,7 +36,9 @@ module.exports = {
{
files: ['*.spec.ts'],
rules: {
'max-len': 'off'
'max-len': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'vue/one-component-per-file': 'off'
}
}
]
Expand Down
33 changes: 19 additions & 14 deletions packages/x-components/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
import { createEsbuildPlugin } from '@badeball/cypress-cucumber-preprocessor/esbuild';
import { defineConfig } from 'cypress';

export default defineConfig({
Expand All @@ -9,34 +7,41 @@ export default defineConfig({
requestTimeout: 7000,
viewportHeight: 1080,
viewportWidth: 1920,
screenshotOnRunFailure: false,
video: false,
specPattern: 'tests/e2e/**/*.feature',
supportFile: 'tests/support/index.ts',
fixturesFolder: 'tests/e2e/fixtures',
screenshotsFolder: 'tests/e2e/screenshots',
experimentalRunAllSpecs: true,
screenshotOnRunFailure: false,
video: false,
retries: {
openMode: 0,
runMode: 1
},
async setupNodeEvents(on, config) {
await addCucumberPreprocessorPlugin(on, config);
on(
'file:preprocessor',
require('@bahmutov/cypress-esbuild-preprocessor')({
plugins: [createEsbuildPlugin(config)]
})
const { createEsbuildPlugin } = require('@badeball/cypress-cucumber-preprocessor/esbuild');
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor');

// await here
await require('@badeball/cypress-cucumber-preprocessor').addCucumberPreprocessorPlugin(
on,
config
);

on('file:preprocessor', createBundler({ plugins: [createEsbuildPlugin(config)] }));

// return any mods to Cypress
return config;
},
specPattern: 'tests/e2e/**/*.feature',
experimentalRunAllSpecs: true
}
},
component: {
defaultCommandTimeout: 7000,
experimentalSingleTabRunMode: true,
viewportHeight: 1080,
viewportWidth: 1920,
specPattern: 'tests/unit/**/*.spec.ts',
supportFile: 'tests/support/index.ts',
indexHtmlFile: 'tests/support/component-index.html',
experimentalSingleTabRunMode: true,
screenshotOnRunFailure: false,
video: false,
retries: {
Expand Down
3 changes: 3 additions & 0 deletions packages/x-components/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module.exports = {
'^.+\\.vue$': '@vue/vue3-jest',
'^.+\\.scss$': 'jest-scss-transform'
},
moduleNameMapper: {
'vue-global-events': '<rootDir>/node_modules/vue-global-events/dist/index.cjs'
},
testMatch: ['<rootDir>/src/**/*.spec.ts'],
setupFilesAfterEnv: ['./jest.setup.ts'],
// jest 27 changes the default environment to node instead of jsdom
Expand Down
4 changes: 2 additions & 2 deletions packages/x-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
"gen:typescript-docs": "api-documenter markdown --input-folder dist/report --output-folder docs/API-reference/api",
"gen:component-docs": "vue-docgen",
"lint": "eslint . --ext .ts,.vue",
"test:unit": "jest --silent",
"test:unit": "jest --coverage",
"test:unit-jest": "jest",
"test:unit-cypress": "cypress run --component --browser chrome",
"test:unit-coverage": "jest --coverage",
"test:unit-watch": "jest --watch",
"test:unit-cypress": "cypress run --component --browser chrome",
"test:e2e": "start-server-and-test preview http://localhost:8080 cypress:open",
"test:e2e:firefox": "start-server-and-test serve http://localhost:8080 cypress:open:firefox",
"test:e2e:ci": "start-server-and-test serve http://localhost:8080 cypress:run:ci",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { ComponentMountingOptions, mount } from '@vue/test-utils';
import { installNewXPlugin } from '../../__tests__/utils';
import { XPlugin } from '../../plugins';
import { WireMetadata } from '../../wiring/wiring.types';
import { WireMetadata, XEventsTypes } from '../../wiring';
import BaseEventButton from '../base-event-button.vue';
import { XEventsTypes } from 'src/wiring';

const stubSlot = `<span class="test-msg">button text</span>
<i class="test-icon"></i>`;
const stubSlot = `<span class="test-msg">button text</span><i class="test-icon"></i>`;

function render(options: ComponentMountingOptions<typeof BaseEventButton> = {}) {
const wrapper = mount(BaseEventButton, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,10 @@ function renderHighlight({
});
return {
wrapper,
getStartPart() {
return wrapper.find(getDataTestSelector('highlight-start'));
},
getMatchingPart() {
return wrapper.find(getDataTestSelector('matching-part'));
},
getEndPart() {
return wrapper.find(getDataTestSelector('highlight-end'));
},
async setHighlight(highlight: string) {
return await wrapper.setProps({ highlight } as any);
}
getStartPart: () => wrapper.find(getDataTestSelector('highlight-start')),
getMatchingPart: () => wrapper.find(getDataTestSelector('matching-part')),
getEndPart: () => wrapper.find(getDataTestSelector('highlight-end')),
setHighlight: (highlight: string) => wrapper.setProps({ highlight } as any)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('testing useXBus', () => {
onColumnsNumberProvidedMock.mockReset();
});

it('should emit and on subscription in the bus for registered events', async () => {
it('should emit and on subscription in the bus for registered events', () => {
const { emitSpy, onSpy } = render();
const metadata = {
customMetadata: 'custom',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createLocalVue } from '@vue/test-utils';
import { computed, defineComponent, inject, nextTick } from 'vue';
import { XComponentsAdapterDummy } from '../../../__tests__/adapter.dummy';
import { XInstaller } from '../../x-installer/x-installer';
import { XInstaller } from '../../x-installer';
import { NormalisedSnippetConfig, SnippetConfig } from '../api.types';
import { BaseXAPI } from '../base-api';
import { XDummyBus } from '../../../__tests__/bus.dummy';
Expand Down Expand Up @@ -66,43 +66,42 @@ describe('testing default X API', () => {
});

it('changes the `SnippetConfig` when calling the `setSnippetConfig` function', async () => {
const vue = createLocalVue();
const snippetConfig: SnippetConfig = {
instance: 'test',
scope: 'test',
lang: 'es'
};
const installerApp = vue.extend({
inject: ['snippetConfig'],
render(h) {
// Vue does not provide type safety for inject
const lang = (this as any).snippetConfig.lang;
const store = (this as any).snippetConfig.store;
return h('div', [
h('h1', { class: 'lang-test' }, [lang]),
h('h1', { class: 'store-test' }, [store])
]);
}
const rootComponent = defineComponent({
setup: () => {
const snippetConfig = inject<SnippetConfig>('snippetConfig');
const lang = computed(() => snippetConfig?.lang ?? '');
const store = computed(() => snippetConfig?.store ?? '');
return { lang, store };
},
template: `<div>
<h1 class="lang-test">{{ lang }}</h1>
<h1 class="store-test">{{ store }}</h1>
</div>`
});

const { api, app } = await new XInstaller({
const { api } = await new XInstaller({
rootComponent,
adapter: XComponentsAdapterDummy,
api: defaultXAPI,
app: installerApp
api: defaultXAPI
}).init(snippetConfig);

const langElement = app?.$el.getElementsByClassName('lang-test')[0];
const storeElement = app?.$el.getElementsByClassName('store-test')[0];
const langElement = document.querySelector('.lang-test');
const storeElement = document.querySelector('.store-test');

expect(langElement).toHaveTextContent(snippetConfig.lang);
expect(langElement?.textContent).toEqual(snippetConfig.lang);
api?.setSnippetConfig({ lang: 'en' });
await vue.nextTick();
expect(langElement).toHaveTextContent('en');
await nextTick();
expect(langElement?.textContent).toEqual('en');

expect(storeElement).toHaveTextContent('');
expect(storeElement?.textContent).toEqual('');
api?.setSnippetConfig({ store: 'Portugal' });
await vue.nextTick();
expect(storeElement).toHaveTextContent('Portugal');
await nextTick();
expect(storeElement?.textContent).toEqual('Portugal');
});

it('should allow set the snippetConfig getter', () => {
Expand Down
Loading
Loading