Skip to content

Commit

Permalink
Merge pull request #773 from particle-iot/fix-failing-e2e-tests
Browse files Browse the repository at this point in the history
Fix failing e2e tests
  • Loading branch information
cole-abbeduto-particle authored Oct 10, 2024
2 parents 615848f + 0b6afce commit b1616ae
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
tags:
- v*
jobs:
call-tests:
uses: ./.github/workflows/reusable-tests.yml
secrets: inherit
call-build:
uses: ./.github/workflows/reusable-build.yml
secrets: inherit
needs: call-tests
call-publish-v2:
uses: ./.github/workflows/reusable-publish-v2.yml
secrets: inherit
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,6 @@ function formatAPIErrorMessage(error){
// TODO (mirande): refactor cmd/api.js to do this check by default when appropriate
function ensureAPIToken(){
if (!settings.access_token){
throw new Error(`You're not logged in. Please login using ${chalk.bold.cyan('particle cloud login')} before using this command`);
throw new Error(`You're not logged in. Please login using ${chalk.bold.cyan('particle login')} before using this command`);
}
}
2 changes: 1 addition & 1 deletion src/cmd/whoami.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Whoami Commands', () => {
throw new Error('expected promise to be rejected');
})
.catch(error => {
expect(stripAnsi(error.message)).to.eql('You\'re not logged in. Please login using particle cloud login before using this command');
expect(stripAnsi(error.message)).to.eql('You\'re not logged in. Please login using particle login before using this command');
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = class ApiClient {

ensureToken(){
if (!this._access_token){
throw new VError(`You're not logged in. Please login using ${chalk.bold.cyan('particle cloud login')} before using this command`);
throw new VError(`You're not logged in. Please login using ${chalk.bold.cyan('particle login')} before using this command`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/compile.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ describe('Compile Commands', () => {
const args = ['compile', platform, '.'];
const { stdout, stderr, exitCode } = await cli.run(args, { cwd });

expect(stdout).to.include('Compile failed: You\'re not logged in. Please login using particle cloud login before using this command');
expect(stdout).to.include('Compile failed: You\'re not logged in. Please login using particle login before using this command');
expect(stderr).to.equal('');
expect(exitCode).to.equal(1);
});
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/help.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Help & Unknown Command / Argument Handling', () => {
'product device', 'product', 'project create', 'project', 'publish',
'serial list', 'serial monitor', 'serial identify', 'serial wifi',
'serial mac', 'serial inspect', 'serial flash',
'serial', 'subscribe', 'token list', 'token revoke',
'serial', 'subscribe', 'token revoke',
'token create', 'token', 'udp send', 'udp listen', 'udp', 'update',
'update-cli', 'usb list', 'usb start-listening', 'usb listen',
'usb stop-listening', 'usb safe-mode', 'usb dfu', 'usb reset',
Expand Down
9 changes: 1 addition & 8 deletions test/e2e/logout.e2e.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { expect } = require('../setup');
const { delay } = require('../lib/mocha-utils');
const cli = require('../lib/cli');
const { USERNAME } = require('../lib/env');

Expand Down Expand Up @@ -40,13 +39,7 @@ describe('Logout Commands', () => {
});

it('Signs out', async () => {
const subprocess = cli.run(['logout']);

await delay(1000);
subprocess.stdin.write('y');
subprocess.stdin.end('\n');

const { stdout, stderr, exitCode } = await subprocess;
const { stdout, stderr, exitCode } = await cli.run(['logout']);

expect(stdout).to.include(`You have been logged out from ${USERNAME}`);
expect(stderr).to.equal('');
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/whoami.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const cli = require('../lib/cli');
const {
USERNAME
} = require('../lib/env');
const stripAnsi = require('strip-ansi');


describe('Whoami Commands', () => {
Expand Down Expand Up @@ -52,7 +53,7 @@ describe('Whoami Commands', () => {
await cli.logout();
const { stdout, stderr, exitCode } = await cli.run('whoami');

expect(stdout).to.equal('You are not signed in! Please run: `particle login`');
expect(stripAnsi(stdout)).to.equal('You\'re not logged in. Please login using particle login before using this command');
expect(stderr).to.equal('');
expect(exitCode).to.equal(1);
});
Expand Down
2 changes: 1 addition & 1 deletion test/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports.loginToForeignAcct = () => {

module.exports.logout = () => {
const { run } = module.exports;
return run(['logout'], { input: 'y\n', reject: true });
return run(['logout'], { reject: true });
};

module.exports.setProfile = (name) => {
Expand Down

0 comments on commit b1616ae

Please sign in to comment.