Skip to content

Commit 3f30b39

Browse files
authored
Merge pull request #895 from Real-Dev-Squad/develop
Dev to main sync
2 parents 1a2b13a + 0399dcd commit 3f30b39

File tree

2 files changed

+17
-32
lines changed

2 files changed

+17
-32
lines changed

__tests__/groups/group.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('Discord Groups Page', () => {
6060
},
6161
body: JSON.stringify(discordGroups),
6262
});
63-
} else if (url === `${BASE_URL}/discord-actions/groups?dev=true`) {
63+
} else if (url === `${BASE_URL}/discord-actions/groups`) {
6464
interceptedRequest.respond({
6565
status: 200,
6666
contentType: 'application/json',
@@ -244,9 +244,9 @@ describe('Discord Groups Page', () => {
244244
expect(groupCreationModalClosed).toBeFalsy();
245245
});
246246

247-
test('Should display only specified groups when dev=true and name=<group-name> with different case', async () => {
247+
test('Should display only specified groups when name=<group-name> with different case', async () => {
248248
const groupNames = 'fIrSt,DSA+COdInG';
249-
await page.goto(`${PAGE_URL}/groups?dev=true&name=${groupNames}`);
249+
await page.goto(`${PAGE_URL}/groups?name=${groupNames}`);
250250
await page.waitForNetworkIdle();
251251

252252
const displayedGroups = await page.evaluate(() => {
@@ -259,7 +259,7 @@ describe('Discord Groups Page', () => {
259259
});
260260

261261
test('Should display no group found div when no group is present', async () => {
262-
await page.goto(`${PAGE_URL}/groups?dev=true&name=no-group-present`);
262+
await page.goto(`${PAGE_URL}/groups?name=no-group-present`);
263263
await page.waitForNetworkIdle();
264264

265265
const noGroupDiv = await page.$('.no-group-container');

groups/script.js

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ import {
2525
} from './utils.js';
2626

2727
const QUERY_PARAM_KEY = {
28-
DEV_FEATURE_FLAG: 'dev',
2928
GROUP_SEARCH: 'name',
3029
};
31-
const isDev = getParamValueFromURL(QUERY_PARAM_KEY.DEV_FEATURE_FLAG) === 'true';
3230

3331
const handler = {
3432
set: (obj, prop, value) => {
@@ -61,26 +59,15 @@ const handler = {
6159
renderAllGroups({
6260
cardOnClick: groupCardOnAction,
6361
});
64-
if (isDev && (!value || value.length == 0)) renderNoGroupFound();
62+
if (!value || value.length == 0) renderNoGroupFound();
6563
break;
6664
case 'search':
67-
if (isDev) {
68-
setParamValueInURL(QUERY_PARAM_KEY.GROUP_SEARCH, value);
69-
dataStore.filteredGroupsIds = getDiscordGroupIdsFromSearch(
70-
Object.values(dataStore.groups),
71-
value,
72-
);
73-
} else if (value === '') {
74-
if (dataStore.groups == null) break;
75-
dataStore.filteredGroupsIds = Object.values(dataStore.groups).map(
76-
(group) => group.id,
77-
);
78-
} else {
79-
const search = value.toLowerCase();
80-
dataStore.filteredGroupsIds = Object.values(dataStore.groups)
81-
.filter((group) => group.title.toLowerCase().includes(search))
82-
.map((group) => group.id);
83-
}
65+
setParamValueInURL(QUERY_PARAM_KEY.GROUP_SEARCH, value);
66+
if (dataStore.groups == null) break;
67+
dataStore.filteredGroupsIds = getDiscordGroupIdsFromSearch(
68+
Object.values(dataStore.groups),
69+
value,
70+
);
8471
obj[prop] = value;
8572
break;
8673
case 'isGroupCreationModalOpen':
@@ -124,7 +111,7 @@ const dataStore = new Proxy(
124111
userSelf: null,
125112
groups: null,
126113
filteredGroupsIds: null,
127-
search: isDev ? getParamValueFromURL(QUERY_PARAM_KEY.GROUP_SEARCH) : '',
114+
search: getParamValueFromURL(QUERY_PARAM_KEY.GROUP_SEARCH),
128115
discordId: null,
129116
isCreateGroupModalOpen: false,
130117
},
@@ -188,12 +175,10 @@ const afterAuthentication = async () => {
188175
};
189176
return acc;
190177
}, {});
191-
if (isDev) {
192-
dataStore.filteredGroupsIds = getDiscordGroupIdsFromSearch(
193-
Object.values(dataStore.groups),
194-
dataStore.search,
195-
);
196-
}
178+
dataStore.filteredGroupsIds = getDiscordGroupIdsFromSearch(
179+
Object.values(dataStore.groups),
180+
dataStore.search,
181+
);
197182
dataStore.discordId = roleData.userId;
198183
},
199184
);
@@ -211,7 +196,7 @@ const bindGroupCreationButton = () => {
211196

212197
const bindSearchInput = () => {
213198
const searchInput = document.querySelector('.search__input');
214-
if (isDev) searchInput.value = dataStore.search;
199+
searchInput.value = dataStore.search;
215200
searchInput.addEventListener('input', (e) => {
216201
dataStore.search = e.target.value;
217202
});

0 commit comments

Comments
 (0)