Skip to content

Commit

Permalink
Add compound container tests (#3857)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndricimrr authored Aug 22, 2024
1 parent dd74a31 commit 69a2f8d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Compound Container Tests', () => {
stub = cy.stub();
});

it('LuigiClient API getUserSettings for LuigiCompoundContainer', () => {
it('LuigiClient API - getUserSettings', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
Expand All @@ -20,7 +20,7 @@ describe('Compound Container Tests', () => {
});
});

it('LuigiClient API getAnchor for LuigiCompoundContainer', () => {
it('LuigiClient API - getAnchor', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
Expand All @@ -32,6 +32,79 @@ describe('Compound Container Tests', () => {
});
});

it('LuigiClient API - getDirtyStatus', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
.shadow()
.contains('getDirtyStatus')
.click()
.then(() => {
expect(stub.getCall(0)).to.be.calledWith('LuigiClient.uxManager().getDirtyStatus()=false');
});
});

it('LuigiClient API - getClientPermissions', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
.shadow()
.contains('getClientPermissions')
.click()
.then(() => {
expect(stub.getCall(0)).to.be.calledWith('{"permission":"testPermission"}');
});
});

it('LuigiClient API - getNodeParams', () => {
cy.on('window:alert', stub);

// getNodeParams is not available for compound children, so default behavior should be to return empty {}
cy.get(containerSelector)
.shadow()
.contains('get node params')
.click()
.then(() => {
expect(stub.getCall(0)).to.be.calledWith('LuigiClient.getNodeParams()={}');
});
});

it('LuigiClient API - getPathParams', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
.shadow()
.contains('getPathParams')
.click()
.then(() => {
expect(stub.getCall(0)).to.be.calledWith('{"path":"param"}');
});
});

it('LuigiClient API - setViewGroupData', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
.shadow()
.contains('setViewGroupData')
.click()
.then(() => {
expect(stub.getCall(0)).to.be.calledWith('{"vg":"some data"}');
});
});

it('LuigiClient API - getCoreSearchParams', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
.shadow()
.contains('getCoreSearchParams')
.click()
.then(() => {
expect(stub.getCall(0)).to.be.calledWith('{"test":"searchParam1"}');
});
});

it('LuigiClient API updateContext', () => {
cy.on('window:alert', stub);

Expand All @@ -41,10 +114,12 @@ describe('Compound Container Tests', () => {
.then(() => {
cy.get(containerSelector)
.shadow()
.contains('updateContext')
.contains('retrieveContextValue')
.click()
.then(() => {
expect(stub.getCall(0)).to.be.calledWith('compoundWC.ctx={"label":"Dashboard","title":"Some input","instant":true,"newContextData":"some data"}');
expect(stub.getCall(0)).to.be.calledWith(
'compoundWC.ctx={"label":"Dashboard","title":"Some input","instant":true,"newContextData":"some data"}'
);
});
});
});
Expand Down
1 change: 1 addition & 0 deletions container/test-app/compound/compoundClientAPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ <h3>
// setViewGroup Data listener
compoundContainer.addEventListener(MFEventID.SET_VIEW_GROUP_DATA_REQUEST, event => {
console.log('Set View Group Data Request received', event.detail, event);
alert(JSON.stringify(event.detail));
});

const deferInitContainer = document.getElementById('defer-init-test');
Expand Down
10 changes: 5 additions & 5 deletions container/test-app/compound/helloWorldWC.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default class extends HTMLElement {
const getDirtyStatusBtn = document.createElement('template');
getDirtyStatusBtn.innerHTML = '<button id="getDirtyStatus">getDirtyStatus</button>';

const updateContextBtn = document.createElement('template');
updateContextBtn.innerHTML = '<button id="updateContext">updateContext</button>';
const retrieveContextValueBtn = document.createElement('template');
retrieveContextValueBtn.innerHTML = '<button id="retrieveContextValue">retrieveContextValue</button>';

const uxManagerMultipleRequestsBtn = document.createElement('template');
uxManagerMultipleRequestsBtn.innerHTML = `<button id="uxManagerManyRequests">uxManager().closeUserSettings,
Expand Down Expand Up @@ -98,7 +98,7 @@ export default class extends HTMLElement {
this._shadowRoot.appendChild(getUserSettingsBtn.content.cloneNode(true));
this._shadowRoot.appendChild(getAnchorBtn.content.cloneNode(true));
this._shadowRoot.appendChild(getDirtyStatusBtn.content.cloneNode(true));
this._shadowRoot.appendChild(updateContextBtn.content.cloneNode(true));
this._shadowRoot.appendChild(retrieveContextValueBtn.content.cloneNode(true));
this._shadowRoot.appendChild(uxManagerMultipleRequestsBtn.content.cloneNode(true));
this._shadowRoot.appendChild(linkManagerChainedFunctionsRequestsBtn.content.cloneNode(true));
this._shadowRoot.appendChild(linkManagerOpenAsRequestsBtn.content.cloneNode(true));
Expand Down Expand Up @@ -207,8 +207,8 @@ export default class extends HTMLElement {
});
});

this.$updateContextBtn = this._shadowRoot.querySelector('#updateContext');
this.$updateContextBtn.addEventListener('click', () => {
this.$retrieveContextValueBtn = this._shadowRoot.querySelector('#retrieveContextValue');
this.$retrieveContextValueBtn.addEventListener('click', () => {
this.LuigiClient.uxManager().showAlert({
text: `compoundWC.ctx=${JSON.stringify(this.ctx)}`,
type: 'info'
Expand Down

0 comments on commit 69a2f8d

Please sign in to comment.