Skip to content

Commit

Permalink
Merge pull request #134 from bible-technology/login_test
Browse files Browse the repository at this point in the history
playwright login test
  • Loading branch information
vipinpaul authored Sep 26, 2023
2 parents b0c18a6 + ea14515 commit 25ad4ef
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 1,282 deletions.
903 changes: 53 additions & 850 deletions e2e-tests/base.test.ts

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export const checkLogInOrNot = async (window, expect) => {
await window.waitForSelector('//*[@id="__next"]/div', '//*[@id="__next"]/div[1]')
const textVisble = await window.locator('//h1["@aria-label=projects"]', { timeout: 3000 }).isVisible()
if (textVisble) {
const title = await window.textContent('[aria-label=projects]')
await expect(title).toBe('Projects')

} else {
const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2')
await expect(welcome).toBe("Welcome!")
await window.reload()
}
return textVisble;
}

export const filterUser = (json, name) => {
const filtered = json.filter((user) =>
user.username.toLowerCase() !== name.toLowerCase()
)
return filtered
}

export const userJson = async (window, packageInfo, fs, path) => {
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage))
const file = path.join(newpath.userPath, packageInfo.name, 'users', 'users.json');
const data = await fs.readFileSync(file);
return JSON.parse(data);
}

export const userFolder = async (window, userName, packageInfo, path) => {
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage))
return path.join(newpath.userPath, packageInfo.name, 'users', userName.toLowerCase())
}

export const userFile = async (window, packageInfo, path) => {
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage))
return path.join(newpath.userPath, packageInfo.name, 'users', 'users.json');
}

export const removeFolderAndFile = async (fs, folder, userName, json, file) => {
fs.rmSync(folder, { recursive: true, force: true })
const filtered = json.filter((item) =>
item.username.toLowerCase() !== userName.toLowerCase()
)
return await fs.writeFileSync(file, JSON.stringify(filtered))
}

export const showLoginPage = async (fs, folder, userName, json, file, window, expect) => {
await removeFolderAndFile(fs, folder, userName, json, file)
const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2')
await expect(welcome).toBe("Welcome!")
await window.reload()
}
33 changes: 33 additions & 0 deletions e2e-tests/myFixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {test as myTest} from "@playwright/test"

type myFixture = {
userName: string
textProject: string,
obsProject: string,
audioProject: string,
syncName:string,
doorUser:string,
doorPassword:string,
flavorText:string,
flavorObs:string
textUnderscore:string,
obsUnderscore:string,
obsUrduProject:string,
}
const myFixtureTest = myTest.extend<myFixture>({
userName : "Playwright user",
textProject: "Translation test project",
obsProject: "Obs test project",
textUnderscore: "Translation_test_project",
obsUnderscore: "Obs_test_project",
audioProject: "Audio test project",
syncName:"Sync_Collab_Test",
doorUser:"bobby",
doorPassword:"Bobby@123",
flavorText: "textTranslation",
flavorObs: "textStories",
obsUrduProject: "Obs urdu project",
})

export const test = myFixtureTest;
export { expect } from '@playwright/test';
107 changes: 0 additions & 107 deletions e2e-tests/obsStroy.test.ts

This file was deleted.

Loading

0 comments on commit 25ad4ef

Please sign in to comment.