Skip to content

Commit

Permalink
Merge branch 'develop' into add-onboard-option
Browse files Browse the repository at this point in the history
  • Loading branch information
fakhruddinkw authored Jul 19, 2023
2 parents 98c920a + 5712f66 commit b46f48b
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 1 deletion.
82 changes: 82 additions & 0 deletions __tests__/standup/standup.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const puppeteer = require('puppeteer');
const API_BASE_URL = 'https://staging-api.realdevsquad.com';
const { user } = require('../../mock-data/users');
const { standup } = require('../../mock-data/standup');

describe('Input box', () => {
let browser;
let page;
jest.setTimeout(60000);

beforeAll(async () => {
browser = await puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
args: ['--incognito', '--disable-web-security'],
devtools: false,
});
page = await browser.newPage();

await page.setRequestInterception(true);

page.on('request', (interceptedRequest) => {
const url = interceptedRequest.url();

if (url === `${API_BASE_URL}/users/sunny`) {
interceptedRequest.respond({
status: 200,
contentType: 'application/json',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
body: JSON.stringify(user),
});
} else if (
url === `${API_BASE_URL}/progresses?userId=YleviOe1SsOML8eitV9W`
) {
interceptedRequest.respond({
status: 200,
contentType: 'application/json',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
body: JSON.stringify(standup),
});
} else {
interceptedRequest.continue();
}
});
await page.goto('http://localhost:8000/standup');
await page.waitForNetworkIdle();
});

afterAll(async () => {
await browser.close();
});

it('should display the table when the search button is clicked', async () => {
const userInput = await page.$('#user-search-input');
const searchButton = await page.$('#search-button');

await userInput.type('sunny');
await searchButton.click();
await page.waitForSelector('#table-container');
const table = await page.$('.user-standup-table');
expect(table).toBeTruthy();
});

it('should display the loader when the search button is clicked', async () => {
const userInput = await page.$('#user-search-input');
const searchButton = await page.$('#search-button');

await userInput.type('sunny');
await searchButton.click();
await page.waitForSelector('#table-container');
const loader = await page.$('.loader');
expect(loader).toBeTruthy();
});
});
98 changes: 98 additions & 0 deletions mock-data/standup/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
const standupOne = {
message: 'Progress document retrieved successfully.',
count: 9,
data: [
{
id: '8hhlqHacZ9iWo3rbWHku',
date: 1685145600000,
createdAt: 1685163538297,
blockers: 'Implement error handling for API endpoints',
completed: 'Implement error handling for API endpoints',
planned: 'Implement error handling for API endpoints',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'ANaIkUInoUeAagwMsxHI',
date: 1685836800000,
createdAt: 1685892283432,
blockers: 'Working on a backend Go project',
completed: 'Working on a backend Go project',
planned: 'Working on a backend Go project',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'KYvOM36StltlBNxtW9Mm',
date: 1685577600000,
createdAt: 1685616571070,
blockers: 'Working on a backend Go project',
completed: 'Working on a backend Go project',
planned: 'Working on a backend Go project',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'T8GZ191H8lVTnGBB3tAQ',
date: 1685318400000,
createdAt: 1685374251104,
blockers: 'Implement error handling for API endpoints',
completed: 'Implement error handling for API endpoints',
planned: 'Implement error handling for API endpoints',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'h3eK4lVB5PlOZXX9RFFP',
date: 1685750400000,
createdAt: 1685783692663,
blockers: 'Working on a backend Go project',
completed: 'Working on a backend Go project',
planned: 'Working on a backend Go project',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'jng8Zlsjr90EuGbBQisG',
date: 1685059200000,
createdAt: 1685115243500,
blockers: 'Working on a backend Go project',
completed: 'Working on a backend Go project',
planned: 'Working on a backend Go project',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'nFTXyHfbufj7XY2mguVX',
date: 1685491200000,
createdAt: 1685506497607,
blockers: 'Implement error handling for API endpoints',
completed: 'Implement error handling for API endpoints',
planned: 'Implement error handling for API endpoints',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'sG4sUGTILmxaby9xmU3I',
date: 1685404800000,
createdAt: 1685453697666,
blockers: 'Working on a backend Go project',
completed: 'Working on a backend Go project',
planned: 'Working on a backend Go project',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
{
id: 'xxvvSUglhJQNnHWVyEZ9',
date: 1685232000000,
createdAt: 1685257952297,
blockers: 'Waiting for database access credentials',
completed: 'Waiting for database access credentials',
planned: 'Waiting for database access credentials',
type: 'user',
userId: 'YleviOe1SsOML8eitV9W',
},
],
};

module.exports = { standupOne };
14 changes: 13 additions & 1 deletion mock-data/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,16 @@ const filteredUsersData = {
],
};

module.exports = { allUsersData, filteredUsersData };
const user = {
id: 'iODXB6gfsjaZB9p0XlBw',
incompleteUserDetails: false,
github_display_name: 'Sunny Sahsi',
last_name: 'Sahsi',
github_id: 'sahsisunny',
first_name: 'Sunny',
username: 'sunny',
roles: {
archived: false,
},
};
module.exports = { allUsersData, filteredUsersData, user };

0 comments on commit b46f48b

Please sign in to comment.