Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding date and time to test queue and new test plan dropdown #397

Merged
merged 2 commits into from
Jan 13, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ADD_TEST_QUEUE_MUTATION,
POPULATE_ADD_TEST_PLAN_TO_QUEUE_MODAL_QUERY
} from '../TestQueue/queries';
import { gitUpdatedDateToString } from '../../utils/gitUtils';

const NewTestPlanReportModal = ({
show = false,
Expand Down Expand Up @@ -43,7 +44,6 @@ const NewTestPlanReportModal = ({
...version
}))
.flat();

setAllTestPlanVersions(allTestPlanVersions);
}
}, [data]);
Expand Down Expand Up @@ -176,7 +176,9 @@ const NewTestPlanReportModal = ({
key={`${item.gitSha}-${item.id}`}
value={item.id}
>
{item.gitSha}
{gitUpdatedDateToString(item.updatedAt)}{' '}
{item.gitMessage} ({item.gitSha.substring(0, 7)}
)
</option>
))}
</Form.Control>
Expand Down
4 changes: 4 additions & 0 deletions client/components/TestQueue/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ export const TEST_QUEUE_PAGE_QUERY = gql`
id
title
gitSha
gitMessage
testPlan {
directory
}
updatedAt
}
draftTestPlanRuns {
id
Expand Down Expand Up @@ -82,9 +84,11 @@ export const POPULATE_ADD_TEST_PLAN_TO_QUEUE_MODAL_QUERY = gql`
id
title
gitSha
gitMessage
testPlan {
directory
}
updatedAt
}
}
`;
Expand Down
9 changes: 9 additions & 0 deletions client/components/TestQueueRow/TestQueueRow.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ button.more-actions:active {
font-size: 0.9rem;
}

.git-string {
font-style: italic;
font-size: 0.9rem;
}

.test-plan {
font-size: 1.1rem;
}

/* tr.test-queue-run-row td:first-child {
padding: 0.75rem;
} */
37 changes: 28 additions & 9 deletions client/components/TestQueueRow/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
REMOVE_TESTER_MUTATION,
REMOVE_TESTER_RESULTS_MUTATION
} from '../TestQueue/queries';
import { gitUpdatedDateToString } from '../../utils/gitUtils';

const TestQueueRow = ({
user = {},
Expand Down Expand Up @@ -114,25 +115,43 @@ const TestQueueRow = ({
};

const renderAssignedUserToTestPlan = () => {
const gitUpdatedDateString = (
<p className="git-string">
Published {gitUpdatedDateToString(testPlanVersion.updatedAt)}
</p>
);
// Determine if current user is assigned to testPlan
if (currentUserAssigned)
return (
<Link to={`/run/${currentUserTestPlanRun.id}`}>
{testPlanVersion.title ||
`"${testPlanVersion.testPlan.directory}"`}
</Link>
<>
<Link
className="test-plan"
to={`/run/${currentUserTestPlanRun.id}`}
>
{testPlanVersion.title ||
`"${testPlanVersion.testPlan.directory}"`}
</Link>
{gitUpdatedDateString}
</>
);

if (!isSignedIn)
return (
<Link to={`/test-plan-report/${testPlanReport.id}`}>
{testPlanVersion.title ||
`"${testPlanVersion.testPlan.directory}"`}
</Link>
<>
<Link to={`/test-plan-report/${testPlanReport.id}`}>
{testPlanVersion.title ||
`"${testPlanVersion.testPlan.directory}"`}
</Link>
{gitUpdatedDateString}
</>
);

return (
testPlanVersion.title || `"${testPlanVersion.testPlan.directory}"`
<div>
{testPlanVersion.title ||
`"${testPlanVersion.testPlan.directory}"`}
{gitUpdatedDateString}
</div>
);
};

Expand Down
24 changes: 18 additions & 6 deletions client/tests/__mocks__/GraphQLMocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export const TEST_QUEUE_PAGE_POPULATED_MOCK_ADMIN = [
id: '1',
title: 'Checkbox Example (Two State)',
gitSha: 'b7078039f789c125e269cb8f8632f57a03d4c50b',
testPlan: { directory: 'checkbox' }
gitMessage: 'The message for this SHA',
testPlan: { directory: 'checkbox' },
updatedAt: '2021-11-30T14:51:28.000Z'
},
draftTestPlanRuns: [
{
Expand Down Expand Up @@ -206,7 +208,9 @@ export const TEST_QUEUE_PAGE_POPULATED_MOCK_ADMIN = [
id: '1',
title: 'Checkbox Example (Two State)',
gitSha: 'b7078039f789c125e269cb8f8632f57a03d4c50b',
testPlan: { directory: 'checkbox' }
gitMessage: 'The message for this SHA',
testPlan: { directory: 'checkbox' },
updatedAt: '2021-11-30T14:51:28.000Z'
},
draftTestPlanRuns: [
{
Expand Down Expand Up @@ -342,7 +346,9 @@ export const TEST_QUEUE_PAGE_POPULATED_MOCK_ADMIN = [
id: '1',
title: 'Checkbox Example (Two State)',
gitSha: 'b7078039f789c125e269cb8f8632f57a03d4c50b',
testPlan: { directory: 'checkbox' }
gitMessage: 'The message for this SHA',
testPlan: { directory: 'checkbox' },
updatedAt: '2021-11-30T14:51:28.000Z'
},
draftTestPlanRuns: [
{
Expand Down Expand Up @@ -555,9 +561,11 @@ export const TEST_QUEUE_PAGE_POPULATED_MOCK_TESTER = [
id: '65',
title: 'Checkbox Example (Two State)',
gitSha: 'aea64f84b8fa8b21e94f5d9afd7035570bc1bed3',
gitMessage: 'The message for this SHA',
testPlan: {
directory: 'checkbox'
}
},
updatedAt: '2021-11-30T14:51:28.000Z'
},
draftTestPlanRuns: [
{
Expand Down Expand Up @@ -696,9 +704,11 @@ export const TEST_QUEUE_PAGE_POPULATED_MOCK_TESTER = [
id: '65',
title: 'Checkbox Example (Two State)',
gitSha: 'aea64f84b8fa8b21e94f5d9afd7035570bc1bed3',
gitMessage: 'The message for this SHA',
testPlan: {
directory: 'checkbox'
}
},
updatedAt: '2021-11-30T14:51:28.000Z'
},
draftTestPlanRuns: [
{
Expand Down Expand Up @@ -780,9 +790,11 @@ export const TEST_QUEUE_PAGE_POPULATED_MOCK_TESTER = [
id: '74',
title: 'Editor Menubar Example',
gitSha: 'aea64f84b8fa8b21e94f5d9afd7035570bc1bed3',
gitMessage: 'The message for this SHA',
testPlan: {
directory: 'menubar-editor'
}
},
updatedAt: '2021-11-30T14:51:28.000Z'
},
draftTestPlanRuns: []
}
Expand Down
17 changes: 17 additions & 0 deletions client/utils/gitUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const gitUpdatedDateToString = dateString => {
const date = new Date(dateString);
let formattedDateString = `${date.toLocaleString('default', {
month: 'short'
})} ${date.getDate()}, ${date.getFullYear()} at ${date.toLocaleTimeString(
'default',
{ timeZone: 'UTC' }
)}`;
alflennik marked this conversation as resolved.
Show resolved Hide resolved

if (formattedDateString.includes('PM')) {
return formattedDateString.replace('PM', 'pm');
}

if (formattedDateString.includes('AM')) {
return formattedDateString.replace('AM', 'am');
}
};
15 changes: 15 additions & 0 deletions client/utils/gitUtils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { gitUpdatedDateToString } from './gitUtils';

describe('gitUpdatedDateToString', () => {
it('returns a formatted string AM', () => {
const date = '2021-11-30T09:51:28.000Z';
const formattedDate = gitUpdatedDateToString(date);
expect(formattedDate).toBe('Nov 30, 2021 at 9:51:28 am');
});

it('returns a formatted string PM', () => {
const date = '2021-11-30T14:51:28.000Z';
const formattedDate = gitUpdatedDateToString(date);
expect(formattedDate).toBe('Nov 30, 2021 at 2:51:28 pm');
});
});