Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 34 additions & 1 deletion ui/apps/platform/cypress/integration-ocp/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import { visitFromConsoleLeftNavExpandable } from '../helpers/nav';
import { withOcpAuth } from '../helpers/ocpAuth';

describe('Basic connectivity to the OCP plugin', () => {
describe('Basic tests of the OCP plugin', () => {
it('should open the OCP web console', () => {
withOcpAuth();

cy.visit('/');

cy.get('h1:contains("Overview")');
});

describe('Plugin version', () => {
beforeEach(() => {
withOcpAuth();
});

it('should display correct plugin version in the plugin manifest', () => {
// The plugin manifest is served at the basePath configured in the ConsolePlugin resource
// which is /api/plugins/<plugin-name>/plugin-manifest.json
cy.request('/api/plugins/advanced-cluster-security/plugin-manifest.json').then(
(response) => {
expect(response.status).to.equal(200);
expect(response.body).to.have.property('name', 'advanced-cluster-security');
expect(response.body).to.have.property('version');

expect(response.body.version).to.match(/^[1-9]\d*\.\d+\.\d+/);
}
);
});

it('should display plugin information in cluster settings', () => {
visitFromConsoleLeftNavExpandable('Administration', 'Dynamic Plugins');

cy.get('td[data-label="name"]:contains("advanced-cluster-security")')
Comment thread
dvail marked this conversation as resolved.
.parent()
.within(() => {
cy.get('td[data-label="version"]')
.invoke('text')
.should('match', /^[1-9]\d*\.\d+\.\d+/);
});
});
});
});
25 changes: 24 additions & 1 deletion ui/apps/platform/webpack.ocp-plugin.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const fs = require('fs');
const { execSync } = require('child_process');
const { DefinePlugin } = require('webpack');
const { ConsoleRemotePlugin } = require('@openshift-console/dynamic-plugin-sdk-webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
Expand All @@ -8,6 +9,28 @@ const acsRootBaseUrl = '/acs';

const isProd = process.env.NODE_ENV === 'production';

/*
* Get the product version from the make tag command and convert it to valid semver format
* e.g., "4.11.x-363-gbff801aa00-dirty" -> "4.11.0-363-gbff801aa00-dirty"
* Note: replacing the .x with .0 is acceptable, as development will almost always be done
* against the upcoming '0' z-stream.
*
* Production builds will get a clean x.y.z version instead
*/
function getProductVersion() {
const repositoryRoot = path.resolve(__dirname, '../../..');
const rawVersion = execSync('make --no-print-directory tag', {
cwd: repositoryRoot,
encoding: 'utf-8',
}).trim();
const version = rawVersion.replace(/\.x/, '.0');

// eslint-disable-next-line no-console
console.warn(`Product version: ${version}`);

return version;
}

/*
* Alias all top level directories and files under `/src/` so that we can import them in our code
* via `import { SomeComponent } from 'Components/SomeComponent`;`. This mirrors the Vite configuration approach.
Expand Down Expand Up @@ -96,7 +119,7 @@ const config = {
validateSharedModules: false,
pluginMetadata: {
name: 'advanced-cluster-security',
version: '0.0.1',
Comment thread
dvail marked this conversation as resolved.
version: getProductVersion(),
displayName: 'Red Hat Advanced Cluster Security for OpenShift',
description: 'OCP Console Plugin for Advanced Cluster Security',
exposedModules: {
Expand Down
Loading