Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wadjih-bencheikh18 committed Nov 2, 2024
1 parent 4baf6ad commit ae34cc5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/component/panels/header/DefaultPanelHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function DefaultPanelHeader(props: DefaultPanelHeaderProps) {
<PanelHeader
{...{ style, className }}
onClickSettings={onSettingClick}
current={hideCounter ? undefined : counter}
current={hideCounter || total === counter ? undefined : counter}
total={hideCounter ? undefined : total}
>
<div style={styles.leftContainer}>
Expand Down
8 changes: 4 additions & 4 deletions test-e2e/panels/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test('process 1d FID 13c spectrum', async ({ page }) => {
const nmrium = await NmriumPage.create(page);
await test.step('Spectra panel settings', async () => {
await nmrium.page.click(
'_react=AccordionItem[title="Spectra"] >> _react=PreferencesButton >> nth=0',
'_react=AccordionItem[title="Spectra"] >> _react=PanelHeader >> button >> nth=-1',
);
await nmrium.page.click(
'_react=AccordionItem[title="Spectra"] >> _react=ToolbarItem[id="save-button"] >> nth=0',
Expand All @@ -16,7 +16,7 @@ test('process 1d FID 13c spectrum', async ({ page }) => {
await test.step('Peaks panel settings', async () => {
await nmrium.clickPanel('Peaks');
await nmrium.page.click(
'_react=AccordionItem[title="Peaks"] >> _react=PreferencesButton >> nth=0',
'_react=AccordionItem[title="Peaks"] >> _react=PanelHeader >> button >> nth=-1',
);
await nmrium.page.click(
'_react=AccordionItem[title="Peaks"] >> _react=ToolbarItem[id="save-button"] >> nth=0',
Expand All @@ -26,7 +26,7 @@ test('process 1d FID 13c spectrum', async ({ page }) => {
await test.step('Integrals panel settings', async () => {
await nmrium.clickPanel('Integrals');
await nmrium.page.click(
'_react=AccordionItem[title="Integrals"] >> _react=PreferencesButton >> nth=0',
'_react=AccordionItem[title="Integrals"] >> _react=PanelHeader >> button >> nth=-1',
);
await nmrium.page.click(
'_react=AccordionItem[title="Integrals"] >> _react=ToolbarItem[id="save-button"] >> nth=0',
Expand All @@ -36,7 +36,7 @@ test('process 1d FID 13c spectrum', async ({ page }) => {
await test.step('Ranges panel settings', async () => {
await nmrium.clickPanel('Ranges / Multiplet analysis');
await nmrium.page.click(
'_react=AccordionItem[title="Ranges / Multiplet analysis"] >> _react=PreferencesButton >> nth=0',
'_react=AccordionItem[title="Ranges / Multiplet analysis"] >> _react=PanelHeader >> button >> nth=-1',
);
await nmrium.page.click(
'_react=AccordionItem[title="Ranges / Multiplet analysis"] >> _react=ToolbarItem[id="save-button"] >> nth=0',
Expand Down
54 changes: 40 additions & 14 deletions test-e2e/panels/structures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ test('molecules 1H spectrum', async ({ page, browserName }) => {
// Go to the next molecule.
await nmrium.page.click('_react=Arrow[direction="right"]');
}
const moleculePanelLocator = nmrium.page.locator('_react=MoleculePanel');

await test.step('Check delete float molecule', async () => {
// Delete molecule.
Expand All @@ -465,9 +464,16 @@ test('molecules 1H spectrum', async ({ page, browserName }) => {
await expect(nmrium.page.locator('#molSVG')).toBeHidden();
// Check selected molecule.

await expect(
moleculePanelLocator.locator('p:has-text("1 / 2"), p:has-text("1 / 3")'),
).toBeVisible();
if (browserName === 'chromium') {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=1 / 3'),
).toBeVisible();
} else {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=1 / 2'),
).toBeVisible();
}

await expect(nmrium.page.locator('text=C11H14N2O - 190.25')).toBeVisible();
await expect(
nmrium.page.locator('.mol-svg-container #molSVG0'),
Expand All @@ -479,9 +485,16 @@ test('molecules 1H spectrum', async ({ page, browserName }) => {
await nmrium.page.click('_react=Arrow[direction="right"]');
// Check the second molecule.

await expect(
moleculePanelLocator.locator('p:has-text("2 / 2"), p:has-text("2 / 3")'),
).toBeVisible();
if (browserName === 'chromium') {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=2 / 3'),
).toBeVisible();
} else {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=2 / 2'),
).toBeVisible();
}

await expect(nmrium.page.locator('text=C6H12 - 84.16')).toBeVisible();
await expect(
nmrium.page.locator('.mol-svg-container #molSVG1'),
Expand All @@ -491,10 +504,16 @@ test('molecules 1H spectrum', async ({ page, browserName }) => {
await nmrium.clickToolByTitle('Delete molecule');

// Check selected molecule.
if (browserName === 'chromium') {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=1 / 2'),
).toBeVisible();
} else {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=1 / 1'),
).toBeVisible();
}

await expect(
moleculePanelLocator.locator('p:has-text("1 / 1"), p:has-text("1 / 2")'),
).toBeVisible();
await expect(nmrium.page.locator('text=C11H14N2O - 190.25')).toBeVisible();
await expect(
nmrium.page.locator('.mol-svg-container #molSVG0'),
Expand All @@ -504,14 +523,21 @@ test('molecules 1H spectrum', async ({ page, browserName }) => {
await test.step('Empty panel', async () => {
// Check selected molecule.

await expect(
moleculePanelLocator.locator('p:has-text("1 / 1"), p:has-text("1 / 2")'),
).toBeVisible();
if (browserName === 'chromium') {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=1 / 2'),
).toBeVisible();
} else {
await expect(
nmrium.page.locator('_react=MoleculePanel >> text=1 / 1'),
).toBeVisible();
}

await expect(nmrium.page.locator('text=C11H14N2O - 190.25')).toBeVisible();

// Delete molecule.
await nmrium.clickToolByTitle('Delete molecule');
if (browserName !== 'firefox') {
if (browserName === 'chromium') {
// Delete molecule.
await nmrium.clickToolByTitle('Delete molecule');
}
Expand Down

0 comments on commit ae34cc5

Please sign in to comment.