-
Notifications
You must be signed in to change notification settings - Fork 26
fix: persist partial premapping #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jozsef Damokos (jozsefdamokos)
merged 8 commits into
trunk
from
feat/partial-premapping
May 28, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
53bd656
fix: persist partial premapping
jozsefdamokos 7768ad6
threads
jozsefdamokos ffc53a0
retrigger CI
jozsefdamokos be48f42
Merge branch 'trunk' into feat/partial-premapping
jozsefdamokos 28de2cd
retrigger CI
jozsefdamokos 7fe4bd8
Merge branch 'feat/partial-premapping' of github.com:shopware/SwagMig…
jozsefdamokos 48570f8
retrigger CI
jozsefdamokos 5545807
always run cs-fixer and phpstan
jozsefdamokos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
tests/Jest/src/module/swag-migration/component/card/swag-migration-premapping.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| import { mount } from '@vue/test-utils'; | ||
| import 'SwagMigrationAssistant/module/swag-migration/store/migration.store'; | ||
| import swagMigrationPremapping from 'SwagMigrationAssistant/module/swag-migration/component/card/swag-migration-premapping'; | ||
| import { fixturePreMapping } from '@/fixture'; | ||
|
|
||
| Shopware.Component.register('swag-migration-premapping', swagMigrationPremapping); | ||
|
|
||
| const migrationApiServiceMock = { | ||
| generatePremapping: jest.fn(() => Promise.resolve([])), | ||
| writePremapping: jest.fn(() => Promise.resolve()), | ||
| }; | ||
|
|
||
| const swagMigrationTabCardStub = { | ||
| name: 'swag-migration-tab-card', | ||
| props: ['items'], | ||
| template: ` | ||
| <div> | ||
| <slot | ||
| v-for="item in items" | ||
| name="items" | ||
| :item="item" | ||
| /> | ||
| </div> | ||
| `, | ||
| }; | ||
|
|
||
| async function createWrapper() { | ||
| return mount(await Shopware.Component.build('swag-migration-premapping'), { | ||
| global: { | ||
| plugins: [Shopware.Store._rootState], | ||
| provide: { | ||
| migrationApiService: migrationApiServiceMock, | ||
| }, | ||
| stubs: { | ||
| 'swag-migration-tab-card': swagMigrationTabCardStub, | ||
| 'swag-migration-grid-selection': true, | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| describe('module/swag-migration/component/card/swag-migration-premapping', () => { | ||
| let store = null; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
|
|
||
| store = Shopware.Store.get('swagMigration'); | ||
| store.$reset(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.useRealTimers(); | ||
| }); | ||
|
|
||
| it('writes partially filled premapping', async () => { | ||
| store.premapping = [ | ||
| { | ||
| ...fixturePreMapping[0], | ||
| mapping: [ | ||
| fixturePreMapping[0].mapping[0], | ||
| { | ||
| ...fixturePreMapping[0].mapping[1], | ||
| destinationUuid: null, | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| const wrapper = await createWrapper(); | ||
| jest.useFakeTimers(); | ||
| const gridSelection = wrapper.findComponent({ name: 'swag-migration-grid-selection' }); | ||
|
|
||
| gridSelection.vm.$emit('update:value'); | ||
| jest.advanceTimersByTime(500); | ||
| await flushPromises(); | ||
|
|
||
| expect(migrationApiServiceMock.writePremapping).toHaveBeenCalledTimes(1); | ||
| expect(migrationApiServiceMock.writePremapping).toHaveBeenCalledWith([ | ||
| { | ||
| ...store.premapping[0], | ||
| mapping: [ | ||
| store.premapping[0].mapping[0], | ||
| ], | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('persists regenerated partial premapping after changing the data selection', async () => { | ||
| const regeneratedPremapping = [ | ||
| { | ||
| ...fixturePreMapping[0], | ||
| mapping: [ | ||
| { | ||
| ...fixturePreMapping[0].mapping[0], | ||
| destinationUuid: 'mr', | ||
| }, | ||
| { | ||
| ...fixturePreMapping[0].mapping[1], | ||
| destinationUuid: null, | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| migrationApiServiceMock.generatePremapping.mockResolvedValueOnce(regeneratedPremapping); | ||
|
|
||
| await createWrapper(); | ||
|
|
||
| store.setDataSelectionIds(['customersOrders']); | ||
| await flushPromises(); | ||
|
|
||
| expect(migrationApiServiceMock.generatePremapping).toHaveBeenCalledTimes(1); | ||
| expect(migrationApiServiceMock.generatePremapping).toHaveBeenCalledWith(['customersOrders']); | ||
| expect(migrationApiServiceMock.writePremapping).toHaveBeenCalledTimes(1); | ||
| expect(migrationApiServiceMock.writePremapping).toHaveBeenCalledWith([ | ||
| { | ||
| ...store.premapping[0], | ||
| mapping: [ | ||
| regeneratedPremapping[0].mapping[0], | ||
| ], | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('debounces repeated premapping changes into a single save', async () => { | ||
| jest.useFakeTimers(); | ||
|
|
||
| store.premapping = fixturePreMapping; | ||
|
|
||
| const wrapper = await createWrapper(); | ||
| const gridSelection = wrapper.findComponent({ name: 'swag-migration-grid-selection' }); | ||
|
|
||
| gridSelection.vm.$emit('update:value'); | ||
| gridSelection.vm.$emit('update:value'); | ||
|
|
||
| expect(store.isLoading).toBe(true); | ||
| expect(migrationApiServiceMock.writePremapping).not.toHaveBeenCalled(); | ||
|
|
||
| jest.advanceTimersByTime(500); | ||
| await flushPromises(); | ||
|
|
||
| expect(migrationApiServiceMock.writePremapping).toHaveBeenCalledTimes(1); | ||
| expect(store.isLoading).toBe(false); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.