Skip to content

Commit

Permalink
changed up to date status
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshmi2506 committed Feb 5, 2024
1 parent c3103d5 commit c230197
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/js/utils/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ export const pluralize = (count: number, str: string) =>
count === 1 ? str : `${str}s`;

export const getOrgStatusMsg = (org: Org) => {
const totalChanges = org.total_unsaved_changes - org.total_ignored_changes;
const nonsourceIgnored: Changeset = {};
for (const groupName in org.ignored_changes) {
if (Object.keys(org.non_source_changes).indexOf(groupName) !== -1) {
nonsourceIgnored[groupName] = org.ignored_changes[groupName];
}
}
const totalIgnored =
org.total_ignored_changes - Object.values(nonsourceIgnored).flat().length;
const totalChanges = org.total_unsaved_changes - totalIgnored;
if (totalChanges > 0) {
const statusMsgDefault = `${totalChanges} unretrieved ${pluralize(
totalChanges,
Expand Down
18 changes: 18 additions & 0 deletions test/js/components/orgs/taskOrgCards.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ describe('<TaskOrgCards/>', () => {
has_ignored_changes: true,
total_ignored_changes: 1,
ignored_changes: { Foo: ['Bar'] },
non_source_changes: {},
},
};
const { getByText } = setup({ orgs });
Expand All @@ -195,6 +196,23 @@ describe('<TaskOrgCards/>', () => {
});
});

describe('org has ignored nonsource changes', () => {
test('renders card status', () => {
const orgs = {
...defaultOrgs,
Dev: {
...defaultOrgs.Dev,
has_ignored_changes: true,
total_ignored_changes: 1,
ignored_changes: { Apple: ['Bars'] },
non_source_changes: { Apple: ['Bars'] },
},
};
const { getByText } = setup({ orgs });
expect(getByText('1 unretrieved change', { exact: false })).toBeVisible();
});
});

describe('not owned by current user', () => {
test('renders org cards', () => {
const orgs = {
Expand Down

0 comments on commit c230197

Please sign in to comment.