mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 09:52:04 +00:00
Resize plans properly (#7597)
* resize firing * ensure watcher fires * remove unneeded const * add small visual test resizing plan * use browser with null viewport * lint
This commit is contained in:
parent
4027eae299
commit
f189a4d602
@ -72,11 +72,29 @@ test.describe('Visual - Planning', () => {
|
|||||||
name: 'Plan Visual Test',
|
name: 'Plan Visual Test',
|
||||||
json: examplePlanSmall2
|
json: examplePlanSmall2
|
||||||
});
|
});
|
||||||
|
|
||||||
await setBoundsToSpanAllActivities(page, examplePlanSmall2, plan.url);
|
await setBoundsToSpanAllActivities(page, examplePlanSmall2, plan.url);
|
||||||
await percySnapshot(page, `Plan View (theme: ${theme})`);
|
await percySnapshot(page, `Plan View (theme: ${theme})`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Resize Plan View @2p', async ({ browser, theme }) => {
|
||||||
|
// need to set viewport to null to allow for resizing
|
||||||
|
const newContext = await browser.newContext({
|
||||||
|
viewport: null
|
||||||
|
});
|
||||||
|
const newPage = await newContext.newPage();
|
||||||
|
|
||||||
|
await newPage.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' });
|
||||||
|
const plan = await createPlanFromJSON(newPage, {
|
||||||
|
name: 'Plan Visual Test',
|
||||||
|
json: examplePlanSmall2
|
||||||
|
});
|
||||||
|
|
||||||
|
await setBoundsToSpanAllActivities(newPage, examplePlanSmall2, plan.url);
|
||||||
|
// resize the window
|
||||||
|
await newPage.setViewportSize({ width: 800, height: 600 });
|
||||||
|
await percySnapshot(newPage, `Plan View resized (theme: ${theme})`);
|
||||||
|
});
|
||||||
|
|
||||||
test('Plan View w/ draft status', async ({ page, theme }) => {
|
test('Plan View w/ draft status', async ({ page, theme }) => {
|
||||||
const plan = await createPlanFromJSON(page, {
|
const plan = await createPlanFromJSON(page, {
|
||||||
name: 'Plan Visual Test (Draft)',
|
name: 'Plan Visual Test (Draft)',
|
||||||
|
@ -77,12 +77,13 @@ export default {
|
|||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const axisHolder = ref(null);
|
const axisHolder = ref(null);
|
||||||
const { size, startObserving } = useResizeObserver();
|
const { size: containerSize, startObserving } = useResizeObserver();
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
startObserving(axisHolder.value);
|
startObserving(axisHolder.value);
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
containerSize: size
|
axisHolder,
|
||||||
|
containerSize
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -95,8 +96,11 @@ export default {
|
|||||||
contentHeight() {
|
contentHeight() {
|
||||||
this.updateNowMarker();
|
this.updateNowMarker();
|
||||||
},
|
},
|
||||||
containerSize() {
|
containerSize: {
|
||||||
this.resize();
|
handler() {
|
||||||
|
this.resize();
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -104,7 +108,7 @@ export default {
|
|||||||
this.useSVG = true;
|
this.useSVG = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container = select(this.$refs.axisHolder);
|
this.container = select(this.axisHolder);
|
||||||
this.svgElement = this.container.append('svg:svg');
|
this.svgElement = this.container.append('svg:svg');
|
||||||
// draw x axis with labels. CSS is used to position them.
|
// draw x axis with labels. CSS is used to position them.
|
||||||
this.axisElement = this.svgElement
|
this.axisElement = this.svgElement
|
||||||
@ -122,7 +126,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resize() {
|
resize() {
|
||||||
if (this.$refs.axisHolder.clientWidth !== this.width) {
|
if (this.axisHolder.clientWidth !== this.width) {
|
||||||
this.setDimensions();
|
this.setDimensions();
|
||||||
this.drawAxis(this.bounds, this.timeSystem);
|
this.drawAxis(this.bounds, this.timeSystem);
|
||||||
this.updateNowMarker();
|
this.updateNowMarker();
|
||||||
@ -139,11 +143,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setDimensions() {
|
setDimensions() {
|
||||||
const axisHolder = this.$refs.axisHolder;
|
this.width = this.axisHolder.clientWidth;
|
||||||
this.width = axisHolder.clientWidth;
|
|
||||||
this.offsetWidth = this.width - this.offset;
|
this.offsetWidth = this.width - this.offset;
|
||||||
|
|
||||||
this.height = Math.round(axisHolder.getBoundingClientRect().height);
|
this.height = Math.round(this.axisHolder.getBoundingClientRect().height);
|
||||||
|
|
||||||
if (this.useSVG) {
|
if (this.useSVG) {
|
||||||
this.svgElement.attr('width', this.width);
|
this.svgElement.attr('width', this.width);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user