Skip to content

Commit 1fc79ef

Browse files
Merge pull request #15649 from yapei/CONSOLE-4853
CONSOLE-4853: merge dynamic plugin tests
2 parents 4988f06 + 200fe08 commit 1fc79ef

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

dynamic-demo-plugin/locales/en/plugin__console-demo-plugin.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
"OpenShift Pods List Page": "OpenShift Pods List Page",
4242
"Create Pod": "Create Pod",
4343
"Sample ResourceIcon": "Sample ResourceIcon",
44+
"An error occurred. Please try again.": "An error occurred. Please try again.",
45+
"Create Project": "Create Project",
46+
"This modal is created with an extension.": "This modal is created with an extension.",
47+
"Display name": "Display name",
48+
"Description": "Description",
49+
"An error occurred.": "An error occurred.",
50+
"Create": "Create",
51+
"Cancel": "Cancel",
52+
"ProjectRequest": "ProjectRequest",
53+
"ProjectRequests": "ProjectRequests",
4454
"Storage Classes": "Storage Classes",
4555
"StorageClasses present in this cluster:": "StorageClasses present in this cluster:",
4656
"Component is resolving": "Component is resolving",

dynamic-demo-plugin/src/components/Modals/CreateProjectModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { k8sCreate, ModalComponent } from '@openshift-console/dynamic-plugin-sdk
1919
import { K8sModel } from '@openshift-console/dynamic-plugin-sdk/lib/api/common-types';
2020

2121
const CreateProjectModal: ModalComponent = ({ closeModal }) => {
22-
const { t } = useTranslation('plugin__console-plugin-template');
22+
const { t } = useTranslation('plugin__console-demo-plugin');
2323
const [name, setName] = React.useState<string>('');
2424
const [displayName, setDisplayName] = React.useState('');
2525
const [description, setDescription] = React.useState('');

frontend/packages/integration-tests-cypress/tests/app/demo-dynamic-plugin.cy.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { isLocalDevEnvironment } from '../../views/common';
44
import { detailsPage } from '../../views/details-page';
55
import { guidedTour } from '../../views/guided-tour';
66
import { listPage } from '../../views/list-page';
7+
import { masthead } from '../../views/masthead';
78
import { modal } from '../../views/modal';
89
import { nav } from '../../views/nav';
910
import { getEditorContent } from '../../views/yaml-editor';
@@ -185,6 +186,35 @@ if (!Cypress.env('OPENSHIFT_CI') || Cypress.env('PLUGIN_PULL_SPEC')) {
185186
apiIDs.forEach((id) => k8sAPINavTest(id));
186187
});
187188

189+
it('add Dynamic Plugins to Cluster Overview Status card', () => {
190+
nav.sidenav.clickNavLink(['Home', 'Overview']);
191+
cy.get('button[data-test="Dynamic Plugins"]').click();
192+
cy.contains('Loaded plugins').should('exist');
193+
cy.get('.pf-v6-c-popover').within(() => {
194+
cy.get('a:contains(View all)').should(
195+
'have.attr',
196+
'href',
197+
'/k8s/cluster/operator.openshift.io~v1~Console/cluster/console-plugins',
198+
);
199+
});
200+
});
201+
202+
it('add Dynamic Plugins in About modal', () => {
203+
masthead.clickMastheadLink('help-dropdown-toggle');
204+
cy.get('span').contains('About').click();
205+
cy.get('dt').contains('Dynamic plugins').should('exist');
206+
cy.contains('console-demo-plugin (0.0.0)').should('exist');
207+
cy.get('button[aria-label="Close Dialog"]').click();
208+
});
209+
210+
it('add extension point to enable customized create project modal', () => {
211+
nav.sidenav.clickNavLink(['Home', 'Projects']);
212+
listPage.dvRows.shouldBeLoaded();
213+
listPage.clickCreateYAMLbutton();
214+
cy.get('div').contains('This modal is created with an extension').should('exist');
215+
cy.byButtonText('Cancel').click();
216+
});
217+
188218
it('should display manifest tab in ConsolePlugin details page', () => {
189219
// Navigate to the demo plugin details page
190220
cy.visit(`/k8s/cluster/console.openshift.io~v1~ConsolePlugin/${PLUGIN_NAME}`);
@@ -241,6 +271,39 @@ if (!Cypress.env('OPENSHIFT_CI') || Cypress.env('PLUGIN_PULL_SPEC')) {
241271
}
242272
});
243273
});
274+
275+
it('console plugin proxy should directly copy the plugin service proxy response status code', () => {
276+
if (!isLocalDevEnvironment) {
277+
let pluginStatusCode;
278+
cy.exec(`oc -n console-demo-plugin create route passthrough --service console-demo-plugin`);
279+
cy.exec(
280+
`oc get route console-demo-plugin -n console-demo-plugin -o jsonpath='{.spec.host}'`,
281+
).then((result) => {
282+
const consoleDemoPluginHost = result.stdout;
283+
cy.request(`https://${consoleDemoPluginHost}/plugin-manifest.json`).then((resp) => {
284+
pluginStatusCode = resp.status;
285+
});
286+
});
287+
cy.request('/api/plugins/console-demo-plugin/plugin-manifest.json').then((resp) => {
288+
expect(resp.status).to.eq(pluginStatusCode);
289+
});
290+
}
291+
});
292+
293+
it('allow disabling dynamic plugins through a query parameter', () => {
294+
// disable non-existing plugin will make no changes
295+
cy.visit('?disable-plugins=foo,bar');
296+
cy.byTestID('nav').as('dynamic_nav').should('include.text', 'Dynamic Nav');
297+
298+
// disable one plugin
299+
cy.visit('?disable-plugins=console-demo-plugin');
300+
cy.get('@dynamic_nav').should('not.have.text', 'Dynamic Nav');
301+
302+
// disable all plugins
303+
cy.visit('?disable-plugins');
304+
cy.get('@dynamic_nav').should('not.have.text', 'Dynamic Nav');
305+
cy.visit('/api-explorer');
306+
});
244307
});
245308
} else {
246309
xdescribe('Skipping demo dynamic plugin tests', () => {

0 commit comments

Comments
 (0)