@@ -236,3 +236,185 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-ui-dark-theme/package.j
236236+ "repository": {
237237+ }
238238+ }
239+ Index: sagemaker-code-editor/vscode/.vscode-test.js
240+ ===================================================================
241+ --- sagemaker-code-editor.orig/vscode/.vscode-test.js
242+ +++ sagemaker-code-editor/vscode/.vscode-test.js
243+ @@ -45,6 +45,11 @@ const extensions = [
244+ label: 'github-authentication',
245+ workspaceFolder: path.join(os.tmpdir(), `msft-auth-${Math.floor(Math.random() * 100000)}`),
246+ mocha: { timeout: 60_000 }
247+ + },
248+ + {
249+ + label: 'sagemaker-ui-dark-theme',
250+ + workspaceFolder: `extensions/sagemaker-ui-dark-theme/test-workspace`,
251+ + mocha: { timeout: 60_000 }
252+ }
253+ ];
254+
255+ Index: sagemaker-code-editor/vscode/extensions/sagemaker-ui-dark-theme/src/test/extension.test.ts
256+ ===================================================================
257+ --- /dev/null
258+ +++ sagemaker-code-editor/vscode/extensions/sagemaker-ui-dark-theme/src/test/extension.test.ts
259+ @@ -0,0 +1,123 @@
260+ + import * as assert from 'assert';
261+ + import * as vscode from 'vscode';
262+ +
263+ + const DEFAULT_DARK_MODERN = 'Default Dark Modern';
264+ + const DEFAULT_LIGHT_MODERN = 'Default Light Modern';
265+ +
266+ + async function waitForThemeChange(expectedTheme: string | undefined, timeoutMs: number): Promise<void> {
267+ + const startTime = Date.now();
268+ +
269+ + while (Date.now() - startTime < timeoutMs) {
270+ + const currentTheme = vscode.workspace.getConfiguration('workbench').inspect('colorTheme');
271+ +
272+ + if (currentTheme?.globalValue === expectedTheme) {
273+ + return;
274+ + }
275+ + await new Promise(resolve => setTimeout(resolve, 100));
276+ + }
277+ + throw new Error(`Theme did not change to ${expectedTheme} at the global level within ${timeoutMs}ms`);
278+ + }
279+ +
280+ + suite('SageMaker UI Dark Theme Extension Tests - In SageMaker Unified Studio Environment', () => {
281+ + // Store original ENV variable value
282+ + const originalEnv = process.env.SERVICE_NAME;
283+ +
284+ + suiteSetup(() => {
285+ + // Clear the theme configurations
286+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Global);
287+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Workspace);
288+ +
289+ + // Set ENV variable value for SageMaker Unified Studio environment
290+ + process.env.SERVICE_NAME = 'SageMakerUnifiedStudio';
291+ + });
292+ +
293+ + suiteTeardown(() => {
294+ + // Clear the theme configurations
295+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Global);
296+ +
297+ + // Restore ENV variable value to original
298+ + originalEnv ? (process.env.SERVICE_NAME = originalEnv) : delete process.env.SERVICE_NAME;
299+ + });
300+ +
301+ + test('Theme is set when global and workspace theme configurations are unset', async () => {
302+ + // Poll for theme update
303+ + await waitForThemeChange(DEFAULT_DARK_MODERN, 10000);
304+ +
305+ + const config = vscode.workspace.getConfiguration();
306+ + const theme = config.inspect('workbench.colorTheme');
307+ +
308+ + assert.strictEqual(theme?.globalValue, DEFAULT_DARK_MODERN, `Global theme should be set to ${DEFAULT_DARK_MODERN}`);
309+ + });
310+ + });
311+ +
312+ + suite('SageMaker UI Dark Theme Extension Tests - In SageMaker Unified Studio Environment', () => {
313+ + // Store original ENV variable value
314+ + const originalEnv = process.env.SERVICE_NAME;
315+ +
316+ + suiteSetup(() => {
317+ + // Set the global theme configuration to Default Light Modern
318+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', DEFAULT_LIGHT_MODERN, vscode.ConfigurationTarget.Global);
319+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Workspace);
320+ +
321+ + // Set ENV variable value for SageMaker Unified Studio environment
322+ + process.env.SERVICE_NAME = 'SageMakerUnifiedStudio';
323+ + });
324+ +
325+ + suiteTeardown(() => {
326+ + // Clear the theme configurations
327+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Global);
328+ +
329+ + // Restore ENV variable value to original
330+ + originalEnv ? (process.env.SERVICE_NAME = originalEnv) : delete process.env.SERVICE_NAME;
331+ + });
332+ +
333+ + test('Theme is not set when global theme configuration is set', async () => {
334+ + // Poll for theme update
335+ + await waitForThemeChange(DEFAULT_LIGHT_MODERN, 10000);
336+ +
337+ + // Poll for Default Dark Modern theme update (expected to fail)
338+ + try {
339+ + await waitForThemeChange(DEFAULT_DARK_MODERN, 10000);
340+ + assert.fail(`Global theme should be kept as ${DEFAULT_LIGHT_MODERN}`);
341+ + } catch (error) {
342+ + // Expected behavior: Theme should not be set
343+ + }
344+ +
345+ + const config = vscode.workspace.getConfiguration();
346+ + const theme = config.inspect('workbench.colorTheme');
347+ +
348+ + assert.strictEqual(theme?.globalValue, DEFAULT_LIGHT_MODERN, `Global theme should be kept as ${DEFAULT_LIGHT_MODERN}`);
349+ + });
350+ + });
351+ +
352+ + suite('SageMaker UI Dark Theme Extension Tests - In SageMaker AI Environment', () => {
353+ + // Store original ENV variable value
354+ + const originalEnv = process.env.SERVICE_NAME;
355+ +
356+ + suiteSetup(() => {
357+ + // Clear the global theme configuration
358+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Global);
359+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Workspace);
360+ +
361+ + // Ensure ENV variable value for SageMaker Unified Studio environment is NOT set
362+ + delete process.env.SERVICE_NAME;
363+ + });
364+ +
365+ + suiteTeardown(() => {
366+ + // Clear the global theme configuration
367+ + vscode.workspace.getConfiguration('workbench').update('colorTheme', undefined, vscode.ConfigurationTarget.Global);
368+ +
369+ + // Restore ENV variable value to original
370+ + originalEnv ? (process.env.SERVICE_NAME = originalEnv) : delete process.env.SERVICE_NAME;
371+ + });
372+ +
373+ + test('Theme is not set', async () => {
374+ + // Poll for theme update
375+ + await waitForThemeChange(undefined, 10000);
376+ +
377+ + const config = vscode.workspace.getConfiguration();
378+ + const theme = config.inspect('workbench.colorTheme');
379+ +
380+ + assert.strictEqual(theme?.globalValue, undefined, 'Global theme should not be set');
381+ + });
382+ + });
383+ Index: sagemaker-code-editor/vscode/extensions/sagemaker-ui-dark-theme/src/test/index.ts
384+ ===================================================================
385+ --- /dev/null
386+ +++ sagemaker-code-editor/vscode/extensions/sagemaker-ui-dark-theme/src/test/index.ts
387+ @@ -0,0 +1,33 @@
388+ + import * as path from 'path';
389+ + import * as testRunner from '../../../../test/integration/electron/testrunner';
390+ +
391+ + const options: import('mocha').MochaOptions = {
392+ + ui: 'tdd',
393+ + color: true,
394+ + timeout: 60000
395+ + };
396+ +
397+ + // Set the suite name
398+ + let suite = '';
399+ + if (process.env.VSCODE_BROWSER) {
400+ + suite = `${process.env.VSCODE_BROWSER} Browser Integration SageMaker UI Dark Theme Tests`;
401+ + } else if (process.env.REMOTE_VSCODE) {
402+ + suite = 'Remote Integration SageMaker UI Dark Theme Tests';
403+ + } else {
404+ + suite = 'Integration SageMaker UI Dark Theme Tests';
405+ + }
406+ +
407+ + if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
408+ + options.reporter = 'mocha-multi-reporters';
409+ + options.reporterOptions = {
410+ + reporterEnabled: 'spec, mocha-junit-reporter',
411+ + mochaJunitReporterReporterOptions: {
412+ + testsuitesTitle: `${suite} ${process.platform}`,
413+ + mochaFile: path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${process.arch}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`)
414+ + }
415+ + };
416+ + }
417+ +
418+ + testRunner.configure(options);
419+ +
420+ + export = testRunner;
0 commit comments