Skip to content

Commit

Permalink
added tests, removed upload test
Browse files Browse the repository at this point in the history
  • Loading branch information
shreybaz committed Apr 29, 2024
1 parent 83fc277 commit 26e0437
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 30 deletions.
117 changes: 87 additions & 30 deletions tests/example.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { chromium } from 'playwright';
import { test, expect } from '@playwright/test';

test.beforeEach(async ({ page }) => {
Expand Down Expand Up @@ -35,9 +36,11 @@ test.describe('New test', () => {

// click unmute button
await page.locator('.fixed').first().click();
await page.waitForTimeout(3000);
await page.waitForTimeout(1000);
// // css selector of unmute button
// const buttonLocator = page.locator('body > main > div.h-full.w-full.overflow-hidden.overflow-y-auto > div > button > svg > path').click();
// await expect(video).toHaveAttribute('muted');
// console.log("is muted");

let video_new = page.locator('video').nth(0);
// await expect(video_new).not.toHaveAttribute('muted');
Expand Down Expand Up @@ -72,7 +75,7 @@ test.describe('New test', () => {
const new_duration = await new_video.evaluate(new_video => new_video.duration);
console.log('2nd Video Duration:', new_duration);

await page.waitForTimeout(3000);
// await page.waitForTimeout(3000);

//scroll to new video based on its locator
let third_video = page.locator('video').nth(5);
Expand All @@ -88,8 +91,6 @@ test.describe('New test', () => {
const third_duration = await third_video.evaluate(new_video => new_video.duration);
console.log('3rd Video Duration:', third_duration);

// await page.waitForTimeout(3000);

});

// test('Test google login', async ({page}) => {
Expand All @@ -109,7 +110,7 @@ test.describe('New test', () => {
// await page.getByRole('button', { name: 'Google Sign-In' }).click();
// const page1 = await page1Promise;
// await page1.getByLabel('Email or phone').click();
// await page1.getByLabel('Email or phone').fill('testautomationyral@gmail.com');
// await page1.getByLabel('Email or phone').fill('testautomationyral@googlemail.com');

// await page.waitForTimeout(2000);
// await page1.getByLabel('Email or phone').press('Enter');
Expand Down Expand Up @@ -139,42 +140,98 @@ test.describe('New test', () => {
// }
// });

test('TEST UPLOAD FLOW', async ({page}) => {
// test('TEST UPLOAD FLOW', async ({page}) => {

console.log('Uploading test');
// // login from wallet: using headfull mode
// console.log('Uploading test');

await page.waitForTimeout(2000);
// await page.waitForTimeout(2000);

await page.getByRole('navigation').getByRole('link').nth(2).click();
// await page.getByRole('navigation').getByRole('link').nth(2).click();

await page.setInputFiles('#dropzone-file', './test1.mp4');
// await page.setInputFiles('#dropzone-file', './test3.mp4');

// TODO
// //endpoint to fetch the response
// const response = await fetch('https://yral.com/api/stream_to_offchain_agent11958048345285885967');
// console.log(response);
// const responseData = await response.json();
// // TODO
// // //endpoint to fetch the response
// // const response = await fetch('https://yral.com/api/stream_to_offchain_agent11958048345285885967');
// // console.log(response);
// // const responseData = await response.json();

// console.log(responseData);
// // Perform assertions based on the API response
// expect(responseData.status).toBe(200);
// // console.log(responseData);
// // // Perform assertions based on the API response
// // expect(responseData.status).toBe(200);

await page.getByPlaceholder('Write your description here..').click();
await page.getByPlaceholder('Write your description here..').fill('test video upload');
await page.getByPlaceholder('#hashtag1,#hashtag2,#hashtag3').click();
await page.getByPlaceholder('#hashtag1,#hashtag2,#hashtag3').fill('#try');
// await page.getByPlaceholder('Write your description here..').click();
// await page.getByPlaceholder('Write your description here..').fill('Monica Dance video');
// await page.getByPlaceholder('#hashtag1,#hashtag2,#hashtag3').click();
// await page.getByPlaceholder('#hashtag1,#hashtag2,#hashtag3').fill('#try');

// const button =
// await button.click('button[data-api-trigger="true"]');
// // const button =
// // await button.click('button[data-api-trigger="true"]');

await page.getByRole('button', { name: 'Upload Video' }).click();
await page.pause();
// await page.getByRole('button', { name: 'Upload Video' }).click();

// console.log('Uploading .. .. ..');

// await button.click('button[data-api-trigger="true"]');
// //wait for upload to complete, Continue Browsing button to appear
// // await page.waitForSelector('button[name="Continue Browsing"]', { state: 'visible' });

await page.getByRole('navigation').getByRole('link').first().click();
await page.waitForTimeout(5000);
// // Wait for the button with the name 'Continue Browsing' to become clickable
// await page.waitForFunction(() => {
// const button = document.querySelector('button[name="Continue Browsing"]');
// return button && !button.disabled;
// });

// // await page.waitForTimeout(20000);

});
// // await getByRole('button', { name: 'Continue Browsing' }).click();
// // // await page.pause();

// console.log('Uploaded succesfully');

// // await button.click('button[data-api-trigger="true"]');

// await page.getByRole('navigation').getByRole('link').first().click();
// await page.waitForTimeout(5000);

// });

// //test like functionality
// test('Test like', async ({page}) => {

// // login from wallet: using headfull mode
// // try {
// console.log('test like');

// await page.waitForTimeout(1000);

// let likes_locator = page.locator('.flex > div:nth-child(2) > .flex > .text-sm').first();
// let total_likes = await likes_locator.textContent();
// console.log("total likes: ", total_likes );

// await page.waitForTimeout(15000);

// await expect(page.locator('button').first()).toBeVisible();
// console.log('like button visible');

// //click like button
// await page.locator('button').first().click();
// // await page.locator('body > main > div.h-full.w-full.overflow-hidden.overflow-y-auto > div > div:nth-child(2) > div > div.flex.flex-row.flex-nowrap.justify-between.items-end.pb-16.px-2.md\:px-6.w-full.text-white.absolute.bottom-0.left-0.bg-transparent.z-\[4\] > div.flex.flex-col.gap-6.items-end.w-3\/12.text-4xl > div > button > svg > path').click();
// await page.waitForTimeout(2000);

// let new_likes_locator = page.locator('.flex > div:nth-child(2) > .flex > .text-sm').first();
// let updated_likes = await new_likes_locator.textContent();
// console.log("updated total likes: ", updated_likes );

// expect(parseInt(updated_likes)).toBe(parseInt(total_likes) + 1);
// // let new_like_count = expect(page.getByRole('main'));
// // console.log("new like count: ", new_like_count );

// // await expect(page.getByRole('main')).toContainText(like_count + 1);

// // } catch (error) {
// // console.error("error in login");
// // }
// });

});
46 changes: 46 additions & 0 deletions tests/like.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { test, expect } from '@playwright/test';

test.beforeEach(async ({ page }) => {
await page.goto('https://yral.com/');
});

test.describe('New test', () => {
//test like functionality
test('Test like', async ({page}) => {

// login from wallet: using headfull mode
// try {
console.log('test like');

await page.waitForTimeout(1000);

let likes_locator = page.locator('.flex > div:nth-child(2) > .flex > .text-sm').first();
let total_likes = await likes_locator.textContent();
console.log("total likes: ", total_likes );

await page.waitForTimeout(15000);

await expect(page.locator('button').first()).toBeVisible();
console.log('like button visible');

//click like button
await page.locator('button').first().click();
// await page.locator('body > main > div.h-full.w-full.overflow-hidden.overflow-y-auto > div > div:nth-child(2) > div > div.flex.flex-row.flex-nowrap.justify-between.items-end.pb-16.px-2.md\:px-6.w-full.text-white.absolute.bottom-0.left-0.bg-transparent.z-\[4\] > div.flex.flex-col.gap-6.items-end.w-3\/12.text-4xl > div > button > svg > path').click();
await page.waitForTimeout(2000);

let new_likes_locator = page.locator('.flex > div:nth-child(2) > .flex > .text-sm').first();
let updated_likes = await new_likes_locator.textContent();
console.log("updated total likes: ", updated_likes );

expect(parseInt(updated_likes)).toBe(parseInt(total_likes) + 1);
// let new_like_count = expect(page.getByRole('main'));
// console.log("new like count: ", new_like_count );

// await expect(page.getByRole('main')).toContainText(like_count + 1);

// } catch (error) {
// console.error("error in login");
// }
});

})
126 changes: 126 additions & 0 deletions tests/reffer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// import { chromium } from 'playwright';
// import { test, expect } from '@playwright/test';

// // test.beforeEach(async ({ page }) => {
// // await page.goto('https://yral.com/');
// // });

// test.describe('New test', () => {
// //test like functionality
// test('Test refferal', async () => {

// // login from wallet: using headfull mode
// try {

// // const environment_pass = global.expect;
// // login for first user
// const environment_pass = process.env.TESTPARAM;

// const browser1 = await chromium.launch(); // Launch Chromium browser
// const context = await browser1.newContext();
// const page = await context.newPage();
// await page.goto('https://yral.com/');

// await page.waitForTimeout(3000);

// await page.getByRole('navigation').getByRole('link').nth(4).click();
// await page.getByRole('button', { name: 'Login' }).click();
// const page1Promise = page.waitForEvent('popup');
// await page.getByRole('button', { name: 'Google Sign-In' }).click();
// const page1 = await page1Promise;
// await page.waitForTimeout(2000);

// await page1.getByLabel('Email or phone').click();
// await page1.getByLabel('Email or phone').fill('[email protected]');
// await page1.getByLabel('Email or phone').press('Enter');

// await page1.getByLabel('Enter your password').click();
// await page1.getByLabel('Enter your password').fill(environment_pass);
// await page1.getByLabel('Enter your password').press('Enter');
// // await page1.pause();
// await page.waitForTimeout(3000);

// // store current users COYN balance
// // await page.getByRole('link', { name: 'View Profile' }).click();
// // await page.waitForTimeout(1000);

// // let earnings = page.getByText('Earnings');
// // let user_earnings = await earnings.textContent();

// // console.log('user earnings : ', user_earnings);
// console.log('Log in test running');

// await page.getByRole('navigation').getByRole('link').first().click();
// // click on refferal button
// await page.locator('div:nth-child(2) > a').first().click();
// await page.waitForTimeout(3000);

// let refferal_link_lo = page.getByText('gzlng-jqzta-5kubz-4nyam-5so2e');
// let refferal_code = await refferal_link_lo.textContent();
// console.log('refferal code : ', refferal_code);

// let refferal_link = "https://yral.com/?user_refer="+refferal_code;
// console.log('refferal link : ', refferal_link);

// // login for second user
// const browser2 = await chromium.launch(); // Launch Chromium browser
// const new_context = await browser2.newContext();
// const page2 = await new_context.newPage();
// await page2.goto(refferal_link);

// const title = await page2.title();
// console.log(title);
// expect(title).toBe("Yral");

// console.log('reffered login ');

// // Todo: remove
// page2.close();
// await page.waitForTimeout(1000);
// await page.getByRole('navigation').getByRole('link').nth(4).click();
// await page.waitForTimeout(2000);

// // uncomment when adding 2nd user
// // await page2.getByRole('navigation').getByRole('link').nth(4).click();
// // await page2.getByRole('button', { name: 'Login' }).click();
// // const page3Promise = page2.waitForEvent('popup');
// // await page2.getByRole('button', { name: 'Google Sign-In' }).click();
// // const page3 = await page3Promise;
// // await page.waitForTimeout(2000);

// // await page3.getByLabel('Email or phone').click();
// // await page3.getByLabel('Email or phone').fill('');

// // await page3.getByLabel('Email or phone').press('Enter');

// // await page3.getByLabel('Enter your password').click();
// // await page3.getByLabel('Enter your password').fill("");

// // await page3.getByLabel('Enter your password').press('Enter');

// // await page2.getByRole('link', { name: 'View Profile' }).click();
// // await page2.waitForTimeout(1000);

// // let earnings = page2.getByText('Earnings');
// // let user_earnings = await earnings.textContent();

// // console.log('user earnings : ', user_earnings);
// // await page.getByRole('navigation').getByRole('link').first().click();

// // await page.waitForTimeout(3000);
// // //request to the API endpoint to fetch the response
// // const response = await fetch('https://yral-metadata.fly.dev/metadata/gzlng-jqzta-5kubz-4nyam-5so2e-tsoio-ijv2s-47dsw-7ksd7-pe3eb-zqe');
// // await page.waitForTimeout(2000);

// // console.log(response.status);
// // const responseData = await response.json();
// // console.log(responseData);

// } catch (error) {
// console.error("error in login");
// }
// });

// })
// //css locator for earnings:
// // let earnings = page.locator('body > main > div > div.grid.grid-cols-1.gap-5.justify-normal.justify-items-center.w-full > div.flex.flex-row.w-11\/12.sm\:w-7\/12.justify-center > div > div > div > p.text-primary-500');

0 comments on commit 26e0437

Please sign in to comment.