Skip to content

Commit

Permalink
e2e-test: fix scm.test.ts flake (#6165)
Browse files Browse the repository at this point in the history
  • Loading branch information
midleman authored Jan 30, 2025
1 parent 272e475 commit 379a3f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
38 changes: 10 additions & 28 deletions test/e2e/pages/scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { Layouts } from './layouts';

const VIEWLET = 'div[id="workbench.view.scm"]';
const SCM_INPUT_TEXTAREA = `${VIEWLET} .scm-editor textarea`;
const SCM_RESOURCE = `${VIEWLET} .monaco-list-row .resource`;
const SCM_RESOURCE_CLICK = (name: string) => `${VIEWLET} .monaco-list-row .resource .monaco-icon-label[aria-label*="${name}"] .label-name`;
const SCM_RESOURCE_ACTION_CLICK = (name: string, actionName: string) => `.monaco-list-row .resource .monaco-icon-label[aria-label*="${name}"] .actions .action-label[aria-label="${actionName}"]`;
const COMMIT_COMMAND = `div[id="workbench.parts.sidebar"] .actions-container a.action-label[aria-label="Commit"]`;
Expand All @@ -28,34 +27,17 @@ export class SCM {
await expect(this.code.driver.page.locator(SCM_INPUT_TEXTAREA)).toBeVisible();
}

async waitForChange(name: string, type: string): Promise<void> {
await expect(async () => {
async waitForChange(name: string, type: 'Staged' | 'Modified'): Promise<void> {
await this.layout.enterLayout('fullSizedSidebar');

await this.layout.enterLayout('fullSizedSidebar');
const tooltip = type === 'Staged' ? 'Index Modified' : 'Modified';
const locator = this.code.driver.page
.getByLabel('Source Control Management')
.locator(`[data-tooltip="${tooltip}"] .file-icon`)
.filter({ hasText: name });

const scmResources = await this.code.driver.page.locator(SCM_RESOURCE).all();

const resources: { name: string; type: string }[] = [];
for (const resource of scmResources) {
const text = await resource.locator('.label-name').textContent();
const tooltip = await resource.getAttribute('data-tooltip') || '';

if (text !== null) {
resources.push({ name: text.trim(), type: tooltip.trim() });
}
}

// debug
resources.forEach(resource => this.code.logger.log(`Name: ${resource.name}, Type: ${resource.type}`));

// Check if at least one resource matches both name and type
expect(resources).toEqual(
expect.arrayContaining([{ name, type }])
);

await this.layout.enterLayout('stacked');

}).toPass({ timeout: 20000 });
await expect(locator).toBeVisible();
await this.layout.enterLayout('stacked');
}

async openChange(name: string): Promise<void> {
Expand All @@ -64,7 +46,7 @@ export class SCM {

async stage(name: string): Promise<void> {
await this.code.driver.page.locator(SCM_RESOURCE_ACTION_CLICK(name, 'Stage Changes')).click();
await this.waitForChange(name, 'Index Modified');
await this.waitForChange(name, 'Staged');
}

async commit(message: string): Promise<void> {
Expand Down
6 changes: 2 additions & 4 deletions test/e2e/tests/scm/scm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ test.use({
suiteId: __filename
});

test.describe('SCM', {
test.describe('Source Content Management', {
tag: [tags.SCM, tags.WEB, tags.WIN]
}, () => {

test('Verify SCM Functionality', async function ({ app, openFile }) {
test('Verify SCM Tracks File Modifications, Staging, and Commit Actions', async function ({ app, openFile }) {

const file = 'chinook-sqlite.py';
await test.step('Open file and add a new line to it', async () => {
Expand Down Expand Up @@ -59,7 +59,5 @@ test.describe('SCM', {
// git user for a real commit to take place:
// await app.workbench.scm.verifyCurrentHistoryItem(message);
});


});
});

0 comments on commit 379a3f4

Please sign in to comment.