Skip to content

Commit

Permalink
Create projects in fixture to reduce number of steps in frontend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vidya-ram committed Jan 8, 2024
1 parent 05974e7 commit 09096bd
Show file tree
Hide file tree
Showing 14 changed files with 308 additions and 180 deletions.
12 changes: 1 addition & 11 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = defineConfig({
globalSetup: './tests/playwright/globalSetup.js',
testDir: './tests/playwright/tests',
/* Run tests in files in parallel */
fullyParallel: true,
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
Expand All @@ -39,16 +39,6 @@ module.exports = defineConfig({
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],

});
Expand Down
30 changes: 25 additions & 5 deletions tests/playwright/fixtures/embed_video.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
[
"https://www.youtube.com/watch?v=qY8QmpdYFfc",
"https://www.youtube.com/watch?v=qY8Qmpdfc",
"https://www.youtube.com/live/RfnjNskapNg?feature=shared",
"https://www.youtube.com/embed/3pbyEGZjgH8?si=7kKze11tNJh554b1",
"https://vimeo.com/860144207"
{
"url": "https://www.youtube.com/watch?v=qY8QmpdYFfc",
"video_classname": ".ytp-title",
"valid": true
},
{
"url": "https://www.youtube.com/watch?v=qY8Qmpdfc",
"video_classname": ".ytp-title",
"valid": false
},
{
"url": "https://www.youtube.com/live/RfnjNskapNg?feature=shared",
"video_classname": ".ytp-title",
"valid": true
},
{
"url": "https://www.youtube.com/embed/3pbyEGZjgH8?si=7kKze11tNJh554b1",
"video_classname": ".ytp-title",
"valid": true
},
{
"url": "https://vimeo.com/860144207",
"video_title_class": ".vp-title",
"video_classname": true
}
]
4 changes: 2 additions & 2 deletions tests/playwright/fixtures/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"room": "Zoom"
},
{
"title": "BIC",
"room": "Hall"
"title": "Hasgeek House",
"room": "Second floor room"
}
],
"labels": [
Expand Down
28 changes: 19 additions & 9 deletions tests/playwright/fixtures/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,37 @@
"owner": {
"username": "profile_cypress",
"fullname": "profile-cypress",
"password": "profile-cypress123_St"
"password": "profile-cypress123_St",
"owns_profile": "fifthelephant",
"project": "summer-edition"
},
"admin": {
"username": "admin_user",
"fullname": "admin-user",
"password": "admin-user129_Ftz"
"password": "admin-user129_Ftz",
"owns_profile": "rootconf",
"project": "autumn-edition"
},
"editor": {
"username": "editor_cypress",
"fullname": "editor-cypress",
"password": "editor-cypress9_GH",
"owns_profile": "jsfoo",
"project": "monsoon-edition"
},
"promoter": {
"username": "promoter_user",
"fullname": "promoter-user",
"password": "promoter-user34_qQE"
"password": "promoter-user34_qQE",
"owns_profile": "metarefresh",
"project": "winter-edition"
},
"usher": {
"username": "usher_cypress",
"fullname": "usher-cypress",
"password": "usher-cypress566_YUt"
},
"editor": {
"username": "editor_cypress",
"fullname": "editor-cypress",
"password": "editor-cypress9_GH"
"password": "usher-cypress566_YUt",
"owns_profile": "kilter",
"project": "spring-edition"
},
"user": {
"username": "member_user",
Expand Down
26 changes: 0 additions & 26 deletions tests/playwright/tests/add-crew-project.spec.js

This file was deleted.

21 changes: 10 additions & 11 deletions tests/playwright/tests/add-livestream.spec.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import { test, expect } from '@playwright/test';

const { LoginPage } = require('../page/login');
const { ProjectPage } = require('../page/create-project');
const project = require('../fixtures/project.json');
const { admin, editor } = require('../fixtures/user.json');
const { admin } = require('../fixtures/user.json');
const videos = require('../fixtures/embed_video.json');

test('Add livestream and verify embed youtube and vimeo urls', async ({ page }) => {
let projectPage = new ProjectPage(page);
let randomProjectName = await projectPage.addProject(admin, [{'username': editor.username, 'role': 'editor'}]);
let loginPage = new LoginPage(page);
await loginPage.login(`/${admin.owns_profile}/${randomProjectName}`, editor.username, editor.password);
await loginPage.login(`/${admin.owns_profile}/${admin.project}`, admin.username, admin.password);

await page.getByTestId('add-livestream').click();
await page.getByTestId('add-livestream-btn').click();
for(let video of videos) {
await page.locator('#livestream_urls').type(video);
await page.locator('#livestream_urls').type(video.url);
await page.locator('#livestream_urls').press('Enter');
}
await page.getByTestId('form-submit-btn').click();

for(let index=0; index<videos.length; index++) {
await page.locator(`#tab-${index+1}`).click();
await page.locator(`#pane-justified-${index+1}`).frameLocator('iframe').locator('[aria-label="Play"]').click();
await page.locator(`#pane-justified-${index+1}`).frameLocator('iframe').locator('video').isVisible();
await expect(page.locator(`#pane-justified-${index+1}`).frameLocator('iframe').locator('video')).toHaveAttribute('src');
await await page.locator(`#pane-justified-${index+1}`).waitFor(6000);
if(videos[index].valid) {
await page.locator(`#pane-justified-${index+1}`).frameLocator('iframe').locator(videos[index].video_classname).isVisible();
} else {
await page.locator(`#pane-justified-${index+1}`).frameLocator('iframe').locator(videos[index].video_classname).isHidden();
}
}

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

const { LoginPage } = require('../page/login');
const { editor, admin } = require('../fixtures/user.json');

test('Add sponsor to project', async ({ page }) => {
let loginPage = new LoginPage(page);
await loginPage.login(`/${editor.owns_profile}/${editor.project}`, editor.username, editor.password);

await page.getByTestId('site-editor-menu').locator('visible=true').click();
await page.locator('.mui-dropdown__menu').locator('visible=true').waitFor(1000);
await Promise.all([
page.waitForRequest(request => request.url().includes("/sponsor"), {timeout: 60000}),
await page.getByTestId('add-sponsor').click()
]);
await page.locator('.select2-selection__arrow').waitFor();
await page.locator('.select2-selection__arrow').click();
await page.locator('.select2-search__field').waitFor();
await page.locator('.select2-search__field').fill(admin.owns_profile);
await page.locator('.select2-results__option').waitFor();
await page.locator('.select2-results__option').click();

await Promise.all([
page.waitForResponse(response => response.url().includes("/sponsor") && response.status() === 200, {timeout: 60000}),
page.getByTestId('form-submit-btn').click()
]);
await page.getByTestId('sponsor-link":has-text(`${admin.owns_profile}`)').isVisible();

await Promise.all([
page.waitForRequest(request => request.url().includes("/edit"), {timeout: 60000}),
await page.getByTestId('edit-sponsor').locator('nth=1').click()
]);
await page.locator('#is_promoted').click();
await Promise.all([
page.waitForResponse(response => response.url().includes("/edit") && response.status() === 200, {timeout: 60000}),
page.getByTestId('form-submit-btn').click()
]);
await page.reload();
await page.getByTestId('promoted').locator('nth=1').isVisible();

await Promise.all([
page.waitForRequest(request => request.url().includes("/remove"), {timeout: 60000}),
await page.getByTestId('remove-sponsor').locator('nth=1').click()
]);
await Promise.all([
page.waitForResponse(response => response.url().includes("/remove") && response.status() === 200, {timeout: 60000}),
page.locator('input[value="Remove"]').click()
]);
await page.reload();
await expect.soft(page.getByTestId('sponsor-card')).toBeHidden();
});
18 changes: 8 additions & 10 deletions tests/playwright/tests/add-submission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import { test, expect } from '@playwright/test';
const { LoginPage } = require('../page/login');
const { ProjectPage } = require('../page/create-project');
const project = require('../fixtures/project.json');
const { user, usher } = require('../fixtures/user.json');
const { usher, owner } = require('../fixtures/user.json');
const proposal = require('../fixtures/proposal.json');
let randomProjectName;

test('Submitting a proposal to a project', async ({ page }) => {
let projectPage = new ProjectPage(page);
randomProjectName = await projectPage.addProject(usher);
test('Submitting a proposal to a project and commenting on proposal', async ({ page }) => {
let loginPage = new LoginPage(page);
await loginPage.login(`/${usher.owns_profile}/${randomProjectName}`, usher.username, usher.password);
await loginPage.login(`/${usher.owns_profile}/${usher.project}`, usher.username, usher.password);
let projectPage = new ProjectPage(page);
await projectPage.addLabels();
await projectPage.openCFP();
await loginPage.logout();

await loginPage.login(`/${usher.owns_profile}/${randomProjectName}`, user.username, user.password);
await loginPage.login(`/${usher.owns_profile}/${usher.project}`, owner.username, owner.password);
await page.getByTestId('propose-a-session').locator('visible=true').click();
await page.getByTestId('close-consent-modal').click();
await page.locator('#title').fill(proposal.title);
Expand Down Expand Up @@ -55,15 +53,15 @@ test('Submitting a proposal to a project', async ({ page }) => {
page.waitForRequest(request => request.url().includes("/new"), {timeout: 60000}),
page.locator('.modal').locator('button[data-testid="form-submit-btn"]').locator('visible=true').click()
]);
await expect(page.locator('.toast-message')).toHaveCount(0, {timeout: 7000});
await expect(page.locator('.toast-message')).toHaveCount(0, {timeout: 10000});
await page.locator('a.modal__close').locator('visible=true').click();
await page.getByTestId('form-submit-btn').waitFor(60000);
await page.getByTestId('form-submit-btn').click();
await page.locator('.user__box__userid user__box__fullname', { hasText: usher.username }).isVisible();
await page.locator('.user__box__userid user__box__userid badge', { hasText: 'Editor' }).isVisible();

await page.getByTestId('proposal-menu').locator('visible=true').click();
await page.locator('.mui-dropdown__menu').locator('visible=true').waitFor(1000);
await page.locator('.mui-dropdown__menu').locator('visible=true').waitFor(3000);
await page.getByTestId('delete').isVisible();
await page.getByTestId('edit-proposal-video').isVisible();

Expand All @@ -74,6 +72,6 @@ test('Submitting a proposal to a project', async ({ page }) => {
page.getByTestId('new-form').getByTestId('submit-comment').click()
]);
await expect(page.locator('.comment__body')).toContainText(proposal.proposer_note);
await expect(page.locator('.comment__header')).toContainText(user.username);
await expect(page.locator('.comment__header')).toContainText(owner.username);

});
11 changes: 4 additions & 7 deletions tests/playwright/tests/add-venue-project.spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { test, expect } from '@playwright/test';

const { LoginPage } = require('../page/login');
const { ProjectCrewFormPage } = require('../page/project-crew-form');
const { ProjectPage } = require('../page/create-project');
const venues = require('../fixtures/venues.json');
const { promoter, usher } = require('../fixtures/user.json');
const { owner } = require('../fixtures/user.json');

test('Add venue to project', async ({ page }) => {
let projectPage = new ProjectPage(page);
let randomProjectName = await projectPage.addProject(promoter, [{'username': usher.username, 'role': 'editor'}]);
let loginPage = new LoginPage(page);
await loginPage.login(`/${promoter.owns_profile}/${randomProjectName}`, usher.username, usher.password);
let loginPage;
loginPage = new LoginPage(page);
await loginPage.login(`/${owner.owns_profile}/${owner.project}`, owner.username, owner.password);

await page.getByTestId('project-menu').locator("visible=true").click();
await page.getByTestId('settings').locator("visible=true").waitFor();
Expand Down
12 changes: 10 additions & 2 deletions tests/playwright/tests/create-project.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { test, expect } from '@playwright/test';

const { LoginPage } = require('../page/login');
const { ProjectPage } = require('../page/create-project');
const { ProjectCrewFormPage } = require('../page/project-crew-form');
const project = require('../fixtures/project.json');
const { admin } = require('../fixtures/user.json');
const { owner, admin, promoter, usher, editor, hguser } = require('../fixtures/user.json');

test('To create project, edit, publish', async ({ page }) => {
test('To create project, edit, publish and add crew', async ({ page }) => {
let randomProjectName = Math.random().toString(36).substring(2, 7);
let projectNameCapitalize = randomProjectName.charAt(0).toUpperCase() + randomProjectName.slice(1);
let loginPage;
Expand All @@ -29,5 +30,12 @@ test('To create project, edit, publish', async ({ page }) => {

//Publish project
await projectPage.publishProject();
let crewForm = new ProjectCrewFormPage(page);
await page.getByTestId('crew').click();
await crewForm.addMember(promoter.username, 'promoter');
await crewForm.addMember(usher.username, 'usher');
await crewForm.addMember(editor.username, 'editor');
await crewForm.addMember(hguser.username, 'usher', false);
await crewForm.deleteMember(promoter.username);

});
15 changes: 6 additions & 9 deletions tests/playwright/tests/open-cfp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ import { test, expect } from '@playwright/test';

const { LoginPage } = require('../page/login');
const { ProjectPage } = require('../page/create-project');
const profile = require('../fixtures/profile.json');
const project = require('../fixtures/project.json');
const { promoter, editor, user } = require('../fixtures/user.json');
const { promoter, user } = require('../fixtures/user.json');
const cfp = require('../fixtures/cfp.json');
const labels = require('../fixtures/labels.json');
const dayjs = require('dayjs');

test('Open call for proposal of the project and add schedule', async ({ page }) => {
let projectPage = new ProjectPage(page);
let randomProjectName = await projectPage.addProject(promoter, [{'username': editor.username, 'role': 'editor'}]);
test('Add schedule to a project (open cfp, add labels, sort labels, add session, publish schedule)', async ({ page }) => {
let loginPage = new LoginPage(page);
await loginPage.login(`/${promoter.owns_profile}/${randomProjectName}`, editor.username, editor.password);
await projectPage.addVenue();
let projectPage = new ProjectPage(page);
await loginPage.login(`/${promoter.owns_profile}/${promoter.project}`, promoter.username, promoter.password);
await page.getByTestId('submissions').click();
await page.getByTestId('add-cfp').click();
await page.locator('#field-instructions .cm-editor .cm-line').fill(cfp.instructions);
Expand Down Expand Up @@ -81,7 +78,7 @@ test('Open call for proposal of the project and add schedule', async ({ page })
await page.locator('#title').fill(project.session_title);
await page.locator('select#venue_room_id').click();
await page.getByText(`${project.venues[0].title}${project.venues[0].room}`).locator('visible=true').click();
await page.locator('#speaker').fill(editor.username);
await page.locator('#speaker').fill(promoter.username);
await page.locator('#is_break').click();
await Promise.all([
page.waitForRequest(request => request.url().includes("/new"), {timeout: 60000}),
Expand Down Expand Up @@ -138,7 +135,7 @@ test('Open call for proposal of the project and add schedule', async ({ page })
]);
await page.locator('#session-modal').isVisible();
await expect(page.getByTestId('title')).toContainText(project.proposal_title);
await expect(page.getByTestId('speaker')).toContainText(editor.fullname);
await expect(page.getByTestId('speaker')).toContainText(promoter.fullname);
await page.getByTestId('time').isVisible();
await expect(page.getByTestId('room')).toContainText(`${project.venues[1].room}, ${project.venues[1].title}`);
await page.getByTestId('session-video').locator('iframe').isVisible();
Expand Down
Loading

0 comments on commit 09096bd

Please sign in to comment.