Skip to content

Commit

Permalink
Generation of custom-element manifest (#3886)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesDoberer authored Nov 8, 2024
1 parent 19768c5 commit 57b6118
Show file tree
Hide file tree
Showing 43 changed files with 1,576 additions and 1,267 deletions.
10 changes: 5 additions & 5 deletions client/src/linkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ export class linkManager extends LuigiClientBase {
const currentId = helpers.getRandomId();
const pathExistsPromises = this.getPromise('pathExistsPromises') || {};
pathExistsPromises[currentId] = {
resolveFn: function() {},
then: function(resolveFn) {
resolveFn: function () {},
then: function (resolveFn) {
this.resolveFn = resolveFn;
}
};
Expand All @@ -393,7 +393,7 @@ export class linkManager extends LuigiClientBase {
// register event listener, which will be cleaned up after this usage
helpers.addEventListener(
'luigi.navigation.pathExists.answer',
function(e, listenerId) {
function (e, listenerId) {
const data = e.data.data;
const pathExistsPromises = this.getPromise('pathExistsPromises') || {};
if (data.correlationId === currentId) {
Expand Down Expand Up @@ -499,8 +499,8 @@ export class linkManager extends LuigiClientBase {

const currentRoutePromise = this.getPromise('getCurrentRoute') || {};
currentRoutePromise[currentId] = {
resolveFn: function() {},
then: function(resolveFn) {
resolveFn: function () {},
then: function (resolveFn) {
this.resolveFn = resolveFn;
}
};
Expand Down
8 changes: 4 additions & 4 deletions client/src/uxManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UxManager extends LuigiClientBase {
/** @private */
constructor() {
super();
helpers.addEventListener('luigi.current-locale-changed', e => {
helpers.addEventListener('luigi.current-locale-changed', (e) => {
if (e.data.currentLocale && lifecycleManager.currentContext?.internal) {
lifecycleManager.currentContext.internal.currentLocale = e.data.currentLocale;
lifecycleManager._notifyUpdate();
Expand Down Expand Up @@ -183,7 +183,7 @@ class UxManager extends LuigiClientBase {

const alertPromises = this.getPromise('alerts') || {};
alertPromises[settings.id] = {};
alertPromises[settings.id].promise = new Promise(resolve => {
alertPromises[settings.id].promise = new Promise((resolve) => {
alertPromises[settings.id].resolveFn = resolve;
});
this.setPromise('alerts', alertPromises);
Expand Down Expand Up @@ -297,13 +297,13 @@ class UxManager extends LuigiClientBase {
* @example LuigiClient.uxManager().applyCSS();
*/
applyCSS() {
document.querySelectorAll('head style[luigi-injected]').forEach(luigiInjectedStyleTag => {
document.querySelectorAll('head style[luigi-injected]').forEach((luigiInjectedStyleTag) => {
luigiInjectedStyleTag.remove();
});
const vars = lifecycleManager.currentContext?.internal?.cssVariables;
if (vars) {
let cssString = ':root {\n';
Object.keys(vars).forEach(key => {
Object.keys(vars).forEach((key) => {
const val = vars[key];
cssString += (key.startsWith('--') ? '' : '--') + key + ':' + val + ';\n';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ describe('Compound Container Tests', () => {
});

it('LuigiClient API - getSkipInitCheck', () => {
cy.get(containerSelector)
.invoke('attr', 'skip-init-check')
.should('eq', 'true');
cy.get(containerSelector).invoke('attr', 'skip-init-check').should('eq', 'true');
});

it('LuigiClient API - getActiveFeatureToggles', () => {
Expand Down Expand Up @@ -188,7 +186,7 @@ describe('Compound Container Tests', () => {
.contains('showConfirmationModal')
.click()
.then(() => {
cy.on('window:confirm', str => {
cy.on('window:confirm', (str) => {
expect(str).to.equal('Are you sure you want to do this?');
});
expect(stub.getCall(0)).to.be.calledWith('LuigiClient.uxManager().showConfirmationModal()');
Expand Down Expand Up @@ -255,7 +253,7 @@ describe('Compound Container Tests', () => {
cy.on('window:alert', stub);

// Set up a spy on console.log
cy.window().then(win => {
cy.window().then((win) => {
cy.spy(win.console, 'log').as('consoleLogSpy');
});

Expand Down
62 changes: 26 additions & 36 deletions container/cypress/e2e/test-app/iframe/iframe-container.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ describe('Iframe Container Test', () => {
cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.contains('test navigate')
.click();
cy.wrap($body).contains('test navigate').click();

cy.location().should(loc => {
cy.location().should((loc) => {
expect(loc.href).to.eq('http://localhost:8080/');
});
});
Expand All @@ -41,11 +39,9 @@ describe('Iframe Container Test', () => {
cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.find('#content')
.should('have.text', 'Received Custom Message: some data');
cy.wrap($body).find('#content').should('have.text', 'Received Custom Message: some data');
});
});

Expand All @@ -55,7 +51,7 @@ describe('Iframe Container Test', () => {
cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.contains('test custom message')
Expand All @@ -78,7 +74,7 @@ describe('Iframe Container Test', () => {
cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');

cy.wrap($body)
Expand All @@ -102,7 +98,7 @@ describe('Iframe Container Test', () => {
cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.contains('test get token')
Expand All @@ -117,54 +113,48 @@ describe('Iframe Container Test', () => {
});

it('openAsModal', () => {
cy.on('window:confirm', () => false);
cy.on('window:confirm', () => false);

cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.contains('test openAsModal()')
.click();

cy.location().should(loc => {
cy.wrap($body).contains('test openAsModal()').click();

cy.location().should((loc) => {
expect(loc.hash).to.eq('#openAsModal-iframe');
});
});
});

it('openAsDrawer', () => {
cy.on('window:confirm', () => false);
cy.on('window:confirm', () => false);

cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.contains('test openAsDrawer')
.click();

cy.location().should(loc => {
cy.wrap($body).contains('test openAsDrawer').click();

cy.location().should((loc) => {
expect(loc.hash).to.eq('#openAsDrawer-iframe');
});
});
});

it('openAsSplitview', () => {
cy.on('window:confirm', () => false);
cy.on('window:confirm', () => false);

cy.get(containerSelector)
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.contains('test openAsSplitview')
.click();

cy.location().should(loc => {
cy.wrap($body).contains('test openAsSplitview').click();

cy.location().should((loc) => {
expect(loc.hash).to.eq('#openAsSplitview-iframe');
});
});
Expand Down
4 changes: 1 addition & 3 deletions container/cypress/e2e/test-app/iframe/iframe-cookies.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ describe('Iframe Cookies Test', () => {
it('should not sent third party cookies request', () => {
cy.on('window:alert', stub);

cy.get(containerSelector)
.should('have.attr', 'skip-cookie-check')
.and('match', /true/);
cy.get(containerSelector).should('have.attr', 'skip-cookie-check').and('match', /true/);
cy.get(containerSelector)
.shadow()
.get('iframe')
Expand Down
30 changes: 10 additions & 20 deletions container/cypress/e2e/test-app/iframe/iframe-settings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Iframe Settings Test', () => {
});

it('defer-init flag for iframe container', () => {
cy.get('#defer-init-test').then(iframe => {
cy.get('#defer-init-test').then((iframe) => {
const $body = iframe.contents().find('main');
expect($body.children()).to.have.length(0);

Expand All @@ -17,11 +17,9 @@ describe('Iframe Settings Test', () => {
cy.get('#defer-init-test')
.shadow()
.get('iframe')
.then(iframe => {
.then((iframe) => {
const $body = iframe.contents().find('body');
cy.wrap($body)
.contains('defer-init test for iframes')
.should('exist');
cy.wrap($body).contains('defer-init test for iframes').should('exist');
});
});
});
Expand All @@ -33,21 +31,17 @@ describe('Iframe Settings Test', () => {
cy.get('#defer-init-test')
.shadow()
.get('iframe')
.then(elements => {
cy.get(elements.first())
.invoke('attr', 'sandbox')
.should('eq', 'allow-modals allow-popups');
.then((elements) => {
cy.get(elements.first()).invoke('attr', 'sandbox').should('eq', 'allow-modals allow-popups');
});
});

it('set sandbox rules by attribute', () => {
cy.get('#sandbox-rules-test')
.shadow()
.find('iframe')
.then(elements => {
cy.get(elements.last())
.invoke('attr', 'sandbox')
.should('eq', 'allow-scripts allow-same-origin');
.then((elements) => {
cy.get(elements.last()).invoke('attr', 'sandbox').should('eq', 'allow-scripts allow-same-origin');
});
});

Expand Down Expand Up @@ -76,15 +70,11 @@ describe('Iframe Settings Test', () => {
it('should initialize Luigi Client', () => {
cy.get('iframe').then(($iframe) => {
const iframeBody = $iframe.contents().find('body');

const checkLuigiClientStatus = (expectedStatus) => {
cy.wrap(iframeBody)
.find('#luigiClientStatus')
.should('exist')
.invoke('text')
.should('eq', expectedStatus);
cy.wrap(iframeBody).find('#luigiClientStatus').should('exist').invoke('text').should('eq', expectedStatus);
};

checkLuigiClientStatus('Luigi Client Initialized: Unknown');
cy.wait(2000);
checkLuigiClientStatus('Luigi Client Initialized: true');
Expand Down
7 changes: 2 additions & 5 deletions container/cypress/e2e/test-app/wc/wc-container.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ describe('Web Container Test', () => {
});

it('sendCustomMessage', () => {
cy.get(containerSelector)
.shadow()
.find('#customMessageDiv')
.should('have.text', 'Received Custom Message: ');
cy.get(containerSelector).shadow().find('#customMessageDiv').should('have.text', 'Received Custom Message: ');

cy.get('#sendCustomMessageBtn').click();
cy.get(containerSelector)
Expand Down Expand Up @@ -214,7 +211,7 @@ describe('Web Container Test', () => {
.contains('showConfirmationModal')
.click()
.then(() => {
cy.on('window:confirm', str => {
cy.on('window:confirm', (str) => {
expect(str).to.equal('Are you sure you want to do this?');
});
expect(stub.getCall(0)).to.be.calledWith('LuigiClient.uxManager().showConfirmationModal()');
Expand Down
Loading

0 comments on commit 57b6118

Please sign in to comment.