Skip to content

Commit

Permalink
removed the unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbykumar706584 committed Oct 26, 2023
1 parent 76aadfd commit be370fd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 55 deletions.
87 changes: 47 additions & 40 deletions e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import packageInfo from '../package.json';
import {
showLoginPage, checkLogInOrNot, userFile,
userFolder, userJson, createProjectValidation,
createProjects, unstarProject, starProject,
userValidation, signOut, showActiveUsers,
createProjects, userValidation, signOut, showActiveUsers,
searchProject, checkProjectName, checkNotification,
goToProjectPage, exportProjects, archivedProjects,
unarchivedProjects, goToEditProject, changeAppLanguage,
projectTargetLanguage, userProfileValidaiton,
exportAudioProject, updateDescriptionAbbriviation, changeLicense,
customAddEditLanguage, customProjectTargetLanguage
customAddEditLanguage, customProjectTargetLanguage, starUnstar
} from './common';

const fs = require('fs');
Expand All @@ -23,8 +22,9 @@ let electronApp;
let appPath;
let window;


test("Start the scribe application", async () => {
// This test case handles the user's login or logout actions and related operations.
// 'If logged IN then logout and delete that user from the backend'
test.beforeAll(async ({ userName }) => {
electronApp = await electron.launch({ args: ['main/index.js'] });
appPath = await electronApp.evaluate(async ({ app }) => {
// This runs in the main Electron process, parameter here is always
Expand All @@ -34,10 +34,6 @@ test("Start the scribe application", async () => {
window = await electronApp.firstWindow();
expect(await window.title()).toBe('Scribe Scripture');

})

// This test case handles the user's login or logout actions and related operations.
test('If logged IN then logout and delete that user from the backend', async ({ userName }) => {
// Here you handle user login and logout logic, user data, and folder management.
//Retrieves and parses a JSON file containing user information
const json = await userJson(window, packageInfo, fs, path)
Expand Down Expand Up @@ -77,6 +73,28 @@ test('If logged IN then logout and delete that user from the backend', async ({

});

/* logout and delete the playwright user */
// "Logout and delete that playwright user from the backend"
test.afterAll(async ({ userName }) => {
//Retrieves and parses a JSON file containing user information
const json = await userJson(window, packageInfo, fs, path)
// Constructs the path to the users.json file.
const file = await userFile(window, packageInfo, path)
// constructs the path to a folder/directory name
const folder = await userFolder(window, userName, packageInfo, path)

expect(await window.locator('//*[@id="user-profile-image"]')).toBeVisible()
await window.locator('//*[@id="user-profile-image"]').click()
const currentUser = await window.textContent('[aria-label="userName"]')
expect(await window.locator('//*[@aria-label="signout"]')).toBeVisible()
await window.locator('//*[@aria-label="signout"]').click()
// projects page then logout and delete playwright user
if (currentUser.toLowerCase() === userName.toLowerCase() && await fs.existsSync(folder)) {
await showLoginPage(fs, folder, userName, json, file, window, expect)
}
})


// This test case creates a new user and logs in.
test('Create a new user and login', async ({ userName }) => {
// Here you create a new user and validate the login.
Expand Down Expand Up @@ -129,34 +147,38 @@ test('Click New and Fill project page details to create a new project for audio'
// text translation
test("Star the text translation project", async ({ textProject }) => {
// Here you star a text translation project.
await starProject(window, expect, textProject)
await starUnstar(window, expect, textProject, "star-project", "unstar-project")
})

test("Unstar the text translation project", async ({ textProject }) => {
// Here you unstar a text translation project.
await unstarProject(window, expect, textProject)
await starUnstar(window, expect, textProject, "unstar-project", "star-project")

})

// obs
test("Star the obs project", async ({ obsProject }) => {
// Here you star a OBS project.
await starProject(window, expect, obsProject)
await starUnstar(window, expect, obsProject, "star-project", "unstar-project")

})

test("Unstar the obs project", async ({ obsProject }) => {
// Here you unstar a OBS project.
await unstarProject(window, expect, obsProject)
await starUnstar(window, expect, obsProject, "unstar-project", "star-project")
})

// audio
test("Star the audio project", async ({ audioProject }) => {
// Here you star a Audio project.
await starProject(window, expect, audioProject)
await starUnstar(window, expect, audioProject, "star-project", "unstar-project")

})

test("Unstar the audio project", async ({ audioProject }) => {
// Here you unstar a Audio project.
await unstarProject(window, expect, audioProject)
await starUnstar(window, expect, audioProject, "unstar-project", "star-project")

})

/* text transaltion project */
Expand Down Expand Up @@ -285,16 +307,18 @@ test("Export the audio project in the Downloads folder", async ({ audioProject }
await exportProjects(window, expect, audioProject)
})

//export chapter wise and full audio project
/* export chapter wise project */
test("Export chapter wise audio project in the Downloads folder", async ({ audioProject }) => {
await exportAudioProject(window, expect, audioProject, "Chapter")
})

/* export full audio project */
test("Export full audio project in the Downloads folder", async ({ audioProject }) => {
await exportAudioProject(window, expect, audioProject, "full")
})

/* archive and unarchive project */
// text translation
test("Archive text translation project", async ({ textProject }) => {
await archivedProjects(window, expect, textProject)
})
Expand All @@ -303,6 +327,7 @@ test("Restore text translation project from archived page", async ({ textProject
await unarchivedProjects(window, expect, textProject)
})

// obs project
test("Archive obs project", async ({ obsProject }) => {
await archivedProjects(window, expect, obsProject)
})
Expand All @@ -311,6 +336,7 @@ test("Restore the obs project from archived page", async ({ obsProject }) => {
await unarchivedProjects(window, expect, obsProject)
})

// audio project
test("Archive audio project", async ({ audioProject }) => {
await archivedProjects(window, expect, audioProject)
})
Expand Down Expand Up @@ -441,8 +467,8 @@ test("Update/Edit audio project of description and abbreviation", async ({ audio
})


// custom project with custom language for text translation
test("Custom text translation with custom language project", async ({ customTextTargetLanguage }) => {
/* custom project with custom language for text translation */
test("Create custom text translation with custom language project", async ({ customTextTargetLanguage }) => {
// Navigate to the new project creation page
await expect(window.locator('//a[@aria-label="new"]')).toBeVisible();
await window.locator('//a[@aria-label="new"]').click();
Expand Down Expand Up @@ -473,13 +499,13 @@ test("Custom text translation with custom language project", async ({ customText
await expect(projectName).toBe(customTextTargetLanguage);
})

//Obs and Audio custom target language RTL project
test("Custom obs project with custom language project", async ({ customObsTargetLanguage }) => {
/* Obs and Audio custom target language RTL project */
test("Create custom obs project with custom language project", async ({ customObsTargetLanguage }) => {
// Create a custom OBS project with a custom language
await customProjectTargetLanguage(window, expect, customObsTargetLanguage, "OBS", "custom obs language test description", "cotp", "add-language", "custom obs project language", 'copl', "RTL", "create-language")
})

test("Custom audio project with custom language project", async ({ customAudioTargetLanguage }) => {
test("Create custom audio project with custom language project", async ({ customAudioTargetLanguage }) => {
// Create a custom audio project with a custom language
await customProjectTargetLanguage(window, expect, customAudioTargetLanguage, "Audio", "custom audio language test description", "catp", "add-language", "custom audio project language", 'capl', "RTL", "create-language")
})
Expand Down Expand Up @@ -618,22 +644,3 @@ test("Delete the user from the active tab and check in the archived tab", async
await expect(title).toBe('Projects')
})

/* logout and delete the playwright user */
test("Logout and delete that playwright user from the backend", async ({ userName }) => {
//Retrieves and parses a JSON file containing user information
const json = await userJson(window, packageInfo, fs, path)
// Constructs the path to the users.json file.
const file = await userFile(window, packageInfo, path)
// constructs the path to a folder/directory name
const folder = await userFolder(window, userName, packageInfo, path)

expect(await window.locator('//*[@id="user-profile-image"]')).toBeVisible()
await window.locator('//*[@id="user-profile-image"]').click()
const currentUser = await window.textContent('[aria-label="userName"]')
expect(await window.locator('//*[@aria-label="signout"]')).toBeVisible()
await window.locator('//*[@aria-label="signout"]').click()
// projects page then logout and delete playwright user
if (currentUser.toLowerCase() === userName.toLowerCase() && await fs.existsSync(folder)) {
await showLoginPage(fs, folder, userName, json, file, window, expect)
}
})
21 changes: 6 additions & 15 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// Function to check if the user is logged in or not
export const checkLogInOrNot = async (window, expect, textVisble) => {
if (textVisble) {
console.log("hello")
// If title is "Projects" (english) or Not(other language) visible in project list page,
const title = await window.locator('//*[@aria-label="projects"]', {timeout:5000}).textContent()
expect(title).toBe(title)
} else {
// await window.waitForSelector('//*[@aria-label="welcome"]', { timeout: 5000 })
console.log("world")
// If 'projects' is not visible, check the 'welcome' element
const welcome = await window.locator('//*[@aria-label="welcome"]', {timeout:5000}).textContent()
await expect(welcome).toBe(welcome)
await window.reload()
}
return textVisble;
}

// get the user path
const userPath= async (window) => {
const path = await window.evaluate(() => Object.assign({}, window.localStorage))
return path.userPath
}

// Retrieves and parses a JSON file containing user information
export const userJson = async (window, packageInfo, fs, path) => {
const file = path.join(await userPath(window), packageInfo.name, 'users', 'users.json');
Expand Down Expand Up @@ -113,7 +113,7 @@ export const createProjects = async (window, expect, projectname, flavorType, de
}

/* Functions for managing project stars/unstars. */
export const starUnstar = async (window, expect, name, clickStar) => {
export const starUnstar = async (window, expect, name, clickStar, expectAttribute) => {
await expect(window.locator('//table[@id="projects-list"]')).toBeVisible()
const table = window.locator('//table[@id="projects-list"]')
const body = table.locator('//*[@id="projects-list-body"]')
Expand All @@ -124,23 +124,14 @@ export const starUnstar = async (window, expect, name, clickStar) => {
if (await tds.nth(1).textContent() === name) {
expect(await tds.first().locator(`[aria-label=${clickStar}]`)).toBeVisible()
await tds.first().locator(`[aria-label=${clickStar}]`).click()
const attribute = await rows.nth(0).locator('td').nth(0).locator('button')
await expect(attribute).toHaveAttribute('aria-label', expectAttribute)
await window.waitForTimeout(500)
break
}
}
}

// Stars a project
export const starProject = async (window, expect, projectname) => {
// Call the common function to star the project.
await starUnstar(window, expect, projectname, "star-project")
}

// Untars a project
export const unstarProject = async (window, expect, projectname) => {
// Call the common function to unstar the project.
await starUnstar(window, expect, projectname, "unstar-project")
}

// Searches for a project with a given name.
export const searchProject = async (window, expect, projectName, searchtext) => {
Expand Down

0 comments on commit be370fd

Please sign in to comment.