From 2d930ff2584477b3c7ecda22110ae021db1a7767 Mon Sep 17 00:00:00 2001 From: romangraef Date: Thu, 12 Aug 2021 23:08:49 +0000 Subject: Automated deployment: Thu Aug 12 23:08:49 UTC 2021 62d3fcb7500e623b8c4a1b79c2e271121c3ce794 --- 2/plugins/behaviors/index.js | 178 ++++++++++++++++++++++++++++++++++ 2/plugins/packages/index.js | 104 ++++++++++++++++++++ 2/plugins/screen-diff/index.js | 200 +++++++++++++++++++++++++++++++++++++++ 2/plugins/screen-diff/styles.css | 30 ++++++ 4 files changed, 512 insertions(+) create mode 100644 2/plugins/behaviors/index.js create mode 100644 2/plugins/packages/index.js create mode 100644 2/plugins/screen-diff/index.js create mode 100644 2/plugins/screen-diff/styles.css (limited to '2/plugins') diff --git a/2/plugins/behaviors/index.js b/2/plugins/behaviors/index.js new file mode 100644 index 0000000..ecde54e --- /dev/null +++ b/2/plugins/behaviors/index.js @@ -0,0 +1,178 @@ +'use strict'; + +allure.api.addTranslation('en', { + tab: { + behaviors: { + name: 'Behaviors' + } + }, + widget: { + behaviors: { + name: 'Features by stories', + showAll: 'show all' + } + } +}); + +allure.api.addTranslation('ru', { + tab: { + behaviors: { + name: 'Функциональность' + } + }, + widget: { + behaviors: { + name: 'Функциональность', + showAll: 'показать все' + } + } +}); + +allure.api.addTranslation('zh', { + tab: { + behaviors: { + name: '功能' + } + }, + widget: { + behaviors: { + name: '特性场景', + showAll: '显示所有' + } + } +}); + +allure.api.addTranslation('de', { + tab: { + behaviors: { + name: 'Verhalten' + } + }, + widget: { + behaviors: { + name: 'Features nach Stories', + showAll: 'Zeige alle' + } + } +}); + +allure.api.addTranslation('nl', { + tab: { + behaviors: { + name: 'Functionaliteit' + } + }, + widget: { + behaviors: { + name: 'Features en story’s', + showAll: 'Toon alle' + } + } +}); + +allure.api.addTranslation('he', { + tab: { + behaviors: { + name: 'התנהגויות' + } + }, + widget: { + behaviors: { + name: 'תכונות לפי סיפורי משתמש', + showAll: 'הצג הכול' + } + } +}); + +allure.api.addTranslation('br', { + tab: { + behaviors: { + name: 'Comportamentos' + } + }, + widget: { + behaviors: { + name: 'Funcionalidades por história', + showAll: 'Mostrar tudo' + } + } +}); + +allure.api.addTranslation('ja', { + tab: { + behaviors: { + name: '振る舞い' + } + }, + widget: { + behaviors: { + name: 'ストーリー別の機能', + showAll: '全て表示' + } + } +}); + +allure.api.addTranslation('es', { + tab: { + behaviors: { + name: 'Funcionalidades' + } + }, + widget: { + behaviors: { + name: 'Funcionalidades por Historias de Usuario', + showAll: 'mostrar todo' + } + } +}); + +allure.api.addTranslation('kr', { + tab: { + behaviors: { + name: '동작' + } + }, + widget: { + behaviors: { + name: '스토리별 기능', + showAll: '전체 보기' + } + } +}); + +allure.api.addTranslation('fr', { + tab: { + behaviors: { + name: 'Comportements' + } + }, + widget: { + behaviors: { + name: 'Thèmes par histoires', + showAll: 'Montrer tout' + } + } +}); + +allure.api.addTab('behaviors', { + title: 'tab.behaviors.name', icon: 'fa fa-list', + route: 'behaviors(/)(:testGroup)(/)(:testResult)(/)(:testResultTab)(/)', + onEnter: (function (testGroup, testResult, testResultTab) { + return new allure.components.TreeLayout({ + testGroup: testGroup, + testResult: testResult, + testResultTab: testResultTab, + tabName: 'tab.behaviors.name', + baseUrl: 'behaviors', + url: 'data/behaviors.json', + csvUrl: 'data/behaviors.csv' + }); + }) +}); + +allure.api.addWidget('widgets', 'behaviors', allure.components.WidgetStatusView.extend({ + rowTag: 'a', + title: 'widget.behaviors.name', + baseUrl: 'behaviors', + showLinks: true +})); diff --git a/2/plugins/packages/index.js b/2/plugins/packages/index.js new file mode 100644 index 0000000..03964b4 --- /dev/null +++ b/2/plugins/packages/index.js @@ -0,0 +1,104 @@ +'use strict'; + +allure.api.addTranslation('en', { + tab: { + packages: { + name: 'Packages' + } + } +}); + +allure.api.addTranslation('ru', { + tab: { + packages: { + name: 'Пакеты' + } + } +}); + +allure.api.addTranslation('zh', { + tab: { + packages: { + name: '包' + } + } +}); + +allure.api.addTranslation('de', { + tab: { + packages: { + name: 'Pakete' + } + } +}); + +allure.api.addTranslation('nl', { + tab: { + packages: { + name: 'Packages' + } + } +}); + +allure.api.addTranslation('he', { + tab: { + packages: { + name: 'חבילות' + } + } +}); + +allure.api.addTranslation('br', { + tab: { + packages: { + name: 'Pacotes' + } + } +}); + +allure.api.addTranslation('ja', { + tab: { + packages: { + name: 'パッケージ' + } + } +}); + +allure.api.addTranslation('es', { + tab: { + packages: { + name: 'Paquetes' + } + } +}); + +allure.api.addTranslation('kr', { + tab: { + packages: { + name: '패키지' + } + } +}); + +allure.api.addTranslation('fr', { + tab: { + packages: { + name: 'Paquets' + } + } +}); + +allure.api.addTab('packages', { + title: 'tab.packages.name', icon: 'fa fa-align-left', + route: 'packages(/)(:testGroup)(/)(:testResult)(/)(:testResultTab)(/)', + onEnter: (function (testGroup, testResult, testResultTab) { + return new allure.components.TreeLayout({ + testGroup: testGroup, + testResult: testResult, + testResultTab: testResultTab, + tabName: 'tab.packages.name', + baseUrl: 'packages', + url: 'data/packages.json' + }); + }) +}); diff --git a/2/plugins/screen-diff/index.js b/2/plugins/screen-diff/index.js new file mode 100644 index 0000000..3774f88 --- /dev/null +++ b/2/plugins/screen-diff/index.js @@ -0,0 +1,200 @@ +(function () { + var settings = allure.getPluginSettings('screen-diff', { diffType: 'diff' }); + + function renderImage(src) { + return ( + '
' + + '' + + '
' + ); + } + + function findImage(data, name) { + if (data.testStage && data.testStage.attachments) { + var matchedImage = data.testStage.attachments.filter(function (attachment) { + return attachment.name === name; + })[0]; + if (matchedImage) { + return 'data/attachments/' + matchedImage.source; + } + } + return null; + } + + function renderDiffContent(type, diffImage, actualImage, expectedImage) { + if (type === 'diff') { + if (diffImage) { + return renderImage(diffImage); + } + } + if (type === 'overlay' && expectedImage) { + return ( + '
' + + '' + + '
' + + '' + + '
' + + '
' + ); + } + if (actualImage) { + return renderImage(actualImage); + } + return 'No diff data provided'; + } + + var TestResultView = Backbone.Marionette.View.extend({ + regions: { + subView: '.screen-diff-view', + }, + template: function () { + return '
'; + }, + onRender: function () { + var data = this.model.toJSON(); + var testType = data.labels.filter(function (label) { + return label.name === 'testType'; + })[0]; + var diffImage = findImage(data, 'diff'); + var actualImage = findImage(data, 'actual'); + var expectedImage = findImage(data, 'expected'); + if (!testType || testType.value !== 'screenshotDiff') { + return; + } + this.showChildView( + 'subView', + new ScreenDiffView({ + diffImage: diffImage, + actualImage: actualImage, + expectedImage: expectedImage, + }), + ); + }, + }); + var ErrorView = Backbone.Marionette.View.extend({ + templateContext: function () { + return this.options; + }, + template: function (data) { + return '
' + data.error + '
'; + }, + }); + var AttachmentView = Backbone.Marionette.View.extend({ + regions: { + subView: '.screen-diff-view', + }, + template: function () { + return '
'; + }, + onRender: function () { + jQuery + .getJSON(this.options.sourceUrl) + .then(this.renderScreenDiffView.bind(this), this.renderErrorView.bind(this)); + }, + renderErrorView: function (error) { + console.log(error); + this.showChildView( + 'subView', + new ErrorView({ + error: error.statusText, + }), + ); + }, + renderScreenDiffView: function (data) { + this.showChildView( + 'subView', + new ScreenDiffView({ + diffImage: data.diff, + actualImage: data.actual, + expectedImage: data.expected, + }), + ); + }, + }); + + var ScreenDiffView = Backbone.Marionette.View.extend({ + className: 'pane__section', + events: function () { + return { + ['click [name="screen-diff-type-' + this.cid + '"]']: 'onDiffTypeChange', + 'mousemove .screen-diff__overlay': 'onOverlayMove', + }; + }, + initialize: function (options) { + this.diffImage = options.diffImage; + this.actualImage = options.actualImage; + this.expectedImage = options.expectedImage; + this.radioName = 'screen-diff-type-' + this.cid; + }, + templateContext: function () { + return { + diffType: settings.get('diffType'), + diffImage: this.diffImage, + actualImage: this.actualImage, + expectedImage: this.expectedImage, + radioName: this.radioName, + }; + }, + template: function (data) { + if (!data.diffImage && !data.actualImage && !data.expectedImage) { + return ''; + } + + return ( + '

Screen Diff

' + + '
' + + '
' + + '' + + '' + + '
' + + renderDiffContent( + data.diffType, + data.diffImage, + data.actualImage, + data.expectedImage, + ) + + '
' + ); + }, + adjustImageSize: function (event) { + var overImage = this.$(event.target); + overImage.width(overImage.width()); + }, + onRender: function () { + const diffType = settings.get('diffType'); + this.$('[name="' + this.radioName + '"][value="' + diffType + '"]').prop( + 'checked', + true, + ); + if (diffType === 'overlay') { + this.$('.screen-diff__image-over img').on('load', this.adjustImageSize.bind(this)); + } + }, + onOverlayMove: function (event) { + var pageX = event.pageX; + var containerScroll = this.$('.screen-diff__container').scrollLeft(); + var elementX = event.currentTarget.getBoundingClientRect().left; + var delta = pageX - elementX + containerScroll; + this.$('.screen-diff__image-over').width(delta); + }, + onDiffTypeChange: function (event) { + settings.save('diffType', event.target.value); + this.render(); + }, + }); + allure.api.addTestResultBlock(TestResultView, { position: 'before' }); + allure.api.addAttachmentViewer('application/vnd.allure.image.diff', { + View: AttachmentView, + icon: 'fa fa-exchange', + }); +})(); diff --git a/2/plugins/screen-diff/styles.css b/2/plugins/screen-diff/styles.css new file mode 100644 index 0000000..6cf2219 --- /dev/null +++ b/2/plugins/screen-diff/styles.css @@ -0,0 +1,30 @@ +.screen-diff__switchers { + margin-bottom: 1em; +} + +.screen-diff__switchers label + label { + margin-left: 1em; +} + +.screen-diff__overlay { + position: relative; + cursor: col-resize; +} + +.screen-diff__container { + overflow-x: auto; +} + +.screen-diff__image-over { + top: 0; + left: 0; + bottom: 0; + background: #fff; + position: absolute; + overflow: hidden; + box-shadow: 2px 0 1px -1px #aaa; +} + +.screen-diff-error { + color: #fd5a3e; +} -- cgit