Skip to content

Commit

Permalink
#2518 - fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gayane Chilingaryan committed Sep 12, 2023
2 parents 8a5facd + f21db33 commit a6b2c91
Show file tree
Hide file tree
Showing 452 changed files with 2,390 additions and 2,109 deletions.
8 changes: 3 additions & 5 deletions ketcher-autotests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function baseURL(): string {
}

const MAX_NUMBER_OF_RETRIES = 2;
const MIN_AMOUNT_OF_WORKERS = 2;
// const MAX_NUMBER_OF_FAILURES = 3;
const isCI = process.env.CI_ENVIRONMENT === 'true';

Expand All @@ -67,15 +68,12 @@ const config: PlaywrightTestConfig = {
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly:
process.env.CI_ENVIRONMENT === 'false'
? false
: Boolean(process.env.CI_ENVIRONMENT),
forbidOnly: isCI,
/* Retry on CI only */
retries: isCI ? MAX_NUMBER_OF_RETRIES : 0,
/* Opt out of parallel tests on CI. */
// eslint-disable-next-line no-magic-numbers
workers: process.env.CI ? 2 : os.cpus().length,
workers: process.env.CI ? MIN_AMOUNT_OF_WORKERS : os.cpus().length,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
[
Expand Down
5 changes: 2 additions & 3 deletions ketcher-autotests/tests/API/api-set-get-molecule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
receiveFileComparisonData,
waitForSpinnerFinishedWork,
clickInTheMiddleOfTheScreen,
waitForIndigoToLoad,
waitForPageInit,
} from '@utils';
import { getAtomByIndex } from '@utils/canvas/atoms';
import {
Expand All @@ -31,8 +31,7 @@ function filteredFile(file: string, filteredIndex: number): string {

test.describe('Tests for API setMolecule/getMolecule', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
await waitForIndigoToLoad(page);
await waitForPageInit(page);
});

test.afterEach(async ({ page }) => {
Expand Down
4 changes: 2 additions & 2 deletions ketcher-autotests/tests/Examples/ketcher-api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { test, expect } from '@playwright/test';
import { molV2000 } from '@tests/test-data/molV2000-result';
import { clickInTheMiddleOfTheScreen } from '@utils';
import { clickInTheMiddleOfTheScreen, waitForPageInit } from '@utils';

test('getting molV2000 from Ketcher API', async ({ page }) => {
await page.goto('');
await waitForPageInit(page);

await page.getByRole('button', { name: 'Benzene (T)' }).click();

Expand Down
3 changes: 2 additions & 1 deletion ketcher-autotests/tests/Examples/ketcher-canvas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import {
clickOnAtom,
BondTool,
selectNestedTool,
waitForPageInit,
} from '@utils';

test.describe('Drawing atom, Benzene ring, Single and Double Bond', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
await waitForPageInit(page);
});

test.afterEach(async ({ page }) => {
Expand Down
14 changes: 9 additions & 5 deletions ketcher-autotests/tests/Examples/ketcher-files.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { test } from '@playwright/test';
import { takeEditorScreenshot, openFileAndAddToCanvas } from '@utils';
import {
takeEditorScreenshot,
openFileAndAddToCanvas,
waitForPageInit,
} from '@utils';

test('opening molfile', async ({ page }) => {
await page.goto('');
await waitForPageInit(page);
await openFileAndAddToCanvas('display-abbrev-groups-example.mol', page);
await takeEditorScreenshot(page);
});
Expand All @@ -11,7 +15,7 @@ test('opening rnx files', async ({ page }) => {
/*
Test case: EPMLSOPKET-1839
*/
await page.goto('');
await waitForPageInit(page);
await openFileAndAddToCanvas('Rxn-V2000/1839-ketcher.rxn', page);
await takeEditorScreenshot(page);
});
Expand All @@ -20,7 +24,7 @@ test('opening smi files', async ({ page }) => {
/*
Test case: EPMLSOPKET-1840
*/
await page.goto('');
await waitForPageInit(page);
await openFileAndAddToCanvas('SMILES/1840-cyclopentyl.smi', page);
await takeEditorScreenshot(page);
});
Expand All @@ -29,7 +33,7 @@ test('opening inchi files', async ({ page }) => {
/*
Test case: EPMLSOPKET-1841
*/
await page.goto('');
await waitForPageInit(page);
await openFileAndAddToCanvas('InChI/1841-ketcher.inchi', page);
await takeEditorScreenshot(page);
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { test } from '@playwright/test';
import {
clickInTheMiddleOfTheScreen,
TopPanelButton,
selectTopPanelButton,
openFileAndAddToCanvas,
takeEditorScreenshot,
pasteFromClipboardAndAddToCanvas,
waitForIndigoToLoad,
} from '@utils';
import { waitForPageInit } from '@utils/common/loaders/waitForPageInit';

test.describe('CDX files', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
await waitForIndigoToLoad(page);
await waitForPageInit(page);
});

test.afterEach(async ({ page }) => {
Expand All @@ -27,21 +24,19 @@ test.describe('CDX files', () => {
await openFileAndAddToCanvas('cdx-expanded-contracted.cdx', page);
});

test.fixme('opening cdx files with R-group', async ({ page }) => {
test('opening cdx files with R-group', async ({ page }) => {
/*
Test case: EPMLSOPKET-6973
Description: Open CDX files with R-group
*/
await openFileAndAddToCanvas('cdx_file.cdx', page);
await openFileAndAddToCanvas('r_group_cdx.cdx', page);
});

test.fixme('opening cdx files from clipboard', async ({ page }) => {
test('opening cdx files from clipboard', async ({ page }) => {
/*
Test case: EPMLSOPKET-6972
Description: Open structure created in ChemDraw from clickboard
*/
await selectTopPanelButton(TopPanelButton.Open, page);
await page.getByText('Paste from clipboard').click();
await pasteFromClipboardAndAddToCanvas(
page,
// eslint-disable-next-line max-len
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
receiveFileComparisonData,
saveToFile,
clickOnAtom,
waitForPageInit,
waitForRender,
} from '@utils';
import { getCdxml } from '@utils/formats';

Expand All @@ -19,12 +21,14 @@ async function selectRadioButtonForNewGroup(
await selectLeftPanelButton(LeftPanelButton.Stereochemistry, page);
await page.getByLabel(selectRadioButton).check();

await pressButton(page, cancelChanges ? 'Cancel' : 'Apply');
await waitForRender(page, async () => {
await pressButton(page, cancelChanges ? 'Cancel' : 'Apply');
});
}

test.describe('CDXML Enhanced Stereochemistry', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
await waitForPageInit(page);
});

test.afterEach(async ({ page }) => {
Expand Down Expand Up @@ -78,7 +82,7 @@ test.describe('CDXML Enhanced Stereochemistry', () => {

test.describe('CDXML Enhanced Stereochemistry', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
await waitForPageInit(page);
});

test('AND stereo marks - Save as *.cdxml file', async ({ page }) => {
Expand Down Expand Up @@ -144,30 +148,33 @@ test.describe('CDXML Enhanced Stereochemistry', () => {
expect(cdxmlFile).toEqual(cdxmlFileExpected);
});

test('Mixed OR stereo marks - Save as *.cdxml file', async ({ page }) => {
/*
test.fixme(
'Mixed OR stereo marks - Save as *.cdxml file',
async ({ page }) => {
/*
Test case: EPMLSOPKET-4726
Description: The structure is saved/opened correctly as *.cdxml file.
All enhanced stereochemistry features are present after opening.
*/
await openFileAndAddToCanvas('CDXML/mixed-or-stereo-marks.cdxml', page);
const expectedFile = await getCdxml(page);
await saveToFile(
'CDXML/mixed-or-stereo-marks-expected.cdxml',
expectedFile,
);

const { fileExpected: cdxmlFileExpected, file: cdxmlFile } =
await receiveFileComparisonData({
page,
expectedFileName:
'tests/test-data/CDXML/mixed-or-stereo-marks-expected.cdxml',
});

expect(cdxmlFile).toEqual(cdxmlFileExpected);
});

test('Mixed stereo marks - Save as *.cdxml file', async ({ page }) => {
await openFileAndAddToCanvas('CDXML/mixed-or-stereo-marks.cdxml', page);
const expectedFile = await getCdxml(page);
await saveToFile(
'CDXML/mixed-or-stereo-marks-expected.cdxml',
expectedFile,
);

const { fileExpected: cdxmlFileExpected, file: cdxmlFile } =
await receiveFileComparisonData({
page,
expectedFileName:
'tests/test-data/CDXML/mixed-or-stereo-marks-expected.cdxml',
});

expect(cdxmlFile).toEqual(cdxmlFileExpected);
},
);

test.fixme('Mixed stereo marks - Save as *.cdxml file', async ({ page }) => {
/*
Test case: EPMLSOPKET-4727
Description: The structure is saved/opened correctly as *.cdxml file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
openFileAndAddToCanvas,
saveToFile,
delay,
waitForIndigoToLoad,
} from '@utils';
import { waitForPageInit } from '@utils/common/loaders/waitForPageInit';
import { getCml } from '@utils/formats';

async function openFileAddToCanvasTakeScreenshot(page: Page, fileName: string) {
Expand All @@ -17,8 +17,7 @@ async function openFileAddToCanvasTakeScreenshot(page: Page, fileName: string) {

test.describe('CML files', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
await waitForIndigoToLoad(page);
await waitForPageInit(page);
});

test('Open and Save files - CML - CML for empty canvas', async ({ page }) => {
Expand Down Expand Up @@ -80,25 +79,28 @@ test.describe('CML files', () => {
expect(cmlFile).toEqual(cmlFileExpected);
});

test('Open and Save file - CML - CML for reaction', async ({ page }) => {
/**
test.fixme(
'Open and Save file - CML - CML for reaction',
async ({ page }) => {
/**
* Test case: EPMLSOPKET-1947
Description: Saved cml file with structure is compering with paste reaction from rxn file
*/
await openFileAddToCanvasTakeScreenshot(page, 'cml-1947-reaction.rxn');
// check that structure opened from file is displayed correctly
await openFileAddToCanvasTakeScreenshot(page, 'cml-1947-reaction.rxn');
// check that structure opened from file is displayed correctly

const expectedFile = await getCml(page);
await saveToFile('cml-1947-reaction-expected.cml', expectedFile);
const { file: cmlFile, fileExpected: cmlFileExpected } =
await receiveFileComparisonData({
page,
expectedFileName: 'tests/test-data/cml-1947-reaction-expected.cml',
});
// comparing cml file with golden cml file
const expectedFile = await getCml(page);
await saveToFile('cml-1947-reaction-expected.cml', expectedFile);
const { file: cmlFile, fileExpected: cmlFileExpected } =
await receiveFileComparisonData({
page,
expectedFileName: 'tests/test-data/cml-1947-reaction-expected.cml',
});
// comparing cml file with golden cml file

expect(cmlFile).toEqual(cmlFileExpected);
});
expect(cmlFile).toEqual(cmlFileExpected);
},
);

test.fixme(
'Open and Save file - CML - CML for R-group and other features',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a6b2c91

Please sign in to comment.