mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 00:46:16 -04:00
tests: Refine frontend tests
* Switch from `helper.newPad()` to `helper.aNewPad()`. * Promisify. * Delete redundant logic. * Lint fixes.
This commit is contained in:
parent
3790c0e41c
commit
bbf89dfcf9
35 changed files with 697 additions and 842 deletions
|
@ -4,49 +4,42 @@ describe('Pad modal', function () {
|
|||
context('when modal is a "force reconnect" message', function () {
|
||||
const MODAL_SELECTOR = '#connectivity';
|
||||
|
||||
beforeEach(function (done) {
|
||||
helper.newPad(() => {
|
||||
// force a "slowcommit" error
|
||||
helper.padChrome$.window.pad.handleChannelStateChange('DISCONNECTED', 'slowcommit');
|
||||
|
||||
// wait for modal to be displayed
|
||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||
helper.waitFor(() => $modal.hasClass('popup-show'), 50000).done(done);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
|
||||
// force a "slowcommit" error
|
||||
helper.padChrome$.window.pad.handleChannelStateChange('DISCONNECTED', 'slowcommit');
|
||||
|
||||
// wait for modal to be displayed
|
||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||
await helper.waitForPromise(() => $modal.hasClass('popup-show'), 50000);
|
||||
});
|
||||
|
||||
it('disables editor', function (done) {
|
||||
it('disables editor', async function () {
|
||||
this.timeout(200);
|
||||
expect(isEditorDisabled()).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
context('and user clicks on editor', function () {
|
||||
it('does not close the modal', function (done) {
|
||||
it('does not close the modal', async function () {
|
||||
this.timeout(200);
|
||||
clickOnPadInner();
|
||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||
const modalIsVisible = $modal.hasClass('popup-show');
|
||||
|
||||
expect(modalIsVisible).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
context('and user clicks on pad outer', function () {
|
||||
it('does not close the modal', function (done) {
|
||||
it('does not close the modal', async function () {
|
||||
this.timeout(200);
|
||||
clickOnPadOuter();
|
||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||
const modalIsVisible = $modal.hasClass('popup-show');
|
||||
|
||||
expect(modalIsVisible).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -55,20 +48,17 @@ describe('Pad modal', function () {
|
|||
context('when modal is not an error message', function () {
|
||||
const MODAL_SELECTOR = '#settings';
|
||||
|
||||
beforeEach(function (done) {
|
||||
helper.newPad(() => {
|
||||
openSettingsAndWaitForModalToBeVisible(done);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
await openSettingsAndWaitForModalToBeVisible();
|
||||
});
|
||||
|
||||
// This test breaks safari testing
|
||||
/*
|
||||
it('does not disable editor', function(done) {
|
||||
xit('does not disable editor', async function () {
|
||||
expect(isEditorDisabled()).to.be(false);
|
||||
done();
|
||||
});
|
||||
*/
|
||||
|
||||
context('and user clicks on editor', function () {
|
||||
it('closes the modal', async function () {
|
||||
this.timeout(200);
|
||||
|
@ -96,12 +86,12 @@ describe('Pad modal', function () {
|
|||
$lineNumbersColumn.click();
|
||||
};
|
||||
|
||||
const openSettingsAndWaitForModalToBeVisible = (done) => {
|
||||
const openSettingsAndWaitForModalToBeVisible = async () => {
|
||||
helper.padChrome$('.buttonicon-settings').click();
|
||||
|
||||
// wait for modal to be displayed
|
||||
const modalSelector = '#settings';
|
||||
helper.waitFor(() => isModalOpened(modalSelector), 10000).done(done);
|
||||
await helper.waitForPromise(() => isModalOpened(modalSelector), 10000);
|
||||
};
|
||||
|
||||
const isEditorDisabled = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue