From 45c20ca4dee76e6187c4cee14aba39668f52cf23 Mon Sep 17 00:00:00 2001 From: Bobbykumar706584 Date: Thu, 16 Nov 2023 15:22:45 +0530 Subject: [PATCH 01/10] added 2 test for adding and removing reference panel --- e2e-tests/base.test.ts | 28 ++++++++++++++++++- e2e-tests/common.js | 19 +++++++++++-- .../Sync/Gitea/EditorSync/EditorSync.js | 2 +- .../src/layouts/editor/ConfirmationModal.js | 3 +- renderer/src/layouts/editor/EditorSection.js | 8 ++++-- .../src/layouts/editor/SectionPlaceholder1.js | 2 ++ .../src/layouts/editor/SectionPlaceholder2.js | 2 ++ 7 files changed, 56 insertions(+), 8 deletions(-) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 9d122cea9..c83b5b442 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -11,7 +11,7 @@ import { exportAudioProject, updateDescriptionAbbriviation, changeLicense, customAddEditLanguage, customProjectTargetLanguage, starUnstar, clickUserImageToLogout, confirmBookInEditor, checkingUpdatedLicense, - createUser, projectPageExpect + createUser, projectPageExpect, removeResource } from './common'; const fs = require('fs'); @@ -277,6 +277,32 @@ test('Add content in verses 1 and 2 in the obs story 1 editor', async () => { expect(verse3).toBe('Story content added in verse 3'); }); +test('Adding panels', async () => { + const addPanel = await window.locator('//*[@aria-label="add-panels"]'); + await addPanel.click() + let title = await window.innerText('//*[@aria-label="number-of-panels"]'); + expect(title).toBe('2'); + await addPanel.click() + title = await window.innerText('//*[@aria-label="number-of-panels"]'); + expect(title).toBe('3'); + await addPanel.click() + title = await window.innerText('//*[@aria-label="number-of-panels"]'); + expect(title).toBe('1'); +}); + +test("Adding 2 panels and removing from the editor", async () => { + await window.waitForSelector('//*[@aria-label="add-panels"]') + const addPanel = await window.locator('//*[@aria-label="add-panels"]') + await addPanel.click() + expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('2') + await addPanel.click() + expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('3') + await removeResource(window, expect, 1, "confirm-remove") + expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('2') + await removeResource(window, expect, 3, "confirm-remove") + expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('1') +}) + test('Increase the font size in the obs editor', async () => { await window.waitForSelector('//*[@aria-label="increase-font"]', { timeout: 5000 }); await window.locator('//*[@aria-label="increase-font"]').click(); diff --git a/e2e-tests/common.js b/e2e-tests/common.js index f73aa697b..1176a7b73 100644 --- a/e2e-tests/common.js +++ b/e2e-tests/common.js @@ -38,6 +38,7 @@ export const clickUserImageToLogout = async (window, expect, userName, path, fs, // constructs the path to a folder/directory name const folder = await userFolder(window, userName, packageInfo, path) // Check if user profile image is visible + await window.waitForSelector('//*[@id="user-profile-image"]') const userProfileImage = window.locator('//*[@id="user-profile-image"]'); expect(await userProfileImage.isVisible()).toBeTruthy(); await userProfileImage.click(); @@ -78,8 +79,10 @@ export const projectPageExpect = async (window, expect) => { export const clickUserImage = async (window, expect, itemClick) => { // Ensure the user profile image is visible and click on it. - expect(await window.locator('//*[@id="user-profile-image"]')).toBeVisible(); - await window.locator('//*[@id="user-profile-image"]').click(); + await window.waitForSelector('//*[@id="user-profile-image"]') + const imageClick = await window.locator('//*[@id="user-profile-image"]') + expect(await imageClick).toBeVisible(); + await imageClick.click(); // Verify that the user profile is visible and click on it. await window.waitForSelector(`//*[@aria-label="${itemClick}"]`) expect(await window.locator(`//*[@aria-label="${itemClick}"]`)).toBeVisible(); @@ -221,6 +224,18 @@ export const checkProjectName = async (window, expect, name) => { await expect(projectname).toBe(name); } +// removing resource +export const removeResource = async (window, expect, resourcePaneNo, confirmButton) => { + await window.waitForSelector(`//*[@aria-label="remove-resource-${resourcePaneNo}"]`) + const closePanel = await window.locator(`//*[@aria-label="remove-resource-${resourcePaneNo}"]`) + expect(await closePanel).toBeVisible() + await closePanel.click() + const title = await window.locator('//*[@aria-label="confirm-title"]').textContent() + await expect(title).toBe(title) + expect(await window.locator(`//*[@aria-label="${confirmButton}"]`)).toBeVisible() + await window.locator(`//*[@aria-label="${confirmButton}"]`).click() +} + // Checks for notifications. export const checkNotification = async (window, expect, projectname) => { // Wait for the notification button to appear and click it. diff --git a/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js b/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js index afe89eff5..d9fedf56d 100644 --- a/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js +++ b/renderer/src/components/Sync/Gitea/EditorSync/EditorSync.js @@ -114,7 +114,7 @@ function EditorSync({ selectedProject }) { ) : (
- + {title}
@@ -91,6 +91,7 @@ export default function ConfirmationModal({ {buttonName && (