Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbykumar706584 committed Sep 26, 2023
2 parents 57ba965 + 25ad4ef commit a0e580b
Show file tree
Hide file tree
Showing 61 changed files with 1,692 additions and 75,890 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ It is relatively easy to setup the application locally for development.
This is an example of how to list things you need to use the software and how to install them.

- [Node.js ^16.15.1](https://nodejs.org/en/)
- [NPM ^8.11.0](https://www.npmjs.com/get-npm)
- [YARN ^1.22.19](https://yarnpkg.com/getting-started)

### Installation

1. Fork and clone this repository
2. Install dependencies with `npm install`
3. Start the application with `npm start`
4. Checkout the web version with `npm run dev`
2. Install dependencies with `yarn install`
3. Start the application with `yarn start`
4. Checkout the web version with `yarn dev`
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

Expand Down Expand Up @@ -107,8 +107,8 @@ Usage: logger.[level]("<filename>, <message>")
- [Jest](https://testing-library.com/docs/react-testing-library/intro)
- [React Testing Library](https://jestjs.io/docs/en/getting-started)

6. Run `npm run lint:fix` for code to adapt our linting rules
7. Run `npm run build` for build checks
6. Run `yarn lint:fix` for code to adapt our linting rules
7. Run `yarn build` for build checks
8. Commit your Changes (`git commit -m 'Add some NewFeatures'`)
9. Push to the Branch (`git push origin feature/NewFeature`)
10. Open a Pull Request and make sure all checks have passed
Expand Down
30 changes: 30 additions & 0 deletions docs/Development/Offline-Merge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Offline Merge Development Document

Offline Merge or Local merge is a functionality to combine the project based on [<span style="color:#f0504a">Scripture Burrito</span>](https://docs.burrito.bible/en/latest/) with contributions from different collabarators

- Current Support for OBS

## Expected Work Flow

- open scribe app and create OBS project
- export and share the project with collabarators
- Collabarator need to import the project on his/her scribe app and edit assigned story/sections
- export the project after finishing the work and send back the project to manager / owner. (He can also merge if he have somebody else changes).
- Owner / Manager import the project from the collabarator to his/her scribe app
- When the owner import the project , he will be prompted with a popup have 3 options _cancel_ , _replace_ and _merge_

- click and proceed with _**merge**_ option.

### Case 1 - No Conflict

- if there is no conflict in the merge process. Success message will be shown and all the combined changes will be avaialble in the project in scribe

### Case 2 - Conflict

- If there is a conflict in the merge process , a new window of _**Conflict Resolver**_ will be pop up

- In the conflict Resolver window , all files with conflict will be listed and conflicted content will be show in the editor window with multiple option to accept which change need to accept .

- once all the conflict is finished . click done and finish the merge process

- Now the project in scribe will have all combined changes.
134 changes: 28 additions & 106 deletions e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import { test, expect } from './myFixtures';
import packageInfo from '../package.json';
import { DisplayLogin, checkLogInOrNot, commonFile, commonFolder, commonJson, createProjects, createUserValidation, projectValidation, searchProject, starProject, unstarProject } from './common';
import { showLoginPage, checkLogInOrNot, userFile, userFolder, userJson, createUserValidation } from './common';

const fs = require('fs');
const path = require('path');
const { _electron: electron } = require('@playwright/test');

let electronApp;
Expand All @@ -24,31 +25,31 @@ test("Start the scribe application", async () => {

})

test('Check whether the app is being logged IN', async ({ userName }) => {
await checkLogInOrNot(window, expect, userName)
test('Check whether the app is being logged IN', async () => {
await checkLogInOrNot(window, expect)
});

test('If logged IN then logout and delete that user from the backend', async ({ userName }) => {
///return json
const json = await commonJson(window, userName, packageInfo, fs)
/// return file
const file = await commonFile(window, packageInfo)
/// return folde name
const folder = await commonFolder(window, userName, packageInfo)

if (await checkLogInOrNot(window, expect, userName)) {
///user json
const json = await userJson(window, packageInfo, fs, path)
/// user file
const file = await userFile(window, packageInfo, path)
/// user folde name
const folder = await userFolder(window, userName, packageInfo, path)

if (await checkLogInOrNot(window, expect)) {
await window.getByRole('button', { name: "Open user menu" }).click()
const currentUser = await window.textContent('[aria-label="userName"]')
await window.getByRole('menuitem', { name: "Sign out" }).click()
/// projects page then logout and delete playwright user
if (currentUser.toLowerCase() === userName.toLowerCase() && await fs.existsSync(folder)) {
await DisplayLogin(fs, folder, userName, json, file, window, expect)
await showLoginPage(fs, folder, userName, json, file, window, expect)
}
} else {
///loging page, if playwright user exist then reload app and remove
const existUser = json.some((item) => item.username.toLowerCase() === userName.toLowerCase())
if (existUser && await fs.existsSync(folder)) {
await DisplayLogin(fs, folder, userName, json, file, window, expect)
await showLoginPage(fs, folder, userName, json, file, window, expect)
}
}

Expand All @@ -65,97 +66,18 @@ test('Create a new user and login', async ({ userName }) => {
})


/*CREATE PROJECTS FOR ALL FLAVOR TYPE */
// // /* Translation Project */
test('Click New and Fill project page details to create a new project for text translation', async ({ textProject }) => {
await projectValidation(window, expect)
await expect(window.locator('//input[@id="project_name"]')).toBeVisible()
await window.locator('//input[@id="project_name"]').fill(textProject)
await expect(window.locator('//textarea[@id="project_description"]')).toBeVisible()
await window.locator('//textarea[@id="project_description"]').fill('test description')
await expect(window.locator('//input[@id="version_abbreviated"]')).toBeVisible()
await window.locator('//input[@id="version_abbreviated"]').fill('ttp')
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 window.locator('//button[@aria-label="create"]').click()
const notifyMe = await window.textContent('//*[@id="__next"]/div/div[2]/div[2]/div/div')
expect(await notifyMe).toBe('New project created')
const projectName = await window.innerText(`//div[@id="${textProject}"]`)
expect(projectName).toBe(textProject);
const title = await window.textContent('[aria-label=projects]');
expect(title).toBe('Projects');

});

// ///Obs translation project
test('Click New and Fill project page details to create a new project for obs', async ({ obsProject }) => {
await createProjects(window, expect, obsProject, "OBS", "test description", "otp")
})

/////Audio project
test('Click Click New and Fill project page details to create a new project for audio', async ({ audioProject }) => {
await createProjects(window, expect, audioProject, "Audio", "test description", "atp")
})

// /* STAR & UNSTAR PROJECT */
///text translation
test("Star the text project", async ({ textProject }) => {
await starProject(window, expect, textProject)
})

test("Unstar the text project", async ({ textProject }) => {
await unstarProject(window, expect, textProject)
test("Logout and delete that playwright user from the backend", async ({ userName }) => {
///user json
const json = await userJson(window, packageInfo, fs, path)
/// user file
const file = await userFile(window, packageInfo, path)
/// user folde name
const folder = await userFolder(window, userName, packageInfo, path)
await window.getByRole('button', { name: "Open user menu" }).click()
const currentUser = await window.textContent('[aria-label="userName"]')
await window.getByRole('menuitem', { name: "Sign out" }).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)
}
})

// ///obs
// test("Star the obs project", async ({ obsProject }) => {
// await starProject(window, expect, obsProject)
// })

// test("Unstar the obs project", async ({ obsProject }) => {
// await unstarProject(window, expect, obsProject)
// })

// // ///audio
// test("Star the audio project", async ({ audioProject }) => {
// await starProject(window, expect, audioProject)
// })

// test("Unstar the audio project", async ({ audioProject }) => {
// await unstarProject(window, expect, audioProject)
// })

test('Search a text project in all projects list', async ({ textProject }) => {
await searchProject(window, expect, textProject, 'translation')
});



// test('Search an obs project in all projects list', async ({ obsProject }) => {
// await searchProject(window, expect, obsProject, 'obs')
// });

// test('Search an audio project in all projects list', async ({ audioProject }) => {
// await searchProject(window, expect, audioProject, 'audio')
// });



// test("Logout and delete that playwright user from the backend", async ({ userName }) => {
// ///return json
// const json = await commonJson(window, userName, packageInfo, fs)
// /// return file
// const file = await commonFile(window, packageInfo)
// /// return folde name
// const folder = await commonFolder(window, userName, packageInfo)
// await window.getByRole('button', { name: "Open user menu" }).click()
// const currentUser = await window.textContent('[aria-label="userName"]')
// await window.getByRole('menuitem', { name: "Sign out" }).click()
// /// projects page then logout and delete playwright user
// if (currentUser.toLowerCase() === userName.toLowerCase() && await fs.existsSync(folder)) {
// await DisplayLogin(fs, folder, userName, json, file, window, expect)
// }
// })
121 changes: 17 additions & 104 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const checkLogInOrNot = async(window, expect, userName) => {
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()
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')
Expand All @@ -13,138 +13,51 @@ export const checkLogInOrNot = async(window, expect, userName) => {
return textVisble;
}

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

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

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

export const commonFile = async (window, packageInfo) => {
export const userFile = async (window, packageInfo, path) => {
const newpath = await window.evaluate(() => Object.assign({}, window.localStorage))
const path = require('path');
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()
)
item.username.toLowerCase() !== userName.toLowerCase()
)
return await fs.writeFileSync(file, JSON.stringify(filtered))
}

export const DisplayLogin = async (fs, folder, userName, json, file, window, expect) => {
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()
}

export const createUserValidation = async (window, expect) => {
await window.getByRole('button', { name: 'Create New Account' }).click()
await expect(window.locator('//input[@placeholder="Username"]')).toBeVisible()
await window.getByPlaceholder('Username').fill('jo')
await expect(window.locator('//button[@type="submit"]')).toBeVisible()
await window.click('[type=submit]');
const lengthError = await window.textContent('//*[@id="show-error"]')
expect(await lengthError).toBe('The input has to be between 3 and 15 characters long')
await window.getByPlaceholder('Username').fill('job')
await window.click('[type=submit]');
const userExistError = await window.textContent('//*[@id="show-error"]')
expect(await userExistError).toBe('User exists, Check archived and active tab by click on view more.')
}

export const projectValidation = async (window,expect) => {
await expect(window.locator('//a[@aria-label="new"]')).toBeVisible()
await window.getByRole('link', { name: 'new' }).click()
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.textContent('[aria-label=projects]');
expect(title).toBe('New Project');
await window.waitForTimeout(5000)
}

export const createProjects = async (window, expect, projectname, type, description, abb) => {
await window.locator('//a[@aria-label="new"]').click()
await expect(window.locator('//button[@aria-label="open-popover"]')).toBeVisible()
await window.locator('//button[@aria-label="open-popover"]').click()
await expect(window.locator(`//a[@data-id="${type}"]`)).toBeVisible()
await window.locator(`//a[@data-id="${type}"]`).click()
////checking for create project validation
await projectValidation(window, expect)
await expect(window.locator('//input[@id="project_name"]')).toBeVisible()
await window.locator('//input[@id="project_name"]').fill(projectname)
await expect(window.locator('//textarea[@id="project_description"]')).toBeVisible()
await window.locator('//textarea[@id="project_description"]').fill(description)
await expect(window.locator('//input[@id="version_abbreviated"]')).toBeVisible()
await window.locator('//input[@id="version_abbreviated"]').fill(abb)
await expect(window.locator('//button[@aria-label="create"]')).toBeVisible()
await window.locator('//button[@aria-label="create"]').click()
const projectName = await window.innerText(`//div[@id="${projectname}"]`)
expect(projectName).toBe(projectname);
const title = await window.textContent('[aria-label=projects]', {timeout:10000});
expect(title).toBe('Projects');
}

export const starProject = async(window, expect, projectname) => {
await expect(window.locator('//*[@id="projects-list"]')).toBeVisible()
const table = window.locator('//*[@id="projects-list"]')
const body = table.locator('//*[@id="projects-list-unstar"]')
const starBody = table.locator('//*[@id="projects-list-star"]')
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.first().locator('[aria-label=unstar-project]')).toBeVisible()
await tds.first().locator('[aria-label=unstar-project]').click()
expect(await rows.count()).toBe(2)
const starRows = await starBody.locator('tr')
const starProjectName = await starRows.locator("td").nth(1).innerText()
expect(await starProjectName).toBe(projectname)
expect(await starRows.count()).toBe(1)
}
}
}

export const unstarProject = async (window, expect, projectname) => {
await expect(window.locator('//*[@id="projects-list"]')).toBeVisible()
const table = window.locator('//*[@id="projects-list"]')
const body = table.locator('//*[@id="projects-list-star"]')
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.first().locator('[aria-label=star-project]')).toBeVisible()
await tds.first().locator('[aria-label=star-project]').click()
const unstarBody = table.locator('//*[@id="projects-list-unstar"]')
const unstarRows = await unstarBody.locator('tr')
expect(await rows.count()).toBe(0)
expect(await unstarRows.count()).toBe(3)
}
}
}

export const searchProject = async (window, expect, projectName, searchtext) => {
await expect(window.locator('//input[@id="search_box"]')).toBeVisible()
await window.locator('//input[@id="search_box"]').fill(searchtext)
const projectname = await window.innerText(`//*[@id="${projectName}"]`);
expect(projectname).toBe(projectName);
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')
}
Loading

0 comments on commit a0e580b

Please sign in to comment.