Skip to content

Commit

Permalink
fix(#7892): restore "now" (marcus bains) line to planning views (#7898)
Browse files Browse the repository at this point in the history
* Initialize alignment offset to 0. (it was undefined). Also handle a small bug with swimlane configuration not getting replaced when the plan used by a gantt chart was changed

* lint: fix

* test: update visual tests to mock clock and show now line

---------

Co-authored-by: Mazzella, Jesse D. (ARC-TI)[KBR Wyle Services, LLC] <[email protected]>
  • Loading branch information
shefalijoshi and ozyx authored Oct 17, 2024
1 parent 7f8b5e0 commit 3e23dce
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions e2e/helper/planningUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export async function setBoundsToSpanAllActivities(page, planJson, planObjectUrl
*/
export function getEarliestStartTime(planJson) {
const activities = Object.values(planJson).flat();

return Math.min(...activities.map((activity) => activity.start));
}

Expand All @@ -139,6 +140,7 @@ export function getEarliestStartTime(planJson) {
*/
export function getLatestEndTime(planJson) {
const activities = Object.values(planJson).flat();

return Math.max(...activities.map((activity) => activity.end));
}

Expand All @@ -151,6 +153,7 @@ export function getFirstActivity(planJson) {
const groups = Object.keys(planJson);
const firstGroupKey = groups[0];
const firstGroupItems = planJson[firstGroupKey];

return firstGroupItems[0];
}

Expand Down
13 changes: 12 additions & 1 deletion e2e/tests/visual-a11y/planning-gantt.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,25 @@ import fs from 'fs';
import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../appActions.js';
import { scanForA11yViolations, test } from '../../avpFixtures.js';
import { VISUAL_FIXED_URL } from '../../constants.js';
import { setBoundsToSpanAllActivities, setDraftStatusForPlan } from '../../helper/planningUtils.js';
import {
getFirstActivity,
setBoundsToSpanAllActivities,
setDraftStatusForPlan
} from '../../helper/planningUtils.js';

const examplePlanSmall2 = JSON.parse(
fs.readFileSync(new URL('../../test-data/examplePlans/ExamplePlan_Small2.json', import.meta.url))
);

const FIRST_ACTIVITY_SMALL_2 = getFirstActivity(examplePlanSmall2);

test.describe('Visual - Gantt Chart @a11y', () => {
test.beforeEach(async ({ page }) => {
// Set the clock to the end of the first activity in the plan
// This is so we can see the "now" line in the plan view
await page.clock.install({ time: FIRST_ACTIVITY_SMALL_2.end + 10000 });
await page.clock.resume();

await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
});
test('Gantt Chart View', async ({ page, theme }) => {
Expand Down
9 changes: 8 additions & 1 deletion e2e/tests/visual-a11y/planning-timestrip.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../appAct
import { scanForA11yViolations, test } from '../../avpFixtures.js';
import { waitForAnimations } from '../../baseFixtures.js';
import { VISUAL_FIXED_URL } from '../../constants.js';
import { setBoundsToSpanAllActivities } from '../../helper/planningUtils.js';
import { getFirstActivity, setBoundsToSpanAllActivities } from '../../helper/planningUtils.js';

const examplePlanSmall2 = JSON.parse(
fs.readFileSync(new URL('../../test-data/examplePlans/ExamplePlan_Small2.json', import.meta.url))
);

const FIRST_ACTIVITY_SMALL_2 = getFirstActivity(examplePlanSmall2);

test.describe('Visual - Time Strip @a11y', () => {
test.beforeEach(async ({ page }) => {
// Set the clock to the end of the first activity in the plan
// This is so we can see the "now" line in the plan view
await page.clock.install({ time: FIRST_ACTIVITY_SMALL_2.end + 10000 });
await page.clock.resume();

await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
});
test('Time Strip View', async ({ page, theme }) => {
Expand Down
6 changes: 6 additions & 0 deletions e2e/tests/visual-a11y/planning-view.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const examplePlanSmall2 = JSON.parse(
);

const FIRST_ACTIVITY_SMALL_1 = getFirstActivity(examplePlanSmall1);
const FIRST_ACTIVITY_SMALL_2 = getFirstActivity(examplePlanSmall2);

test.describe('Visual - Timelist progress bar @clock @a11y', () => {
test.beforeEach(async ({ page }) => {
Expand All @@ -59,6 +60,11 @@ test.describe('Visual - Timelist progress bar @clock @a11y', () => {

test.describe('Visual - Plan View @a11y', () => {
test.beforeEach(async ({ page }) => {
// Set the clock to the end of the first activity in the plan
// This is so we can see the "now" line in the plan view
await page.clock.install({ time: FIRST_ACTIVITY_SMALL_2.end + 10000 });
await page.clock.resume();

await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
});

Expand Down
1 change: 1 addition & 0 deletions src/plugins/plan/components/PlanView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export default {
}
},
handleConfigurationChange(newConfiguration) {
this.configuration = this.planViewConfiguration.getConfiguration();
Object.keys(newConfiguration).forEach((key) => {
this[key] = newConfiguration[key];
});
Expand Down
2 changes: 2 additions & 0 deletions src/ui/components/TimeSystemAxis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default {
const svgWidth = ref(0);
const svgHeight = ref(0);
const axisTransform = ref('translate(0,20)');
const alignmentOffset = ref(0);
const nowMarkerStyle = reactive({
height: '0px',
left: '0px'
Expand All @@ -100,6 +101,7 @@ export default {
svgWidth,
svgHeight,
axisTransform,
alignmentOffset,
nowMarkerStyle,
openmct
};
Expand Down

0 comments on commit 3e23dce

Please sign in to comment.