Skip to content

Commit 11f4c2e

Browse files
authored
Merge pull request #276 from pluginpal/feature/fix-duplication
fix: response structure for cloned content to prevent issues
2 parents 90921de + 434169d commit 11f4c2e

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

.changeset/angry-points-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"strapi-plugin-webtools": patch
3+
---
4+
5+
fix: response structure for cloned content to prevent issues

.github/workflows/tests.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,7 @@ jobs:
5858
run: yarn playground:install
5959
- name: Build the playground
6060
run: yarn playground:build
61-
# We allow the unit tests to fail the first time around.
62-
# For some reason they always fail the first time.
63-
- name: Run unit tests (allow failures)
64-
run: yarn test:unit || exit 0
65-
# Then we run the test again, but this time we disallow failures.
66-
# This way we can see the actual error messages.
67-
- name: Run unit tests (disallow failures)
61+
- name: Run unit tests
6862
run: yarn test:unit
6963
- name: Run integration tests
7064
run: yarn test:integration

packages/core/server/middlewares/__tests__/middlewares.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ describe('Query layer decorator', () => {
2929
expect(clonedPage).not.toBeNull();
3030

3131
const newUrlAliasPath = `${page.url_alias[0].url_path}-0`;
32-
expect(clonedPage).toHaveProperty('url_alias[0].url_path', newUrlAliasPath);
33-
expect(clonedPage).toHaveProperty('url_alias[0].generated', true);
34-
expect(clonedPage).toHaveProperty('url_alias[0].contenttype', 'api::test.test');
32+
expect(clonedPage).toHaveProperty('entries[0].url_alias[0].url_path', newUrlAliasPath);
33+
expect(clonedPage).toHaveProperty('entries[0].url_alias[0].generated', true);
34+
expect(clonedPage).toHaveProperty('entries[0].url_alias[0].contenttype', 'api::test.test');
3535
expect(clonedPage.documentId).not.toBe(page.documentId);
36-
expect(clonedPage.url_alias[0].documentId).not.toBe(page.url_alias[0].documentId);
36+
expect(clonedPage.entries[0].url_alias[0].documentId).not.toBe(page.url_alias[0].documentId);
3737
});
3838

3939
it('Create - Should generate a new URL alias', async () => {

packages/core/server/middlewares/generate-url-alias.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ const generateUrlAliasMiddleware: Modules.Documents.Middleware.Middleware = asyn
154154
populate: params.populate,
155155
});
156156

157+
if (action === 'clone') {
158+
return {
159+
documentId: entity.documentId,
160+
entries: [finalEntity],
161+
};
162+
}
163+
157164
return finalEntity;
158165
};
159166

0 commit comments

Comments
 (0)