mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server: Fix duplicating notes with relationships (closes #308)
This commit is contained in:
parent
ddc82853fc
commit
f297105c25
@ -2,8 +2,8 @@ import { test as setup, expect } from '@playwright/test';
|
||||
|
||||
const authFile = 'playwright/.auth/user.json';
|
||||
|
||||
const ROOT_URL = "http://localhost:8080";
|
||||
const LOGIN_PASSWORD = "eliandoran";
|
||||
const ROOT_URL = "http://localhost:8082";
|
||||
const LOGIN_PASSWORD = "demo1234";
|
||||
|
||||
// Reference: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests
|
||||
|
||||
|
9
integration-tests/duplicate.spec.ts
Normal file
9
integration-tests/duplicate.spec.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test("Can duplicate note with broken links", async ({ page }) => {
|
||||
await page.goto(`http://localhost:8082/#2VammGGdG6Ie`);
|
||||
await page.locator('.tree-wrapper .fancytree-active').getByText('Note map').click({ button: 'right' });
|
||||
await page.getByText('Duplicate subtree').click();
|
||||
await expect(page.locator(".toast-body")).toBeHidden();
|
||||
await expect(page.locator('.tree-wrapper').getByText('Note map (dup)')).toBeVisible();
|
||||
});
|
@ -34,7 +34,7 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
|
||||
isSynced?: boolean;
|
||||
blobId?: string;
|
||||
|
||||
protected beforeSaving() {
|
||||
protected beforeSaving(opts?: {}) {
|
||||
const constructorData = (this.constructor as unknown as ConstructorData<T>);
|
||||
if (!(this as any)[constructorData.primaryKeyName]) {
|
||||
(this as any)[constructorData.primaryKeyName] = utils.newEntityId();
|
||||
@ -109,7 +109,7 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
|
||||
|
||||
const isNewEntity = !(this as any)[primaryKeyName];
|
||||
|
||||
this.beforeSaving();
|
||||
this.beforeSaving(opts);
|
||||
|
||||
const pojo = this.getPojoToSave();
|
||||
|
||||
|
@ -817,7 +817,6 @@ function undeleteBranch(branchId: string, deleteId: string, taskContext: TaskCon
|
||||
|
||||
for (const attributeRow of attributeRows) {
|
||||
// relation might point to a note which hasn't been undeleted yet and would thus throw up
|
||||
// TODO: skipValidation is not used.
|
||||
new BAttribute(attributeRow).save({skipValidation: true});
|
||||
}
|
||||
|
||||
@ -997,8 +996,7 @@ function duplicateSubtreeInner(origNote: BNote, origBranch: BBranch, newParentNo
|
||||
}
|
||||
|
||||
// the relation targets may not be created yet, the mapping is pre-generated
|
||||
// TODO: This used to be `attr.save({skipValidation: true});`, but skipValidation is in beforeSaving.
|
||||
attr.save();
|
||||
attr.save({skipValidation: true});
|
||||
}
|
||||
|
||||
for (const childBranch of origNote.getChildBranches()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user