Skip to content

Commit

Permalink
#3019 - Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoblit committed Aug 28, 2023
1 parent 6afaa76 commit 65fd631
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,63 @@
import { test } from '@playwright/test';
import { Page, test } from '@playwright/test';
import {
getCoordinatesOfTheMiddleOfTheScreen,
pressButton,
resetCurrentTool,
selectTopPanelButton,
STRUCTURE_LIBRARY_BUTTON_NAME,
takeEditorScreenshot,
TopPanelButton,
} from '@utils';

async function setDisplayStereoFlagsSettingToOn(page: Page) {
await selectTopPanelButton(TopPanelButton.Settings, page);
await page.getByText('Stereochemistry', { exact: true }).click();
await pressButton(page, 'IUPAC style');
await page.getByRole('option', { name: 'On' }).click();
await pressButton(page, 'Apply');
}

async function switchIgnoreChiralFlagSetting(page: Page) {
await selectTopPanelButton(TopPanelButton.Settings, page);
await page.getByText('Stereochemistry', { exact: true }).click();
await page.getByText('Ignore the chiral flag').click();
await pressButton(page, 'Apply');
}

async function placePhenylalanineMustard(page: Page, x: number, y: number) {
await pressButton(page, STRUCTURE_LIBRARY_BUTTON_NAME);
const phenylalanineLocator = page.locator(
`div[title*="Phenylalanine mustard"] > div`,
);
if ((await phenylalanineLocator.count()) === 0) {
await page.getByText('Aromatics').click();
}
await phenylalanineLocator.first().click();
await page.mouse.click(x, y);
}

test.describe('Templates - Template Library', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
});

test.afterEach(async ({ page }) => {
await resetCurrentTool(page);
await takeEditorScreenshot(page);
});

test.only('Template with chiral flag 0 with ignoreChiralFlag enabled/disabled', async ({
test('Template with chiral flag 0 with ignoreChiralFlag enabled/disabled', async ({
page,
}) => {
await selectTopPanelButton(TopPanelButton.Settings, page);
await page.getByText('Stereochemistry', { exact: true }).click();
await page.getByLabel('Ignore the chiral flag').click();
// await pressButton(page, 'Labels Only');
// await page.getByRole('option', { name: color }).click();
// await pressButton(page, 'Apply');
const offsetX = 200;
const { x, y } = await getCoordinatesOfTheMiddleOfTheScreen(page);

await setDisplayStereoFlagsSettingToOn(page);

await switchIgnoreChiralFlagSetting(page);
await placePhenylalanineMustard(page, x - offsetX, y);

await switchIgnoreChiralFlagSetting(page);
await placePhenylalanineMustard(page, x + offsetX, y);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 65fd631

Please sign in to comment.