Skip to content

Commit

Permalink
feat: add support for axe-core@4.10.0 (#2696) (#2718)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Brush <steve.brush@blackbaud.com>
  • Loading branch information
johnhwhite and Blackbaud-SteveBrush committed Sep 10, 2024
1 parent 4e360ee commit 7221b5e
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libs/components/indicators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"@skyux-sdk/testing": "0.0.0-PLACEHOLDER",
"@skyux/core": "0.0.0-PLACEHOLDER",
"@skyux/help-inline": "0.0.0-PLACEHOLDER",
"@skyux/icon": "0.0.0-PLACEHOLDER",
"@skyux/i18n": "0.0.0-PLACEHOLDER",
"@skyux/icon": "0.0.0-PLACEHOLDER",
"@skyux/theme": "0.0.0-PLACEHOLDER"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"factory": "./update-11/ag-grid/ag-grid.schematic",
"description": "Apply code changes for AG Grid 32."
},
"axe-core": {
"version": "11.0.0",
"factory": "./update-11/axe-core/axe-core.schematic",
"description": "Update axe-core if @skyux-sdk/testing installed."
},
"forms": {
"version": "11.0.0",
"factory": "./update-11/forms/forms.schematic",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';

import { resolve } from 'path';

import { createTestLibrary } from '../../../testing/scaffold';

describe('axe-core.schematic', () => {
const runner = new SchematicTestRunner(
'migrations',
resolve(__dirname, '../../migration-collection.json'),
);

async function setupTest(options?: {
packageJson?: {
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
};
}) {
const tree = await createTestLibrary(runner, {
projectName: 'my-lib',
});

tree.overwrite('/package.json', JSON.stringify(options?.packageJson ?? {}));

return {
runSchematic: () => runner.runSchematic('axe-core', {}, tree),
tree,
};
}

beforeEach(() => {
jest.resetAllMocks();
});

it('should update axe-core version if @skyux-sdk/testing installed', async () => {
const { runSchematic, tree } = await setupTest({
packageJson: {
dependencies: {
'axe-core': '*',
},
devDependencies: {
'@skyux-sdk/testing': '*',
},
},
});

await runSchematic();

expect(JSON.parse(tree.readText('package.json'))).toEqual({
dependencies: {},
devDependencies: {
'@skyux-sdk/testing': '*',
'axe-core': '~4.10.0',
},
});
});

it('should abort if @skyux-sdk/testing not installed', async () => {
const { runSchematic, tree } = await setupTest({
packageJson: {
devDependencies: {
'axe-core': '*',
},
},
});

await runSchematic();

expect(JSON.parse(tree.readText('package.json'))).toEqual({
devDependencies: { 'axe-core': '*' },
});
});

it('should install axe-core if @skyux-sdk/testing installed without', async () => {
const { runSchematic, tree } = await setupTest({
packageJson: {
devDependencies: {
'@skyux-sdk/testing': '*',
},
},
});

await runSchematic();

expect(JSON.parse(tree.readText('package.json'))).toEqual({
devDependencies: {
'@skyux-sdk/testing': '*',
'axe-core': '~4.10.0',
},
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Rule } from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import {
NodeDependency,
NodeDependencyType,
addPackageJsonDependency,
getPackageJsonDependency,
removePackageJsonDependency,
} from '@schematics/angular/utility/dependencies';

const AXE_CORE_PACKAGE = 'axe-core';
const AXE_CORE_VERSION = '~4.10.0';

/**
* Sets axe-core to ~4.10.0. We can't put this in the ng-update.packageGroup
* because we only want to update a customer's axe-core version if they've
* installed @skyux-sdk/testing.
*/
export default function updateAxeCore(): Rule {
return (tree, context) => {
if (getPackageJsonDependency(tree, '@skyux-sdk/testing') !== null) {
const axeCore: NodeDependency = {
name: AXE_CORE_PACKAGE,
version: AXE_CORE_VERSION,
type: NodeDependencyType.Dev,
overwrite: true,
};

const packageJsonPath = '/package.json';

removePackageJsonDependency(tree, AXE_CORE_PACKAGE, packageJsonPath);
addPackageJsonDependency(tree, axeCore, packageJsonPath);
}

context.addTask(new NodePackageInstallTask());
};
}
2 changes: 1 addition & 1 deletion libs/sdk/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@angular/core": "^18.2.3",
"@angular/platform-browser": "^18.2.3",
"@skyux/i18n": "0.0.0-PLACEHOLDER",
"axe-core": "^3.5.6 || ~4.6.3 || ~4.7.2 || ~4.9.1"
"axe-core": "^3.5.6 || ~4.6.3 || ~4.7.2 || ~4.10"
},
"dependencies": {
"tslib": "^2.6.3"
Expand Down
8 changes: 4 additions & 4 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 @@ -104,7 +104,7 @@
"ag-grid-angular": "32.1.0",
"ag-grid-community": "32.1.0",
"autonumeric": "4.10.5",
"axe-core": "4.9.1",
"axe-core": "4.10.0",
"comment-json": "4.2.4",
"dom-autoscroller": "2.3.4",
"dompurify": "3.1.6",
Expand Down

0 comments on commit 7221b5e

Please sign in to comment.