Skip to content

Commit

Permalink
feat: add connect-to-nx-cloud command (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKless authored Oct 18, 2022
1 parent d30d166 commit 22af88c
Show file tree
Hide file tree
Showing 28 changed files with 6,021 additions and 337 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/nx-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ runs:
run: yarn exec nx affected --target=e2e --parallel=3 --configuration=ci
shell: bash
- name: Stopping nx-cloud ci agents
if: always()
run: npx nx-cloud stop-all-agents
shell: bash
- name: Stopping e2e agent
if: always()
run: npx nx-cloud stop-all-agents
shell: bash
env:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import e2eBase from './connect-to-nx-cloud.e2e-base';

describe('Connect to Nx Cloud button with Nx latest', e2eBase('nx'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import e2eBase from './connect-to-nx-cloud.e2e-base';

describe('Connect to Nx Cloud button with Nx 11', e2eBase('nx11'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import {
CustomTreeItem,
SideBarView,
ViewItemAction,
ViewSection,
} from 'wdio-vscode-service';
import {
assertWorkspaceIsLoaded,
closeAllSectionsExcept,
openNxConsoleViewContainer,
openWorkspace,
TestWorkspaceKind,
} from '../utils';

export default (workspaceKind: TestWorkspaceKind) => () => {
let nxConsoleViewContainer: SideBarView<unknown>;
let helpAndFeedbackSection: ViewSection;
let helpAndFeedbackItems: CustomTreeItem[];

describe('Connect to Nx Cloud button', () => {
before(async () => {
await openWorkspace(workspaceKind);
});

it('should load VSCode', assertWorkspaceIsLoaded('nx'));

it('should show disconnected nx cloud status', async () => {
nxConsoleViewContainer = await openNxConsoleViewContainer();

closeAllSectionsExcept(nxConsoleViewContainer, 'HELP AND FEEDBACK');

await browser.waitUntil(async () => {
let view: ViewSection;
try {
view = await nxConsoleViewContainer
.getContent()
.getSection('HELP AND FEEDBACK');
} catch (error) {
view = undefined;
}
if (view) {
helpAndFeedbackSection = view;
return true;
}
});

helpAndFeedbackItems = await getHelpAndFeedbackItems();

const labels = await Promise.all(
helpAndFeedbackItems.map((i) => i.getLabel())
);
expect(labels).toContain('Disconnected from Nx Cloud. Connect now?');
});

it('should connect to nx cloud via button', async () => {
let connectToNxCloudTreeItem: CustomTreeItem;
for (const item of helpAndFeedbackItems) {
if (
(await item.getLabel()) === 'Disconnected from Nx Cloud. Connect now?'
) {
connectToNxCloudTreeItem = item;
}
}

const treeItemElem = await connectToNxCloudTreeItem.elem;
await treeItemElem.waitForClickable();
treeItemElem.click();

let actionButtons: ViewItemAction[];
await browser.waitUntil(async () => {
const abs = await connectToNxCloudTreeItem.getActionButtons();
if (abs.length > 0) {
actionButtons = abs;
return true;
}
});

const launchButton = await actionButtons[0].elem;
await launchButton.waitForClickable();
launchButton.click();

await browser.waitUntil(
async () => {
const hafItems = await getHelpAndFeedbackItems();
const labels = await Promise.all(hafItems.map((i) => i.getLabel()));
if (labels.includes('You are connected to Nx Cloud!')) {
return true;
}
},
{
timeout: 300000,
timeoutMsg: 'Connection to Nx Cloud not established within 20s',
interval: 1000,
}
);
});
});

async function getHelpAndFeedbackItems() {
let hafItems: CustomTreeItem[];
await browser.waitUntil(async () => {
const items = await helpAndFeedbackSection.getVisibleItems();
if (items.length > 0) {
hafItems = items as CustomTreeItem[];
return true;
}
});
return hafItems;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
assertWorkspaceIsLoaded,
openNxConsoleViewContainer,
openWorkspace,
} from './utils';
} from '../utils';

describe('NxConsole Projects View in an empty workspace', () => {
before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
closeAllSectionsExcept,
openNxConsoleViewContainer,
openWorkspace,
} from './utils';
} from '../utils';

let nxConsoleViewContainer: SideBarView<unknown>;
let projectsSection: ViewSection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
closeAllSectionsExcept,
openNxConsoleViewContainer,
openWorkspace,
} from './utils';
} from '../utils';

let nxConsoleViewContainer: SideBarView<unknown>;
let projectsSection: ViewSection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
closeAllSectionsExcept,
openNxConsoleViewContainer,
openWorkspace,
} from './utils';
} from '../utils';

let nxConsoleViewContainer: SideBarView<unknown>;
let projectsSection: ViewSection;
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode-e2e/specs/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path';
import { SideBarView } from 'wdio-vscode-service';

export type TestWorkspaceKind = 'empty' | 'nx' | 'ng' | 'lerna';
export type TestWorkspaceKind = 'empty' | 'nx' | 'ng' | 'lerna' | 'nx11';
export async function openWorkspace(workspace: TestWorkspaceKind) {
const testFolder = join(
getTestWorkspacePath(),
Expand Down
12 changes: 12 additions & 0 deletions apps/vscode-e2e/testworkspaces/testworkspace-nx/migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"migrations": [
{
"version": "14.8.0-beta.0",
"description": "Migrates from @nrwl/workspace:run-commands to nx:run-commands",
"cli": "nx",
"implementation": "./src/migrations/update-14-8-0/change-run-commands-executor",
"package": "@nrwl/workspace",
"name": "14-8-0-change-run-commands-executor"
}
]
}
Loading

0 comments on commit 22af88c

Please sign in to comment.