Skip to content

Commit

Permalink
NEXT-24090 - Refactor tests to unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Feb 22, 2023
1 parent 77d4f64 commit 3fab3e7
Show file tree
Hide file tree
Showing 35 changed files with 353 additions and 1,367 deletions.
1 change: 1 addition & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
pkgs.gnupatch
pkgs.nodePackages_latest.yalc
pkgs.symfony-cli
pkgs.deno
];

languages.javascript = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class UpdateService extends ApiService {
});
}

downloadUpdate(offset) {
downloadRecovery() {
const headers = this.getBasicHeaders();

return this.httpClient
.get(`/_action/${this.getApiBasePath()}/download-latest-update?offset=${offset}`, { headers })
.get(`/_action/${this.getApiBasePath()}/download-recovery`, { headers })
.then((response) => {
return ApiService.handleResponse(response);
});
Expand All @@ -69,18 +69,6 @@ class UpdateService extends ApiService {
});
}

unpackUpdate(offset) {
const headers = this.getBasicHeaders();

return this.httpClient
.get(
`/_action/${this.getApiBasePath()}/unpack?offset=${offset}`,
{ headers },
).then((response) => {
return ApiService.handleResponse(response);
});
}

getBasicParams(additionalParams = {}) {
const basicParams = {
language: localStorage.getItem('sw-admin-locale'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './page/sw-settings-shopware-updates-index';
import './page/sw-settings-shopware-updates-wizard';
import './view/sw-settings-shopware-updates-info';
import './view/sw-settings-shopware-updates-requirements';
Expand All @@ -21,14 +20,6 @@ Module.register('sw-settings-shopware-updates', {
favicon: 'icon-module-settings.png',

routes: {
index: {
component: 'sw-settings-shopware-updates-index',
path: 'index',
meta: {
parentPath: 'sw.settings.index.system',
privilege: 'system.core_update',
},
},
wizard: {
component: 'sw-settings-shopware-updates-wizard',
path: 'wizard',
Expand All @@ -42,7 +33,7 @@ Module.register('sw-settings-shopware-updates', {
settingsItem: {
privilege: 'system.core_update',
group: 'system',
to: 'sw.settings.shopware.updates.index',
to: 'sw.settings.shopware.updates.wizard',
icon: 'regular-sync',
},
});

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ Component.register('sw-settings-shopware-updates-wizard', {
};
},

changelog() {
if (!this.updateInfo.version) {
return '';
}

if (this.$i18n.locale.substr(0, 2) === 'de') {
return this.updateInfo.changelog.de.changelog;
}

return this.updateInfo.changelog.en.changelog;
},

displayIncompatiblePluginsWarning() {
return this.plugins.some((plugin) => {
return plugin.statusName !== 'compatible' && plugin.statusName !== 'notInStore';
Expand Down Expand Up @@ -146,7 +134,7 @@ Component.register('sw-settings-shopware-updates-wizard', {
message: this.$tc('sw-settings-shopware-updates.notifications.updateStarted'),
});

this.downloadUpdate(0);
this.downloadRecovery();
},

stopUpdateProcess() {
Expand All @@ -158,20 +146,10 @@ Component.register('sw-settings-shopware-updates-wizard', {
});
},

downloadUpdate(offset) {
this.updateService.downloadUpdate(offset).then(response => {
this.progressbarValue = (Math.floor((response.offset / response.total) * 100));

if (response.offset === response.total && response.success) {
this.progressbarValue = 0;
this.deactivatePlugins(0);
} else if (response.offset !== response.total && response.success) {
this.downloadUpdate(response.offset);
} else {
this.createNotificationError({
message: this.$tc('sw-settings-shopware-updates.notifications.downloadFailed'),
});
}
downloadRecovery(offset) {
this.updateService.downloadRecovery(offset).then(() => {
this.progressbarValue = 0;
this.deactivatePlugins(0);
}).catch(() => {
this.createNotificationError({
message: this.$tc('sw-settings-shopware-updates.notifications.downloadFailed'),
Expand All @@ -185,8 +163,7 @@ Component.register('sw-settings-shopware-updates-wizard', {
this.progressbarValue = (Math.floor((response.offset / response.total) * 100));

if (response.offset === response.total && response.success) {
this.progressbarValue = 0;
this.unpackUpdate(0);
window.location.href = `${Shopware.Context.api.basePath}/shopware-recovery.phar.php`;
} else if (response.offset !== response.total && response.success) {
this.deactivatePlugins(response.offset);
} else {
Expand Down Expand Up @@ -223,22 +200,5 @@ Component.register('sw-settings-shopware-updates-wizard', {
}
});
},

unpackUpdate(offset) {
this.step = 'unpack';
this.updateService.unpackUpdate(offset).then(response => {
this.progressbarValue = (Math.floor((response.offset / response.total) * 100));

if (response.redirectTo) {
window.location.href = response.redirectTo;
} else if (response.offset !== response.total && response.success) {
this.unpackUpdate(response.offset);
} else {
this.createNotificationError({
message: this.$tc('sw-settings-shopware-updates.notifications.unpackFailed'),
});
}
});
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
{% block sw_settings_shopware_updates_wizard_content %}
<sw-card-view v-if="isLoading || updateInfo.version">
<sw-settings-shopware-updates-info
v-if="updateInfo"
:is-loading="isLoading"
:changelog="changelog"
:changelog="updateInfo.body"
/>
<sw-settings-shopware-updates-requirements
:is-loading="isLoading"
Expand Down
Loading

0 comments on commit 3fab3e7

Please sign in to comment.