Skip to content

Commit

Permalink
chore: add Cypress & test folders as ESLint checks (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jul 6, 2024
1 parent b342b06 commit 88d19c0
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.eslintcache
node_modules
jspm_packages
bower_components
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.chrome
.circleci
.env
.eslintcache
.github
.idea
.vscode
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default tseslint.config(
},
parser: tseslint.parser,
parserOptions: {
project: ['./tsconfig.json']
project: ['./tsconfig.json', './test/tsconfig.spec.json', './test/cypress/tsconfig.json']
}
},
settings: {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dev": "pnpm -r --stream --parallel dev",
"cypress:open": "cypress open --config-file test/cypress.config.ts",
"cypress:ci": "cypress run --config-file test/cypress.config.ts",
"lint": "eslint packages",
"lint": "eslint --cache .",
"preview:publish": "lerna publish from-package --dry-run --yes",
"preview:version": "lerna version --dry-run --yes",
"test:ci": "jest --runInBand --coverage=true --ci --config ./test/jest.config.ts",
Expand All @@ -41,12 +41,14 @@
"devDependencies": {
"@4tw/cypress-drag-drop": "^2.2.5",
"@aurelia/fetch-client": "^2.0.0-beta.19",
"@aurelia/i18n": "^2.0.0-beta.19",
"@aurelia/platform": "^2.0.0-beta.19",
"@aurelia/platform-browser": "^2.0.0-beta.19",
"@formkit/tempo": "^0.1.2",
"@jest/types": "^29.6.3",
"@lerna-lite/cli": "^3.7.0",
"@lerna-lite/publish": "^3.7.0",
"@slickgrid-universal/common": "^5.3.3",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.10",
"conventional-changelog-conventionalcommits": "^7.0.2",
Expand All @@ -68,6 +70,7 @@
"npm-run-all2": "^6.2.2",
"pnpm": "^8.15.8",
"rimraf": "^5.0.7",
"rxjs": "^7.8.1",
"ts-jest": "^29.1.5",
"typescript": "^5.5.3",
"typescript-eslint": "^7.15.0"
Expand Down
25 changes: 9 additions & 16 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion test/containerServiceStub.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContainerInstance, ContainerService } from '@slickgrid-universal/common';
import type { ContainerInstance, ContainerService } from '@slickgrid-universal/common';

export class ContainerServiceStub implements ContainerService {
dependencies: ContainerInstance[] = [];
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/example13.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Example 13 - Grouping & Aggregators', () => {
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 2}px;"].slick-group-level-2 .slick-group-toggle.collapsed`).should('have.length', 1);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 2}px;"].slick-group-level-2 .slick-group-title`).contains(/^% Complete: [0-9]/);

cy.get(`[style="top: ${GRID_ROW_HEIGHT * 3}px;"].slick-group-totals.slick-group-level-2 .slick-cell:nth(3)`).contains(/^Avg: [0-9]\%$/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 3}px;"].slick-group-totals.slick-group-level-2 .slick-cell:nth(3)`).contains(/^Avg: [0-9]%$/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 3}px;"].slick-group-totals.slick-group-level-2`)
.find('.slick-cell:nth(3)').contains('Avg: ');
});
Expand Down
4 changes: 2 additions & 2 deletions test/cypress/e2e/example30.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ describe('Example 30 Composite Editor Modal', () => {

cy.get('.btn-save')
.click()
.then(() => expect(alertStub.getCall(0)).to.be.calledWith('Sorry we could not detect any changes.'))
.then(() => expect(alertStub.getCall(0)).to.be.calledWith('Sorry we could not detect any changes.'));

cy.get('.btn-cancel')
.click()
.click();
});

it('should have the "Mass Selection" button disabled when no rows are selected', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/example33.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('Example 33 - Regular & Custom Tooltips', () => {
cy.get('@percentage-cell').trigger('mouseover');

cy.get('.slick-custom-tooltip').should('be.visible');
cy.get('.slick-custom-tooltip').contains(/\d+\%$/);
cy.get('.slick-custom-tooltip').contains(/\d+%$/);

cy.get('@percentage-cell').trigger('mouseout');
});
Expand Down
10 changes: 5 additions & 5 deletions test/cypress/e2e/example34.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ describe('Example 34 - Real-Time Trading Platform', () => {
for (let i = 0; i < 5; i++) {
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(0)`).contains(/CAD|USD$/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(4)`).contains(/Buy|Sell$/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(5)`).contains(/\$\(?[0-9\.]*\)?/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(6)`).contains(/\$[0-9\.]*/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(5)`).contains(/\$\(?[0-9.]*\)?/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(6)`).contains(/\$[0-9.]*/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(7)`).contains(/\d$/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(8)`).contains(/\$[0-9\.]*/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * i}px;"] > .slick-cell:nth(8)`).contains(/\$[0-9.]*/);
}
});

Expand Down Expand Up @@ -54,10 +54,10 @@ describe('Example 34 - Real-Time Trading Platform', () => {

cy.get(`[style="top: ${GRID_ROW_HEIGHT * 0}px;"] > .slick-cell:nth(0) .slick-group-toggle.collapsed`).should('have.length', 1);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 0}px;"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Currency: CAD');
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 1}px;"] > .slick-cell:nth(8)`).contains(/\$[0-9\,\.]*/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 1}px;"] > .slick-cell:nth(8)`).contains(/\$[0-9,.]*/);

cy.get(`[style="top: ${GRID_ROW_HEIGHT * 2}px;"] > .slick-cell:nth(0) .slick-group-toggle.collapsed`).should('have.length', 1);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 2}px;"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Currency: USD');
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 3}px;"] > .slick-cell:nth(8)`).contains(/\$[0-9\,\.]*/);
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 3}px;"] > .slick-cell:nth(8)`).contains(/\$[0-9,.]*/);
});
});
1 change: 0 additions & 1 deletion test/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default (_on: any, _config: any) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
Expand Down
10 changes: 5 additions & 5 deletions test/jest-global-mocks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const mock = () => {
let storage = {};
let storage: any = {};
return {
getItem: key => key in storage ? storage[key] : null,
setItem: (key, value) => storage[key] = value || '',
removeItem: key => delete storage[key],
getItem: (key: string) => key in storage ? storage[key] : null,
setItem: (key: string, value: number | string) => storage[key] = value || '',
removeItem: (key: string) => delete storage[key],
clear: () => storage = {},
};
};
Expand All @@ -18,7 +18,7 @@ Object.defineProperty(window, '__env', { value: { env: { backendUrl: 'mocked URL

Object.defineProperty(window, 'getComputedStyle', {
value: () => ({
getPropertyValue: (prop) => {
getPropertyValue: () => {
return '';
}
})
Expand Down
2 changes: 1 addition & 1 deletion test/mockSlickEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handler, SlickEvent, SlickEventData } from '@slickgrid-universal/common';
import type { Handler, SlickEvent, SlickEventData } from '@slickgrid-universal/common';
type MergeTypes<A, B> = { [key in keyof A]: key extends keyof B ? B[key] : A[key]; } & B;

// @ts-ignore
Expand Down
5 changes: 3 additions & 2 deletions test/rxjsResourceStub.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { RxJsFacade } from '@slickgrid-universal/common';
import type { RxJsFacade } from '@slickgrid-universal/common';
import { EMPTY, iif, isObservable, firstValueFrom, Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

// @ts-ignore
export class RxJsResourceStub implements RxJsFacade {
readonly className = 'RxJsResource';

Expand Down Expand Up @@ -45,4 +46,4 @@ export class RxJsResourceStub implements RxJsFacade {
takeUntil<T>(notifier: Observable<any>): any {
return takeUntil<T>(notifier);
}
}
}
4 changes: 2 additions & 2 deletions test/translaterServiceStub.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TranslaterService, TranslateServiceEventName } from '@slickgrid-universal/common';
import { I18N } from '@aurelia/i18n';
import type { TranslaterService, TranslateServiceEventName } from '@slickgrid-universal/common';
import type { I18N } from '@aurelia/i18n';

export class TranslaterServiceStub implements TranslaterService {
eventName = 'onLanguageChange' as TranslateServiceEventName;
Expand Down

0 comments on commit 88d19c0

Please sign in to comment.