Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export tests #175

Closed
wants to merge 13 commits into from
154 changes: 145 additions & 9 deletions e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { test, expect } from './myFixtures';
import packageInfo from '../package.json';
import { showLoginPage, checkLogInOrNot, userFile, userFolder, userJson, createProjectValidation, createProjects, unstarProject, starProject, userValidation, signOut, showActiveUsers, searchProject, checkProjectName, checkNotification, goToProjectPage } from './common';
import { showLoginPage, checkLogInOrNot, userFile, userFolder, userJson, createProjectValidation, createProjects, unstarProject, starProject, userValidation, signOut, showActiveUsers, searchProject, checkProjectName, checkNotification, goToProjectPage, exportProjects, archivedProjects, unarchivedProjects, goToEditProject, changeAppLanguage } from './common';

const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -63,8 +63,8 @@ test('Create a new user and login', async ({ userName }) => {
await window.locator('//input[@placeholder="Username"]').fill(userName)
await expect(window.locator('//button[@type="submit"]')).toBeVisible()
await window.click('[type=submit]');
const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent();
expect(title).toBe('Projects');
const title = await window.locator('//*[@aria-label="projects"]').textContent();
await expect(title).toBe('Projects');
})


Expand Down Expand Up @@ -231,8 +231,144 @@ test("About scribe Application and License", async () => {
await window.click('[aria-label=license-button]');
await window.locator('//*[@aria-label="about-description"]').click()
await window.click('[aria-label=close-about]');
const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent();
expect(title).toBe('Projects');
const title = await window.locator('//*[@aria-label="projects"]').textContent();
await expect(title).toBe('Projects');
})

/* exports project */
test("Export text translation project in the Downloads folder", async ({ textProject }) => {
await exportProjects(window, expect, textProject)
})

test("Export the obs project in the Downloads folder", async ({ obsProject }) => {
await exportProjects(window, expect, obsProject)
})

test("Export the audio project in the Downloads folder", async ({ audioProject }) => {
await exportProjects(window, expect, audioProject)
})

/*archive and unarchive project */
test("Archive text translation project", async ({ textProject }) => {
await archivedProjects(window, expect, textProject)
})

test("Restore text translation project from archived page", async ({ textProject }) => {
await unarchivedProjects(window, expect, textProject)
})

test("Archive obs project", async ({ obsProject }) => {
await archivedProjects(window, expect, obsProject)
})

test("Restore the obs project from archived page", async ({ obsProject }) => {
await unarchivedProjects(window, expect, obsProject)
})

test("Archive audio project", async ({ audioProject }) => {
await archivedProjects(window, expect, audioProject)
})

test("Restore the audio project from the archived page", async ({ audioProject }) => {
await unarchivedProjects(window, expect, audioProject)
})

/*Update/Edit the text translation project */
test("Update/Edit text translation project of description and abbreviation", async ({ textProject }) => {
await goToEditProject(window, expect, textProject)
const description = await window.textContent('//textarea[@id="project_description"]')
await expect(description).toBe('test description')
await window.locator('//textarea[@id="project_description"]').fill('edit test version')
const editDescription = await window.textContent('//textarea[@id="project_description"]')
await expect(editDescription).toBe('edit test version')
await window.locator('input[name="version_abbreviated"]').fill('tvs')
await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible()
await window.locator('//button[@aria-label="save-edit-project"]').click()
await window.waitForTimeout(3000)
const title = await window.textContent('[aria-label=projects]');
expect(await title).toBe('Projects')
})

test("Update/Edit text translation project scope mark and luke", async ({ textProject }) => {
await goToEditProject(window, expect, textProject)
await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible()
await window.locator('//button[@id="open-advancesettings"]').click()
await expect(window.locator('//div[@aria-label="custom-book"]')).toBeVisible()
await window.locator('//div[@aria-label="custom-book"]').click()
await window.locator('//*[@aria-label="nt-Mark"]').click()
await window.locator('//*[@aria-label="nt-Luke"]').click()
await window.locator('//*[@id="save-canon"]').click()
await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible()
await window.locator('//button[@aria-label="save-edit-project"]').click()
await window.waitForTimeout(2500)
const title = await window.textContent('[aria-label=projects]');
expect(await title).toBe('Projects')
})

test("Update/Edit text translation project scope custom book into NT", async ({ textProject }) => {
await goToEditProject(window, expect, textProject)
await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible()
await window.locator('//button[@id="open-advancesettings"]').click()
await expect(window.locator('//div[@aria-label="new-testament"]')).toBeVisible()
await window.locator('//div[@aria-label="new-testament"]').click()
await window.locator('//button[contains(text(),"Ok")]').click()
await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible()
await window.locator('//button[@aria-label="save-edit-project"]').click()
await window.waitForTimeout(3000)
const title = await window.textContent('[aria-label=projects]');
expect(await title).toBe('Projects')
})

test("Update/Edit text transaltion project scope custom book genesis and exodus from OT", async ({ textProject }) => {
await goToEditProject(window, expect, textProject)
await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible()
await window.locator('//button[@id="open-advancesettings"]').click()
await expect(window.locator('//div[@aria-label="custom-book"]')).toBeVisible()
await window.locator('//div[@aria-label="custom-book"]').click()
await window.locator('//*[@aria-label="ot-Genesis"]').click()
await window.locator('//*[@aria-label="ot-Exodus"]').click()
await window.locator('//*[@id="save-canon"]').click()
await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible()
await window.locator('//button[@aria-label="save-edit-project"]').click()
await window.waitForTimeout(3000)
const title = await window.textContent('[aria-label=projects]');
expect(await title).toBe('Projects')
})

test("Update/Edit text translation project license", async ({ textProject }) => {
await goToEditProject(window, expect, textProject)
await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible()
await window.locator('//button[@id="open-advancesettings"]').click()
await window.getByRole('button', { name: 'CC BY-SA' }).click()
await window.getByRole('option', { name: 'CC BY', exact: true }).click()
await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible()
await window.locator('//button[@aria-label="save-edit-project"]').click()
await window.waitForTimeout(3000)
const title = await window.textContent('[aria-label=projects]');
expect(await title).toBe('Projects')
})


/*changing app language */
test("App language change English to hindi", async () => {
await changeAppLanguage(window, expect, "English", "Hindi")
const snackbar = await window.locator('//*[@id="__next"]/div[2]/div/div').isVisible()
expect(await snackbar === true)
const textHindi = await window.locator('//*[@aria-label="projects"]').allTextContents()
expect(await textHindi[0]).toBe("प्रोफ़ाइल")
})

test("App language change Hindi to English", async () => {
expect(await window.locator('//*[@aria-label="projectList"]')).toBeVisible()
await window.locator('//*[@aria-label="projectList"]').click()
await window.waitForTimeout(2000)
const title = await window.textContent('[aria-label=projects]', { timeout: 10000 });
expect(await title).toBe('प्रोजेक्ट्स')
await changeAppLanguage(window, expect, "Hindi", "English")
const snackbar = await window.locator('//*[@id="__next"]/div[2]/div/div').isVisible()
const profile = await window.locator('//*[@aria-label="projects"]').allTextContents()
expect(await profile[0]).toBe("Profile")
expect(await snackbar === true)
})

/*signing out */
Expand All @@ -249,8 +385,8 @@ test("Click the view users button, log in with playwright user, and sign out", a
if (await div.nth(i).textContent() === userName.toLowerCase()) {
await div.nth(i).click()
await window.waitForTimeout(1000)
const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent();
expect(title).toBe('Projects')
const title = await window.locator('//*[@aria-label="projects"]').textContent();
await expect(title).toBe('Projects')
await signOut(window, expect)
break
}
Expand Down Expand Up @@ -281,8 +417,8 @@ test("Delete the user from the active tab and check in the archived tab", async
break
}
}
const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent();
expect(title).toBe('Projects')
const title = await window.locator('//*[@aria-label="projects"]').textContent();
await expect(title).toBe('Projects')
})

/* logout and delete the playwright user */
Expand Down
106 changes: 93 additions & 13 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
export const checkLogInOrNot = async (window, expect) => {
await window.waitForSelector('//*[@id="__next"]/div', '//*[@id="__next"]/div[1]', { timeout: 5000 })
const textVisble = await window.locator('//h1[@aria-label="projects"]', { timeout: 5000 }).isVisible()
const textVisble = await window.locator('//*[@aria-label="projects"]', { timeout: 5000 }).isVisible()
if (textVisble) {
const title = await window.locator('//h1[@aria-label="projects"]').textContent()
await expect(title).toBe('Projects')

const title = await window.locator('//*[@aria-label="projects"]').textContent()
if(await title === "Projects"){
await expect(title).toBe("Projects")
}else{
await expect(title).not.toBe('Projects')
}
} else {
const welcome = await window.locator('//h2[@aria-label="welcome"]', {timeout:5000}).textContent()
await expect(welcome).toBe("Welcome!")
Expand Down Expand Up @@ -55,16 +58,15 @@ export const userValidation = async (window, expect) => {
await expect(window.locator('//button[@type="submit"]')).toBeVisible()
await window.click('[type=submit]');
const lengthError = await window.locator('//*[@id="show-error"]')
expect(await lengthError === true)
expect(await lengthError.textContent()).toBe('The input has to be between 3 and 15 characters long')
}

// project creation validation
export const createProjectValidation = async (window, expect) => {
await window.locator('//button[@aria-label="create"]').click()
const snackbar = await window.textContent('//*[@id="__next"]/div/div[2]/div[2]/div/div')
expect(await snackbar).toBe('Fill all the fields')
const title = await window.locator('//h1[@aria-label="projects"]').textContent();
const snackbar = await window.locator('//*[@aria-label="snack-text"]').textContent()
await expect(snackbar).toBe('Fill all the fields')
const title = await window.locator('//*[@aria-label="projects"]').textContent();
await expect(title).toBe('New Project');
await window.waitForTimeout(3000)
}
Expand Down Expand Up @@ -159,8 +161,8 @@ export const checkProjectName = async (window, expect, name) => {
}
}
await window.waitForTimeout(1000)
const projectname = await window.locator('[aria-label=editor-project-name]', { timeout: 10000 }).textContent()
expect(projectname).toBe(name);
const projectname = await window.locator('[aria-label=editor-project-name]').textContent()
await expect(projectname).toBe(name);
}

// check notification
Expand All @@ -175,12 +177,90 @@ export const checkNotification = async (window, expect) => {
export const goToProjectPage = async (window, expect) => {
await expect(window.locator('//*[@id="back-button"]')).toBeVisible()
await window.locator('//*[@id="back-button"]').click();
const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent();
expect(title).toBe('Projects');
const title = await window.locator('//*[@aria-label="projects"]').textContent();
await expect(title).toBe('Projects');
await window.waitForTimeout(1000)
}

// sing out
// common function for looping the table
export const commonUtilArchive = async (window, expect, projectName, clickItem) => {
await expect(window.locator('//*[@id="projects-list"]')).toBeVisible()
const table = window.locator('//*[@id="projects-list"]')
const body = table.locator('//*[@id="projects-list-unstar"]')
const rows = await body.locator('tr')
for (let i = 0; i < await rows.count(); i++) {
const row = await rows.nth(i);
const tds = await row.locator('td');
if (await tds.nth(1).textContent() === projectName) {
expect(await tds.last().locator('[aria-label="unstar-expand-project"]')).toBeVisible()
await tds.last().locator('[aria-label="unstar-expand-project"]').click()
await window.waitForTimeout(1000)
await window.locator('//*[@aria-label="unstar-menu-project"]').click()
await window.locator(`//*[@aria-label="${clickItem}"]`).click()
break
}
}
}

// export projects
export const exportProjects = async (window, expect, projectname) => {
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage))
const userpath = newpath.userPath.split(".")[0]
await commonUtilArchive(window, expect, projectname, "unstar-export-project")
await expect(window.locator('input[name="location"]')).toBeVisible()
await window.locator('input[name="location"]').fill(`${userpath}/Downloads`)
await window.locator('//*[@aria-label="export-projects"]').click()
await window.waitForTimeout(2000)
const snackText = await window.locator('//*[@aria-label="snack-text"]').textContent()
await expect(snackText).toBe("Exported Successfully")
await window.locator('[aria-label=unstar-arrow-up]').click()
}


// archived projects
export const archivedProjects = async (window, expect, projectname) => {
await commonUtilArchive(window, expect, projectname, "unstar-archive-restore-project")
await window.locator('//*[@aria-label="archived-projects"]').click()
const archiveTitle = await window.locator('//*[@aria-label="projects"]').textContent()
await expect(archiveTitle).toBe("Archived projects")
const projectName = await window.innerText(`//div[@id="${projectname}"]`)
await expect(projectName).toBe(projectname);
await window.locator('//*[@aria-label="active-projects"]').click()
const projectTitle = await window.locator('//*[@aria-label="projects"]').textContent()
await expect(projectTitle).toBe('Projects');
}

// unarchived projects
export const unarchivedProjects = async (window, expect, projectname) => {
await window.locator('//*[@aria-label="archived-projects"]').click()
await commonUtilArchive(window, expect, projectname, "unstar-archive-restore-project")
const archiveTitle = await window.locator('//*[@aria-label="projects"]').textContent()
await expect(archiveTitle).toBe("Archived projects")
await window.locator('//*[@aria-label="active-projects"]').click()
const projectName = await window.innerText(`//div[@id="${projectname}"]`)
await expect(projectName).toBe(projectname);
const projectTitle = await window.locator('//*[@aria-label="projects"]').textContent()
await expect(projectTitle).toBe('Projects');
}

export const goToEditProject = async (window, expect, projectName) => {
await commonUtilArchive(window, expect, projectName, "edit-project")
const editTitle = await window.locator('//*[@aria-label="projects"]').textContent()
await expect(editTitle).toBe('Edit Project');
}

export const changeAppLanguage = async (window, expect, fromLanguage, toLanguage) => {
expect(await window.locator('//*[@id="user-profile"]')).toBeVisible()
await window.locator('//*[@id="user-profile"]').click()
expect(await window.locator('//*[@aria-label="user-profile"]')).toBeVisible()
await window.locator('//*[@aria-label="user-profile"]').click()
await window.getByRole('button', { name: fromLanguage }).click()
await window.getByRole('option', { name: toLanguage }).click()
expect(await window.locator('//*[@id="save-profile"]')).toBeVisible()
await window.locator('//*[@id="save-profile"]').click()
}

// sign out
export const signOut = async (window, expect) => {
await expect(window.locator('//*[@id="user-profile"]')).toBeVisible()
await window.locator('//*[@id="user-profile"]').click()
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/SnackBar/SnackBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const SnackBar = ({
>
<XMarkIcon />
</button>
<p>
<p aria-label="snack-text">
{snackText}
</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions renderer/src/layouts/projects/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ export default function ProjectsLayout(props) {
{showArchived ? (
<>
<ComputerDesktopIcon className="h-4 mr-2 text-white" />
<span>{t('label-active')}</span>
<span aria-label="active-projects">{t('label-active')}</span>
</>
) : (
<>
<ArchiveBoxIcon className="h-4 mr-2 text-white" />
<span>{t('label-archived')}</span>
<span aria-label="archived-projects">{t('label-archived')}</span>
</>
)}
</button>
Expand Down
1 change: 1 addition & 0 deletions renderer/src/modules/projects/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export default function UserProfile() {

<button
type="submit"
id="save-profile"
className=" w-20 h-9 bg-success shadow-md font-light text-white border-none text-xs leading-5 rounded uppercase mb-5"
>
{t('btn-save')}
Expand Down
Loading
Loading