Skip to content

Commit

Permalink
Reactivate all text editor tests
Browse files Browse the repository at this point in the history
Due to the Monaco uplift, we had to temporarily skip a test, because
it affected the default preference regarding auto-save.

To re-enable the test, we now explicitly set the auto save preference to
`off` before the test. This way the preference value is ensured to be
consistent.

See also #10736

Fixes #10891

Change-Id: I6ab22a71848e174313a30f9121cb4b3dec363f12
  • Loading branch information
planger committed Apr 29, 2022
1 parent 9dc2ab5 commit a09c3d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/playwright/src/tests/theia-preference-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ test.describe('Preference View', () => {
const preferenceId = PreferenceIds.Editor.RenderWhitespace;

await preferences.resetPreferenceById(preferenceId);
expect(await preferences.getOptionsPreferenceById(preferenceId)).toBe(DefaultPreferences.Editor.RenderWhitespace.None);
expect(await preferences.getOptionsPreferenceById(preferenceId)).toBe(DefaultPreferences.Editor.RenderWhitespace.Selection);

await preferences.setOptionsPreferenceById(preferenceId, DefaultPreferences.Editor.RenderWhitespace.Boundary);
await preferences.waitForModified(preferenceId);
expect(await preferences.getOptionsPreferenceById(preferenceId)).toBe(DefaultPreferences.Editor.RenderWhitespace.Boundary);

await preferences.resetPreferenceById(preferenceId);
expect(await preferences.getOptionsPreferenceById(preferenceId)).toBe(DefaultPreferences.Editor.RenderWhitespace.None);
expect(await preferences.getOptionsPreferenceById(preferenceId)).toBe(DefaultPreferences.Editor.RenderWhitespace.Selection);
});

test('should throw an error if we try to read, set, or reset a non-existing preference', async () => {
Expand Down
8 changes: 7 additions & 1 deletion examples/playwright/src/tests/theia-text-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// *****************************************************************************

import { expect } from '@playwright/test';
import { DefaultPreferences, PreferenceIds, TheiaPreferenceView } from '../theia-preference-view';
import { TheiaApp } from '../theia-app';
import { TheiaTextEditor } from '../theia-text-editor';
import { TheiaWorkspace } from '../theia-workspace';
Expand All @@ -27,6 +28,11 @@ test.describe('Theia Text Editor', () => {
test.beforeAll(async () => {
const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
app = await TheiaApp.load(page, ws);

// set auto-save preference to off
const preferenceView = await app.openPreferences(TheiaPreferenceView);
await preferenceView.setOptionsPreferenceById(PreferenceIds.Editor.AutoSave, DefaultPreferences.Editor.AutoSave.Off);
await preferenceView.close();
});

test('should be visible and active after opening "sample.txt"', async () => {
Expand Down Expand Up @@ -164,7 +170,7 @@ test.describe('Theia Text Editor', () => {
await sampleTextEditor.saveAndClose();
});

test.skip('should close without saving', async () => {
test('should close without saving', async () => {
const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
await sampleTextEditor.replaceLineWithLineNumber('change again', 1);
expect(await sampleTextEditor.isDirty()).toBe(true);
Expand Down
8 changes: 5 additions & 3 deletions examples/playwright/src/theia-preference-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const TheiaSettingsViewData = {

export const PreferenceIds = {
Editor: {
AutoSave: 'editor.autoSave',
AutoSave: 'files.autoSave',
RenderWhitespace: 'editor.renderWhitespace'
},
Explorer: {
Expand All @@ -39,8 +39,10 @@ export const PreferenceIds = {
export const DefaultPreferences = {
Editor: {
AutoSave: {
On: 'on',
Off: 'off'
Off: 'off',
AfterDelay: 'afterDelay',
OnFocusChange: 'onFocusChange',
OnWindowChange: 'onWindowChange'
},
RenderWhitespace: {
None: 'none',
Expand Down

0 comments on commit a09c3d9

Please sign in to comment.