Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-points-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-plugin-webtools": patch
---

fix: response structure for cloned content to prevent issues
8 changes: 1 addition & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ jobs:
run: yarn playground:install
- name: Build the playground
run: yarn playground:build
# We allow the unit tests to fail the first time around.
# For some reason they always fail the first time.
- name: Run unit tests (allow failures)
run: yarn test:unit || exit 0
# Then we run the test again, but this time we disallow failures.
# This way we can see the actual error messages.
- name: Run unit tests (disallow failures)
- name: Run unit tests
run: yarn test:unit
- name: Run integration tests
run: yarn test:integration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe('Query layer decorator', () => {
expect(clonedPage).not.toBeNull();

const newUrlAliasPath = `${page.url_alias[0].url_path}-0`;
expect(clonedPage).toHaveProperty('url_alias[0].url_path', newUrlAliasPath);
expect(clonedPage).toHaveProperty('url_alias[0].generated', true);
expect(clonedPage).toHaveProperty('url_alias[0].contenttype', 'api::test.test');
expect(clonedPage).toHaveProperty('entries[0].url_alias[0].url_path', newUrlAliasPath);
expect(clonedPage).toHaveProperty('entries[0].url_alias[0].generated', true);
expect(clonedPage).toHaveProperty('entries[0].url_alias[0].contenttype', 'api::test.test');
expect(clonedPage.documentId).not.toBe(page.documentId);
expect(clonedPage.url_alias[0].documentId).not.toBe(page.url_alias[0].documentId);
expect(clonedPage.entries[0].url_alias[0].documentId).not.toBe(page.url_alias[0].documentId);
});

it('Create - Should generate a new URL alias', async () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/core/server/middlewares/generate-url-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ const generateUrlAliasMiddleware: Modules.Documents.Middleware.Middleware = asyn
populate: params.populate,
});

if (action === 'clone') {
return {
documentId: entity.documentId,
entries: [finalEntity],
};
}

return finalEntity;
};

Expand Down