Skip to content

Commit

Permalink
fix: re-enable all playwright tests in the test suite
Browse files Browse the repository at this point in the history
Contributed on behalf of STMicroelectronics

Signed-off-by: Olaf Lessenich <[email protected]>
  • Loading branch information
xai committed Nov 24, 2023
1 parent 53a33a7 commit 7414b0b
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 114 deletions.
120 changes: 57 additions & 63 deletions examples/playwright/src/tests/theia-output-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,72 +20,66 @@ import { TheiaApp } from '../theia-app';
import { TheiaAppLoader } from '../theia-app-loader';
import { TheiaOutputView } from '../theia-output-view';

if (process.env.USE_ELECTRON === 'true') {
// TODO: remove this once the test is stable enough with electron
test.describe.skip('Theia Output View', () => { });
} else {
let app: TheiaApp; let outputView: TheiaOutputView; let testChannel: TheiaOutputViewChannel;
test.describe('Theia Output View', () => {
let app: TheiaApp; let outputView: TheiaOutputView; let testChannel: TheiaOutputViewChannel;
test.describe('Theia Output View', () => {

test.beforeAll(async ({ playwright, browser }) => {
app = await TheiaAppLoader.load({ playwright, browser });
});

test.afterAll(async () => {
await app.page.close();
});
test.beforeAll(async ({ playwright, browser }) => {
app = await TheiaAppLoader.load({ playwright, browser });
});

test('should open the output view and check if is visible and active', async () => {
outputView = await app.openView(TheiaOutputView);
expect(await outputView.isTabVisible()).toBe(true);
expect(await outputView.isDisplayed()).toBe(true);
expect(await outputView.isActive()).toBe(true);
});
test('should be opened at the bottom and have the title "Output"', async () => {
expect(await outputView.isInSidePanel()).toBe(false);
expect(await outputView.side()).toBe('bottom');
expect(await outputView.title()).toBe('Output');
});
test('should be closable', async () => {
expect(await outputView.isClosable()).toBe(true);
await outputView.close();
expect(await outputView.isTabVisible()).toBe(false);
expect(await outputView.isDisplayed()).toBe(false);
expect(await outputView.isActive()).toBe(false);
});
test('should select a test output channel', async () => {
outputView = await app.openView(TheiaOutputView);
expect(await outputView.isTabVisible()).toBe(true);
expect(await outputView.isDisplayed()).toBe(true);
expect(await outputView.isActive()).toBe(true);
test.afterAll(async () => {
await app.page.close();
});

const testChannelName = 'API Sample: my test channel';
expect(await outputView.selectOutputChannel(testChannelName)).toBe(true);
});
test('should check if the output view of the test output channel', async () => {
const testChannelName = 'API Sample: my test channel';
expect(await outputView.isOutputChannelSelected(testChannelName));
const channel = await outputView.getOutputChannel(testChannelName);
expect(channel).toBeDefined;
testChannel = channel!;
expect(await testChannel!.isDisplayed()).toBe(true);
});
test('should check if the output view test channel shows the test output', async () => {
expect(await testChannel.numberOfLines()).toBe(5);
expect(await testChannel.textContentOfLineByLineNumber(1)).toMatch('hello info1');
expect(await testChannel.maxSeverityOfLineByLineNumber(1)).toMatch('info');
expect(await testChannel.textContentOfLineByLineNumber(2)).toMatch('hello info2');
expect(await testChannel.maxSeverityOfLineByLineNumber(2)).toMatch('info');
expect(await testChannel.textContentOfLineByLineNumber(3)).toMatch('hello error');
expect(await testChannel.maxSeverityOfLineByLineNumber(3)).toMatch('error');
expect(await testChannel.textContentOfLineByLineNumber(4)).toMatch('hello warning');
expect(await testChannel.maxSeverityOfLineByLineNumber(4)).toMatch('warning');
expect(await testChannel.textContentOfLineByLineNumber(5)).toMatch(
'inlineInfo1 inlineWarning inlineError inlineInfo2'
);
expect(await testChannel.maxSeverityOfLineByLineNumber(5)).toMatch('error');
});
test('should open the output view and check if is visible and active', async () => {
outputView = await app.openView(TheiaOutputView);
expect(await outputView.isTabVisible()).toBe(true);
expect(await outputView.isDisplayed()).toBe(true);
expect(await outputView.isActive()).toBe(true);
});
test('should be opened at the bottom and have the title "Output"', async () => {
expect(await outputView.isInSidePanel()).toBe(false);
expect(await outputView.side()).toBe('bottom');
expect(await outputView.title()).toBe('Output');
});
test('should be closable', async () => {
expect(await outputView.isClosable()).toBe(true);
await outputView.close();
expect(await outputView.isTabVisible()).toBe(false);
expect(await outputView.isDisplayed()).toBe(false);
expect(await outputView.isActive()).toBe(false);
});
test('should select a test output channel', async () => {
outputView = await app.openView(TheiaOutputView);
expect(await outputView.isTabVisible()).toBe(true);
expect(await outputView.isDisplayed()).toBe(true);
expect(await outputView.isActive()).toBe(true);

const testChannelName = 'API Sample: my test channel';
expect(await outputView.selectOutputChannel(testChannelName)).toBe(true);
});
test('should check if the output view of the test output channel', async () => {
const testChannelName = 'API Sample: my test channel';
expect(await outputView.isOutputChannelSelected(testChannelName));
const channel = await outputView.getOutputChannel(testChannelName);
expect(channel).toBeDefined;
testChannel = channel!;
expect(await testChannel!.isDisplayed()).toBe(true);
});
test('should check if the output view test channel shows the test output', async () => {
expect(await testChannel.numberOfLines()).toBe(5);
expect(await testChannel.textContentOfLineByLineNumber(1)).toMatch('hello info1');
expect(await testChannel.maxSeverityOfLineByLineNumber(1)).toMatch('info');
expect(await testChannel.textContentOfLineByLineNumber(2)).toMatch('hello info2');
expect(await testChannel.maxSeverityOfLineByLineNumber(2)).toMatch('info');
expect(await testChannel.textContentOfLineByLineNumber(3)).toMatch('hello error');
expect(await testChannel.maxSeverityOfLineByLineNumber(3)).toMatch('error');
expect(await testChannel.textContentOfLineByLineNumber(4)).toMatch('hello warning');
expect(await testChannel.maxSeverityOfLineByLineNumber(4)).toMatch('warning');
expect(await testChannel.textContentOfLineByLineNumber(5)).toMatch(
'inlineInfo1 inlineWarning inlineError inlineInfo2'
);
expect(await testChannel.maxSeverityOfLineByLineNumber(5)).toMatch('error');
});

}
});
97 changes: 46 additions & 51 deletions examples/playwright/src/tests/theia-quick-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,58 @@ import { TheiaNotificationIndicator } from '../theia-notification-indicator';
import { TheiaNotificationOverlay } from '../theia-notification-overlay';
import { TheiaQuickCommandPalette } from '../theia-quick-command-palette';

if (process.env.USE_ELECTRON === 'true') {
// TODO: remove this once the test is stable enough with electron
test.describe.skip('Theia Quick Command', () => { });
} else {
test.describe('Theia Quick Command', () => {
test.describe('Theia Quick Command', () => {

let app: TheiaApp;
let quickCommand: TheiaQuickCommandPalette;
let app: TheiaApp;
let quickCommand: TheiaQuickCommandPalette;

test.beforeAll(async ({ playwright, browser }) => {
app = await TheiaAppLoader.load({ playwright, browser });
quickCommand = app.quickCommandPalette;
});

test.afterAll(async () => {
await app.page.close();
});
test.beforeAll(async ({ playwright, browser }) => {
app = await TheiaAppLoader.load({ playwright, browser });
quickCommand = app.quickCommandPalette;
});

test('should show quick command palette', async () => {
await quickCommand.open();
expect(await quickCommand.isOpen()).toBe(true);
await quickCommand.hide();
expect(await quickCommand.isOpen()).toBe(false);
await quickCommand.open();
expect(await quickCommand.isOpen()).toBe(true);
});
test.afterAll(async () => {
await app.page.close();
});

test('should trigger \'About\' command after typing', async () => {
await quickCommand.type('About');
await quickCommand.trigger('About');
expect(await quickCommand.isOpen()).toBe(false);
const aboutDialog = new TheiaAboutDialog(app);
expect(await aboutDialog.isVisible()).toBe(true);
await aboutDialog.close();
expect(await aboutDialog.isVisible()).toBe(false);
test('should show quick command palette', async () => {
await quickCommand.open();
expect(await quickCommand.isOpen()).toBe(true);
await quickCommand.hide();
expect(await quickCommand.isOpen()).toBe(false);
await quickCommand.open();
expect(await quickCommand.isOpen()).toBe(true);
});

await quickCommand.type('Select All');
await quickCommand.trigger('Select All');
expect(await quickCommand.isOpen()).toBe(false);
});
test('should trigger \'About\' command after typing', async () => {
await quickCommand.type('About');
await quickCommand.trigger('About');
expect(await quickCommand.isOpen()).toBe(false);
const aboutDialog = new TheiaAboutDialog(app);
expect(await aboutDialog.isVisible()).toBe(true);
await aboutDialog.close();
expect(await aboutDialog.isVisible()).toBe(false);

test('should trigger \'Toggle Explorer View\' command after typing', async () => {
await quickCommand.type('Toggle Explorer');
await quickCommand.trigger('Toggle Explorer View');
expect(await quickCommand.isOpen()).toBe(false);
const explorerView = new TheiaExplorerView(app);
expect(await explorerView.isDisplayed()).toBe(true);
});
await quickCommand.type('Select All');
await quickCommand.trigger('Select All');
expect(await quickCommand.isOpen()).toBe(false);
});

test('should trigger \'Quick Input: Test Positive Integer\' command by confirming via Enter', async () => {
await quickCommand.type('Test Positive', true);
expect(await quickCommand.isOpen()).toBe(true);
await quickCommand.type('6', true);
const notificationIndicator = new TheiaNotificationIndicator(app);
const notification = new TheiaNotificationOverlay(app, notificationIndicator);
expect(await notification.isEntryVisible('Positive Integer: 6')).toBe(true);
});
test('should trigger \'Toggle Explorer View\' command after typing', async () => {
await quickCommand.type('Toggle Explorer');
await quickCommand.trigger('Toggle Explorer View');
expect(await quickCommand.isOpen()).toBe(false);
const explorerView = new TheiaExplorerView(app);
expect(await explorerView.isDisplayed()).toBe(true);
});

test('should trigger \'Quick Input: Test Positive Integer\' command by confirming via Enter', async () => {
await quickCommand.type('Test Positive', true);
expect(await quickCommand.isOpen()).toBe(true);
await quickCommand.type('6', true);
const notificationIndicator = new TheiaNotificationIndicator(app);
const notification = new TheiaNotificationOverlay(app, notificationIndicator);
expect(await notification.isEntryVisible('Positive Integer: 6')).toBe(true);
});
}

});

0 comments on commit 7414b0b

Please sign in to comment.