Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions __tests__/requests/requests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,34 @@ describe('Tests the request cards', () => {
await browser.close();
});

it('should match the request page url with correct request tab link after reloading the page', async () => {
await page.click('#extension_tab_link');
expect(page.url()).toContain('type=extension');

await page.reload();
expect(page.url()).toContain('type=extension');

const isExtensionTabLinkSelected = await page.$eval(
'[data-testid="extension-tab"]',
(e) => e.classList.contains('selected__tab'),
);
const isOnboardingTabLinkSelected = await page.$eval(
'[data-testid="onboarding-tab"]',
(e) => e.classList.contains('selected__tab'),
);
const isOOOTabLinkSelected = await page.$eval(
'[data-testid="ooo-tab"]',
(e) => e.classList.contains('selected__tab'),
);

expect(isExtensionTabLinkSelected).toBe(true);
expect(isOnboardingTabLinkSelected).toBe(false);
expect(isOOOTabLinkSelected).toBe(false);
});

it('should update the card when the accept or reject button is clicked for OOO requests', async () => {
await page.click('#ooo_tab_link');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the selected__tab has been removed from index.html, has to manually click ooo_tab_link to simulate the behaviour


await page.waitForSelector('.request__status');
const statusButtonText = await page.$eval(
'.request__status',
Expand Down
8 changes: 1 addition & 7 deletions requests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@
<div class="container" id="request-page-container">
<div class="container__header">
<nav>
<a
href="#"
class="selected__tab"
id="ooo_tab_link"
data-testid="ooo-tab"
>OOO</a
>
<a href="#" id="ooo_tab_link" data-testid="ooo-tab">OOO</a>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the default selected_tab class from here because after a reload it selects the ooo tab then goes to another tab to match the request page url

<a
href="#"
class="disabled__tab hidden"
Expand Down
33 changes: 21 additions & 12 deletions requests/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,30 @@ const filterOptionsContainer = document.getElementById(
);
const applyFilterButton = document.getElementById('applyFilterButton');
const userNameFilterInput = document.getElementById('assignee-search-input');
let currentReqType = OOO_REQUEST_TYPE;
let currentReqType = params.get('type') ?? OOO_REQUEST_TYPE;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetches type from page url if not found select ooo request type as default

let selected__tab__class = 'selected__tab';
let statusValue = null;
let sortByValue = null;
let userDetails = [];
let nextLink = '';
let isDataLoading = false;

function updateTabLink(requestType) {
if (requestType === OOO_REQUEST_TYPE) {
oooTabLink.classList.add(selected__tab__class);
onboardingExtensionTabLink.classList.remove(selected__tab__class);
extensionTabLink.classList.remove(selected__tab__class);
} else if (requestType === ONBOARDING_EXTENSION_REQUEST_TYPE) {
onboardingExtensionTabLink.classList.add(selected__tab__class);
oooTabLink.classList.remove(selected__tab__class);
extensionTabLink.classList.remove(selected__tab__class);
} else if (requestType === EXTENSION_REQUEST_TYPE) {
extensionTabLink.classList.add(selected__tab__class);
oooTabLink.classList.remove(selected__tab__class);
onboardingExtensionTabLink.classList.remove(selected__tab__class);
}
}

Comment on lines +30 to +45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on current request type it adds selected__tab class to request tab link and removes from others

function getUserDetails(id) {
return userDetails.find((user) => user.id === id);
}
Expand Down Expand Up @@ -65,9 +81,7 @@ oooTabLink.addEventListener('click', async function (event) {
nextLink = '';
deselectRadioButtons();
userNameFilterInput.value = '';
oooTabLink.classList.add(selected__tab__class);
extensionTabLink.classList.remove(selected__tab__class);
onboardingExtensionTabLink.classList.remove(selected__tab__class);
updateTabLink(currentReqType.toUpperCase());
Comment on lines -68 to +84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have refactored this as it is being handle in updateTabLink function

changeFilter();
updateUrlWithQuery(currentReqType);
await renderRequestCards({ state: statusValue, sort: sortByValue });
Expand All @@ -80,9 +94,7 @@ extensionTabLink.addEventListener('click', async function (event) {
nextLink = '';
deselectRadioButtons();
userNameFilterInput.value = '';
extensionTabLink.classList.add(selected__tab__class);
oooTabLink.classList.remove(selected__tab__class);
onboardingExtensionTabLink.classList.remove(selected__tab__class);
updateTabLink(currentReqType.toUpperCase());
Comment on lines -83 to +97
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have refactored this as it is being handle in updateTabLink function

changeFilter();
updateUrlWithQuery(currentReqType);
await renderRequestCards({ state: statusValue, sort: sortByValue });
Expand All @@ -95,9 +107,7 @@ onboardingExtensionTabLink.addEventListener('click', async function (event) {
nextLink = '';
deselectRadioButtons();
userNameFilterInput.value = '';
onboardingExtensionTabLink.classList.add(selected__tab__class);
extensionTabLink.classList.remove(selected__tab__class);
oooTabLink.classList.remove(selected__tab__class);
updateTabLink(currentReqType.toUpperCase());
Comment on lines -98 to +110
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have refactored this as it is being handle in updateTabLink function

changeFilter();
updateUrlWithQuery(currentReqType);
await renderRequestCards({ state: statusValue, sort: sortByValue });
Expand Down Expand Up @@ -768,7 +778,6 @@ function populateStatus() {
addRadioButton(name, id, 'status-filter');
}
}

updateTabLink(currentReqType.toUpperCase());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

select the request tab link based on current type for every page reload

populateStatus();

renderRequestCards({ state: statusValue, sort: sortByValue });
Loading