Skip to content

Commit

Permalink
AXON-32 First iteration on e2e tests - no auth (#49)
Browse files Browse the repository at this point in the history
* First iteration on e2e tests - no auth

* add test file to branch

* lint
  • Loading branch information
bwieger-atlassian-com authored Dec 19, 2024
1 parent 197d21f commit c573c27
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 21,045 deletions.
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// increase default test case timeout to 5 seconds
module.exports = {
"timeout": 5000,
"timeout": 60000,
// For further investigation
// "extension": ["ts"],
// "exit": true,
Expand Down
21 changes: 21 additions & 0 deletions .vscode/launch.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug UI Tests",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/extest",
"windows": {
"program": "${workspaceFolder}/node_modules/vscode-extension-tester/out/cli.js",
},
"args": [
"run-tests",
"${workspaceFolder}/.generated/atlascode/e2e/tests/*.test.js",
"--code_settings",
"${workspaceFolder}/e2e/test-settings.json",
"--extensions_dir",
".test-extensions",
"--mocha_config",
"${workspaceFolder}/.mocharc.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "Extension",
"type": "extensionHost",
Expand Down
62 changes: 0 additions & 62 deletions e2e/tests/dummy.test.ts

This file was deleted.

86 changes: 86 additions & 0 deletions e2e/tests/no-auth.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { expect } from 'chai';
import { before, ActivityBar, after, SideBarView, By, WebView, EditorView, Workbench } from 'vscode-extension-tester';

describe('Atlassian Extension Activity Bar', async () => {
let activityBar: ActivityBar;

before(async () => {
activityBar = new ActivityBar();
});

after(async () => {});

it('should be installed', async () => {
const controls = await activityBar.getViewControls();
// Get title from every control
const titles = await Promise.all(controls.map(async (control) => control.getTitle()));

expect('Atlassian').to.be.oneOf(titles);
});
});

describe('Atlassian Extension SideBar', async () => {
let activityBar: ActivityBar;
let sideBarView: SideBarView;

before(async () => {
activityBar = new ActivityBar();
(await activityBar.getViewControl('Atlassian'))?.openView();
sideBarView = new SideBarView();
sideBarView.wait();

// wait for 2 seconds so the sidebar can load
await new Promise((res) => {
setTimeout(res, 2000);
});
});

after(async () => {});

it('should have a login action suggestion', async () => {
let atlasDrawer = sideBarView.findElement(By.id('workbench.view.extension.atlascode-drawer'));
expect(atlasDrawer).to.not.be.undefined;

// find element by aria-label: "Please login to Jira"
const loginButton = atlasDrawer.findElement(By.css('[aria-label="Please login to Jira"]'));
expect(loginButton).to.not.be.undefined;
expect(await loginButton.getText()).to.equal('Please login to Jira');
});
});

describe('Atlassian Extension Settings Page', async () => {
let view: WebView;

before(async () => {
await new EditorView().closeAllEditors();
await new Workbench().executeCommand('Atlassian: Open Settings');
await new Promise((res) => {
setTimeout(res, 6000);
});
// init the WebView page object
view = new WebView();
});

after(async () => {
// after we are done with the webview, switch webdriver back to the vscode window
await view.switchBack();
await new EditorView().closeAllEditors();
});

it('should have a title', async () => {
const title = await view.getTitle();
expect(title).to.equal('Atlassian Settings');
});

it('should have an Authentication Section', async () => {
// can't write this test because selectors on webViews is broken
// https://github.com/redhat-developer/vscode-extension-tester/issues/1492
// Going to add our repro steps to the issue in hopes that this gets fixed
// alternative: we could downgrade the version that we test.
// No. because we should be testing on the latest version of VSCode
// alternative: we could speed up the bug fix by contributing to the project
// Perhaps, but we have other priorities first. Eg: testing the authenticated flows
// alternative: we could do some kind of screenshot computer vision test
// Maybe, but seems overkill for something that looks like its going to be fixed soon
});
});
Loading

0 comments on commit c573c27

Please sign in to comment.