-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Introduce FitAddon tests #2483
Introduce FitAddon tests #2483
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that if I try something stupid, like having a 1x1 pixel #terminal-container the fit will propose a negative cols. Is this expected behavior?
I guess this is a bug, feel free to add a test for that and fix it (just prevent < 1x1 cell?)
await page.evaluate(` | ||
window.fit = new FitAddon(); | ||
window.term.loadAddon(window.fit); | ||
document.querySelector('#terminal-container').style.width='100%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be better as an absolute px
value in case #terminal-container
's container changes its size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
assert.equal(await page.evaluate(`window.fit.proposeDimensions()`), undefined); | ||
}); | ||
|
||
it('default propose fit', async function(): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move all tests relating to just proposeDimensions into describe('proposeDimensions', () => {
, and all fit ones into the same but 'fit'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave the no terminal
test outside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The no terminal test just uses proposeDimensions so it can live in there
await page.evaluate(` | ||
window.fit = new FitAddon(); | ||
window.term.loadAddon(window.fit); | ||
document.querySelector('#terminal-container').style.width='100%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again it might be safer to use px
How about this instead @Tyriar? it removes a bit of duplicated code, but we don't rely directly on the default width? I can revert otherwise. I still need to add one test for the 1x1 case, will do after work. Edit: 1008px is the equivalent of 100% in a 1024x768 screen (you have to account for margin, padding and so forth). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! Should be good to merge after the small width test.
I don't understand why the MacOS integration tests failed, I kept the same timeout that exists elsewhere? Also, regarding the FitAddon, it doesn't need to be smaller than 1x1 to break: it('small width', async function(): Promise<any> {
await openTerminal();
await loadFit(1);
console.log(await page.evaluate(`window.fit.proposeDimensions()`));
}); returns: { cols: -2, rows: 26 } it('small width', async function(): Promise<any> {
await openTerminal();
await loadFit(1);
await page.evaluate(`window.fit.fit()`);
console.log(await page.evaluate(`window.term.cols`));
console.log(await page.evaluate(`window.term.rows`));
}); returns:
What is the desired result? |
Checking the |
@leomoty proposeDimensions should give back the same number as an actual resize would, you can just hardcode the constant into the fit addon as well, should be enough as changing the other constant will break the test. |
Not sure, try narrow down which await is not returning? I'll requeue the build in case it's flakiness |
I have updated the Also updated FitAddon to respect MINIMUM_COLS and MINIMUM_ROWS. Mac OS is still flaky, but since I only have linux to test, I am not sure why. |
Looks good, I'll look into the mac test now |
I couldn't repro the flakiness on my mac, I pushed a change to avoid loading the page every time though which makes the tests take about 25% of the time. Hopefully the flakiness is fixed magically 🤞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They passed 3 times so I guess the flakiness is gone 🤷♂
Thanks for this! 👍
Fixes #2167
I have a few questions:
I want to remove the duplicated code to a helper function before merging.