diff --git a/public/data/sample-with-error.zip b/public/data/sample-with-error.zip
new file mode 100644
index 0000000..f92c64d
Binary files /dev/null and b/public/data/sample-with-error.zip differ
diff --git a/src/demo/NMRiumWrapperDemo.tsx b/src/demo/NMRiumWrapperDemo.tsx
index 1476606..79699c9 100644
--- a/src/demo/NMRiumWrapperDemo.tsx
+++ b/src/demo/NMRiumWrapperDemo.tsx
@@ -72,6 +72,7 @@ export default function NMRiumWrapperDemo() {
Test Load URL without extension
{
void loadFilesFromURLs([
'../data/COSY-12.zip',
@@ -87,6 +88,21 @@ export default function NMRiumWrapperDemo() {
>
Test Load Files
+ {
+ void loadFilesFromURLs(['../data/sample-with-error.zip']).then(
+ (files) => {
+ events.trigger('load', {
+ data: files,
+ type: 'file',
+ });
+ },
+ );
+ }}
+ >
+ Test Logger
+
diff --git a/test-e2e/core.test.ts b/test-e2e/core.test.ts
index 0921c1a..6f3139e 100644
--- a/test-e2e/core.test.ts
+++ b/test-e2e/core.test.ts
@@ -80,3 +80,38 @@ test('should load NMRium from URL without .zip extension in the path', async ({
// if loaded successfully, there should be a 1H
await expect(nmrium.page.locator('.tab-list-item >> text=1H')).toBeVisible();
});
+
+
+
+test("Should trigger error action and load the other one that parses successfully", async ({
+ page,
+}) => {
+ const nmrium = await NmriumWrapperPage.create(page);
+
+
+
+ const hasError = await nmrium.page.evaluate(() => {
+ const button = document.querySelector(".logger-btn") as HTMLButtonElement;
+ // Add a listener for the 'message' event
+ return new Promise((resolve) => {
+ window.addEventListener('message', (event) => {
+ if (event.data.type === "nmr-wrapper:error") {
+ resolve(true)
+ }
+ })
+ button.click();
+
+ }
+ );
+
+ });
+
+ // the error event is triggered
+ expect(hasError).toBeTruthy();
+
+ // load a 1H spectrum successfully
+ await expect(nmrium.page.locator('.tab-list-item >> text=1H')).toBeVisible();
+ // load a 13C spectrum successfully
+ await expect(nmrium.page.locator('.tab-list-item >> text=13C')).toBeVisible();
+
+});