Skip to content

Commit

Permalink
chore(SFINT-3308): Update prettier and ran it (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-bompart committed Jul 8, 2020
1 parent 53fe18a commit d6c403c
Show file tree
Hide file tree
Showing 60 changed files with 421 additions and 419 deletions.
8 changes: 4 additions & 4 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = {
{
files: '*.json',
options: {
singleQuote: false
}
}
]
singleQuote: false,
},
},
],
};
20 changes: 10 additions & 10 deletions config/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ var configuration = {
// Both CoveoJsSearch and CoveoJsSearchTests are included as externals, so you need include them in your testing environment.
{
pattern: '../node_modules/coveo-search-ui/bin/js/CoveoJsSearch.js',
watched: false
watched: false,
},
{
pattern: '../node_modules/coveo-search-ui-tests/bin/js/CoveoJsSearchTests.js',
watched: false
watched: false,
},
{ pattern: '../src/Index.ts' },
{ pattern: '../tests/**/*.spec.ts' }
{ pattern: '../tests/**/*.spec.ts' },
],
preprocessors: {
// Builds both the components and the tests.
'../src/**/*.ts': ['webpack'],
'../tests/**/*.spec.ts': ['webpack']
'../tests/**/*.spec.ts': ['webpack'],
},
// Required for Chrome, if you use it.
mime: { 'text/x-typescript': ['ts'] },
Expand All @@ -31,22 +31,22 @@ var configuration = {
coverageIstanbulReporter: {
dir: path.resolve('./bin/coverage'),
reports: ['html', 'cobertura', 'json', 'lcov', 'text-summary'],
fixWebpackSourcePaths: true
fixWebpackSourcePaths: true,
},
webpack: webpackConfig,
webpackMiddleware: {
stats: 'minimal',
logLevel: 'warn'
logLevel: 'warn',
},
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
flags: ['--no-sandbox'],
},
},
};

module.exports = function(config) {
module.exports = function (config) {
config.set(configuration);
};
24 changes: 12 additions & 12 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ const path = require('path');
module.exports = {
mode: 'development',
entry: {
CoveoJsSearchExtensions: './src/Index'
CoveoJsSearchExtensions: './src/Index',
},
output: {
path: path.resolve('./bin/commonjs'),
filename: `[name].js`,
libraryTarget: 'umd',
library: 'CoveoExtension',
publicPath: '/commonjs'
publicPath: '/commonjs',
},
externals: [
{
// Defines the module "coveo-search-ui" as external, "Coveo" is defined in the global scope.
// This requires you to load the original CoveoJsSearch.js file in your page.
'coveo-search-ui': 'Coveo'
}
'coveo-search-ui': 'Coveo',
},
],
resolve: {
extensions: ['.js', '.ts']
extensions: ['.js', '.ts'],
},
devtool: 'source-map',
module: {
Expand All @@ -31,17 +31,17 @@ module.exports = {
options: {
configFile: path.resolve('./config/tsconfig.json'),
compilerOptions: {
target: 'es5'
}
}
target: 'es5',
},
},
},
{
test: /\.svg$/,
loader: 'raw-loader',
options: {}
}
]
options: {},
},
],
},
plugins: [],
bail: true
bail: true,
};
22 changes: 11 additions & 11 deletions config/webpack.config.karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ webpackConfig.module.rules = [
test: /\.ts$/,
use: [
{
loader: 'ts-es5-istanbul-coverage'
loader: 'ts-es5-istanbul-coverage',
},
{
loader: 'ts-loader',
Expand All @@ -19,30 +19,30 @@ webpackConfig.module.rules = [
module: 'commonjs',
inlineSourceMap: true,
sourceMap: undefined,
outDir: undefined
}
}
}
]
outDir: undefined,
},
},
},
],
},
{
test: /\.svg$/,
loader: 'raw-loader',
options: {}
options: {},
},
{
enforce: 'post',
test: /\.ts$/,
loader: 'istanbul-instrumenter-loader',
exclude: path.resolve('tests/'),
query: {
esModules: true
}
}
esModules: true,
},
},
];

webpackConfig.externals.push({
'coveo-search-ui-tests': 'CoveoJsSearchTests'
'coveo-search-ui-tests': 'CoveoJsSearchTests',
});

/**
Expand Down
20 changes: 5 additions & 15 deletions cypress/integration/user_actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ describe('User actions', () => {
describe('When I click on the user actions button', () => {
beforeEach(() => {
cy.get('.coveo-main-section').should('be.visible');
cy.get('.coveo-user-actions-dropdown-header')
.should('be.visible')
.click();
cy.get('.coveo-user-actions-dropdown-header').should('be.visible').click();
});

it('should hide user actions panel when I click on the user actions button', () => {
Expand All @@ -26,25 +24,17 @@ describe('User actions', () => {
it('should display user activity', () => {
cy.get('.CoveoUserActivity').should('be.visible');

cy.get('.coveo-activity > .coveo-search')
.should('be.visible')
.should('contain', 'some_query');
cy.get('.coveo-activity > .coveo-search').should('be.visible').should('contain', 'some_query');

cy.get('.coveo-activity > .coveo-click')
.should('be.visible')
.should('contain', 'some_document_title');
cy.get('.coveo-activity > .coveo-click').should('be.visible').should('contain', 'some_document_title');
});

it('should display user clicked document', () => {
cy.get('.CoveoClickedDocumentList')
.should('be.visible')
.should('contain', 'some_document_title');
cy.get('.CoveoClickedDocumentList').should('be.visible').should('contain', 'some_document_title');
});

it('should display user queries', () => {
cy.get('.CoveoQueryList')
.should('be.visible')
.should('contain', 'some_query');
cy.get('.CoveoQueryList').should('be.visible').should('contain', 'some_query');
});
});
});
14 changes: 7 additions & 7 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const wp = require('@cypress/webpack-preprocessor');
module.exports = on => {
module.exports = (on) => {
const options = {
webpackOptions: {
resolve: {
extensions: ['.ts', '.tsx', '.js']
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: { transpileOnly: true }
}
]
}
}
options: { transpileOnly: true },
},
],
},
},
};
on('file:preprocessor', wp(options));
};
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"ncp": "^2.0.0",
"node-sass": "^4.13.1",
"pre-commit": "^1.2.2",
"prettier": "1.16.4",
"prettier": "2.0.5",
"puppeteer": "^2.0.0",
"raw-loader": "^1.0.0",
"rimraf": "^2.6.3",
Expand Down
2 changes: 1 addition & 1 deletion pages/action_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="../commonjs/CoveoJsSearchExtensions.js"></script>
<script>
let attachedIds = [];
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
Coveo.SearchEndpoint.configureSampleEndpointV2();
Coveo.init(document.body, {});
});
Expand Down
16 changes: 8 additions & 8 deletions pages/attached_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@
<script src="../commonjs/CoveoJsSearchExtensions.js"></script>
<script>
let attachedIds = [];
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
Coveo.SearchEndpoint.configureSampleEndpointV2();
Coveo.init(document.body, {
AttachResult: {
attach: function(result) {
attach: function (result) {
return new Promise((resolve, reject) => {
console.log('attached ', result);
attachedIds.push(result.raw.urihash);
setTimeout(resolve, 1000);
});
},
detach: function(result) {
detach: function (result) {
return new Promise((resolve, reject) => {
console.log('detached ', result);
attachedIds.pop(result.raw.urihash);
setTimeout(resolve, 1000);
});
},
isAttached: function(result) {
isAttached: function (result) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(attachedIds.indexOf(result.raw.urihash) >= 0), 1000);
});
}
},
},
ResultsFilter: {
getValues: function() {
getValues: function () {
return attachedIds;
}
}
},
},
});
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion pages/copy_to_clipboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="../commonjs/CoveoJsSearchExtensions.js"></script>
<script>
let attachedIds = [];
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
Coveo.SearchEndpoint.configureSampleEndpointV2();
Coveo.init(document.body, {});
});
Expand Down
2 changes: 1 addition & 1 deletion pages/toggle_action_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="../commonjs/CoveoJsSearchExtensions.js"></script>
<script>
let attachedIds = [];
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
Coveo.SearchEndpoint.configureSampleEndpointV2();
Coveo.init(document.body, {});
});
Expand Down
8 changes: 4 additions & 4 deletions pages/user_actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
<script src="../js/CoveoJsSearch.Lazy.js"></script>
<script src="../commonjs/CoveoJsSearchExtensions.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
Coveo.SearchEndpoint.configureSampleEndpointV2();

const endpoint = Coveo.SearchEndpoint.endpoints['default'];

new Coveo.UserProfileModel(document.body, {
searchEndpoint: endpoint,
organizationId: 'searchuisamples',
restUri: ''
restUri: '',
});

Coveo.init(document.body, {
UserActions: {
userId: 'test'
}
userId: 'test',
},
});
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion scripts/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let fs = require('fs');
let basePath = './bin/css/';
let result = sass.renderSync({
file: './src/sass/Index.scss',
outFile: `${basePath}CoveoJsSearchExtensions.css`
outFile: `${basePath}CoveoJsSearchExtensions.css`,
});

if (!fs.existsSync(basePath)) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/dev.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ const compiler = webpack(webpackConfig);
var server = new WebpackDevServer(compiler, {
contentBase: ['bin/', 'node_modules/coveo-search-ui/bin/'],
publicPath: '/commonjs',
compress: true
compress: true,
});
server.listen(port, 'localhost', function() {});
server.listen(port, 'localhost', function () {});
9 changes: 6 additions & 3 deletions scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ const { ncp } = require('ncp');
const { resolve } = require('path');
const { mkdirSync, existsSync } = require('fs');

const folderToCopy = [{ src: resolve('./pages'), dest: resolve('./bin/pages') }, { src: resolve('./svg'), dest: resolve('./bin/img') }];
const folderToCopy = [
{ src: resolve('./pages'), dest: resolve('./bin/pages') },
{ src: resolve('./svg'), dest: resolve('./bin/img') },
];

if (!existsSync(resolve('./bin'))) {
mkdirSync(resolve('./bin'), { recursive: true });
}

folderToCopy.forEach(folder =>
ncp(folder.src, folder.dest, err => {
folderToCopy.forEach((folder) =>
ncp(folder.src, folder.dest, (err) => {
if (err) throw err;
})
);
Loading

0 comments on commit d6c403c

Please sign in to comment.