Skip to content

Commit

Permalink
patch: passing url e2e on mac ?
Browse files Browse the repository at this point in the history
  • Loading branch information
aethernet committed Apr 26, 2024
1 parent f286376 commit 8ad42f1
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ runs:
run: |
hdiutil create -size 4096m -layout NONE -o virtual_test_disk.dmg
virtual_path=$(hdiutil attach -nomount virtual_test_disk.dmg)
echo "VIRTUAL_TEST_DISK=${virtual_path}" >> $GITHUB_ENV
echo "TARGET_DRIVE=${virtual_path}" >> $GITHUB_ENV
echo "ETCHER_INCLUDE_VIRTUAL_DRIVES=1" >> $GITHUB_ENV
- name: Test release
Expand Down
2 changes: 1 addition & 1 deletion lib/gui/app/components/drive-selector/drive-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export class DriveSelector extends React.Component<
primary: !showWarnings,
warning: showWarnings,
disabled: !hasAvailableDrives(),
"data-testid": 'validate-target-button',
'data-testid': 'validate-target-button',
}}
{...props}
>
Expand Down
4 changes: 3 additions & 1 deletion lib/gui/app/components/progress-button/progress-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export class ProgressButton extends React.PureComponent<ProgressButtonProps> {
}}
>
<Flex>
<Txt data-testid="flash-status" color="#fff">{status}&nbsp;</Txt>
<Txt data-testid="flash-status" color="#fff">
{status}&nbsp;
</Txt>
<Txt color={colors[type]}>{position}</Txt>
</Flex>
{type && (
Expand Down
2 changes: 1 addition & 1 deletion lib/gui/app/components/source-selector/source-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const URLSelector = ({
cancel={cancel}
primaryButtonProps={{
disabled: loading || !imageURL,
"data-testid":"source-url-ok-button",
'data-testid': 'source-url-ok-button',
}}
action={loading ? <Spinner /> : i18next.t('ok')}
done={async () => {
Expand Down
3 changes: 2 additions & 1 deletion lib/util/drive-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { geteuid, platform } from 'process';
const adapters: Adapter[] = [
new BlockDeviceAdapter({
includeSystemDrives: () => true,
includeVirtualDrives: () => process.env.ETCHER_INCLUDE_VIRTUAL_DRIVES === '1',
includeVirtualDrives: () =>
process.env.ETCHER_INCLUDE_VIRTUAL_DRIVES === '1',
}),
];

Expand Down
45 changes: 23 additions & 22 deletions tests/e2e/e2e-flash-from-file.spec.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
import { browser } from '@wdio/globals';
import { FlashResults } from '../../lib/gui/app/components/flash-results/flash-results';

describe('Electron Testing', () => {
it('should print application title', async () => {
console.log('Hello', await browser.getTitle(), 'application!');
});

it('should "flash from file"', async () => {
const flashFromFileButton = $('button[data-testid="flash-from-file"]')
await flashFromFileButton.waitForDisplayed({timeout: 10000})
const flashFromFileButton = $('button[data-testid="flash-from-file"]');
await flashFromFileButton.waitForDisplayed({ timeout: 10000 });
// const isDisplayed = await flashFromFileButton.isDisplayed();
await flashFromFileButton.click();

const selectTargetButton = $('button[data-testid="select-target-button"]')
await selectTargetButton.waitForClickable({timeout: 30000})
const selectTargetButton = $('button[data-testid="select-target-button"]');
await selectTargetButton.waitForClickable({ timeout: 30000 });
await selectTargetButton.click();

// TODO: Select target using ENV variable for the drive
const targetVirtualDrive = $('=/dev/disk8')
await targetVirtualDrive.waitForDisplayed({timeout: 10000})
await targetVirtualDrive.click();
// TODO: Select target using ENV variable for the drive
const targetVirtualDrive = $('=/dev/disk8');
await targetVirtualDrive.waitForDisplayed({ timeout: 10000 });
await targetVirtualDrive.click();

const validateTargetButton = $('button[data-testid="validate-target-button"]')
await validateTargetButton.waitForClickable({timeout: 10000})
const validateTargetButton = $(
'button[data-testid="validate-target-button"]',
);
await validateTargetButton.waitForClickable({ timeout: 10000 });
await validateTargetButton.click();
const flashNowButton= $('button[data-testid="flash-now-button"]')
await flashNowButton.waitForClickable({timeout: 10000})

const flashNowButton = $('button[data-testid="flash-now-button"]');
await flashNowButton.waitForClickable({ timeout: 10000 });
await flashNowButton.click();

// FIXME: not able to find the flashResults :(
const flashResults = $('span[data-testid="flash-results"]')
await flashResults.waitForDisplayed({timeout: 20000})
expect(flashResults.getText()).toBe('Flash Completed!')
// we're good;
// now we should check the content of the image but we can do that outside wdio
// FIXME: not able to find the flashResults :(
const flashResults = $('span[data-testid="flash-results"]');
await flashResults.waitForDisplayed({ timeout: 20000 });

expect(flashResults.getText()).toBe('Flash Completed!');

// we're good;
// now we should check the content of the image but we can do that outside wdio
});
});
59 changes: 45 additions & 14 deletions tests/e2e/e2e-flash-from-url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,57 @@ describe('Electron Testing', () => {
console.log('Hello', await browser.getTitle(), 'application!');
});

it('should "flash from url"', async () => {
const flashFromUrlButton = $('button[data-testid="flash-from-url"]')
await flashFromUrlButton.waitForDisplayed({timeout: 10000})
it('should "select an url source"', async () => {
const flashFromUrlButton = $('button[data-testid="flash-from-url"]');
await flashFromUrlButton.waitForDisplayed({ timeout: 10000 });
// const isDisplayed = await flashFromFileButton.isDisplayed();
await flashFromUrlButton.click();

const enterValidUrlInput = $('input[data-testid="source-url-input"]')
await enterValidUrlInput.waitForDisplayed({timeout: 10000})

// TODO: use an env variable for the URL
await enterValidUrlInput.setValue('https://api.balena-cloud.com/download?deviceType=raspberrypi4-64&version=5.2.8&fileType=.zip&developmentMode=true')
const enterValidUrlInput = $('input[data-testid="source-url-input"]');
await enterValidUrlInput.waitForDisplayed({ timeout: 10000 });

// FIXME: this is a workaround for the sidecar to have the time to load in the background
// We have a race condition to fix here
browser.pause(3000); // 3-second delay
// TODO: use an env variable for the URL
await enterValidUrlInput.setValue(
'https://api.balena-cloud.com/download?deviceType=raspberrypi4-64&version=5.2.8&fileType=.zip&developmentMode=true',
);

const sourceUrlOkButton = $('button[data-testid="source-url-ok-button"]')
await sourceUrlOkButton.waitForDisplayed({timeout: 10000})
const sourceUrlOkButton = $('button[data-testid="source-url-ok-button"]');
await sourceUrlOkButton.waitForDisplayed({ timeout: 10000 });
await sourceUrlOkButton.click();
});

it('should "select a virtual target"', async () => {
const selectTargetButton = $('button[data-testid="select-target-button"]');
await selectTargetButton.waitForClickable({ timeout: 30000 });
await selectTargetButton.click();

// target drive is set in the github custom test action
// if you run the test locally, pass the varibale
const targetVirtualDrive = $(`=${process.env.TARGET_DRIVE}`);
await targetVirtualDrive.waitForDisplayed({ timeout: 10000 });
await targetVirtualDrive.click();

const validateTargetButton = $(
'button[data-testid="validate-target-button"]',
);
await validateTargetButton.waitForClickable({ timeout: 10000 });
await validateTargetButton.click();
});

it('should "start flashing"', async () => {
const flashNowButton = $('button[data-testid="flash-now-button"]');
await flashNowButton.waitForClickable({ timeout: 10000 });
await flashNowButton.click();
});

it('should find "Flash Completed" screen', async () => {
const flashResults = $('[data-testid="flash-results"]');
await flashResults.waitForDisplayed({ timeout: 180000 });

const flashResultsText = await flashResults.getText();
expect(flashResultsText).toBe('Flash Completed!');

// we're blocked here because of a bug with URL loading
// we're good;
// now we should check the content of the image but we can do that outside wdio
});
});
4 changes: 2 additions & 2 deletions wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export const config: Options.Testrunner = {

suites: {
'e2e': [
'tests/e2e/e2e-flash-from-file.spec.ts',
// 'tests/e2e/flash-from-url.spec.ts',
// 'tests/e2e/e2e-flash-from-file.spec.ts',
'tests/e2e/e2e-flash-from-url.spec.ts',
],
},
//
Expand Down

0 comments on commit 8ad42f1

Please sign in to comment.