summaryrefslogtreecommitdiff
path: root/packages/upgrade/test/install.test.js
diff options
context:
space:
mode:
authorGravatar Erika <3019731+Princesseuh@users.noreply.github.com> 2023-11-28 15:39:38 +0100
committerGravatar GitHub <noreply@github.com> 2023-11-28 09:39:38 -0500
commit000e8f4654cae9982e21e0a858366c4844139db6 (patch)
tree36001de27a149aecd7b5e67276026b6ac68dab12 /packages/upgrade/test/install.test.js
parent415fec54f8340a1ffcd6b926c1f5b1a0e0645e5a (diff)
downloadastro-000e8f4654cae9982e21e0a858366c4844139db6.tar.gz
astro-000e8f4654cae9982e21e0a858366c4844139db6.tar.zst
astro-000e8f4654cae9982e21e0a858366c4844139db6.zip
feat: implement overlay main screen redesign (#9118)
* feat: implement redesign * fix: make it build * feat: visual tweaks * feat(overlay): update styling, integration endpoint * feat: add fallback icons * Clean up tests (#9183) * Add `@astrojs/upgrade` package for automatic package upgrades (#8525) Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * [ci] format * fix: links with same path but different search params not prefetched (#9189) Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * fix: discord icon * chore: changeset --------- Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Spencer Whitehead <35475068+SpencerWhitehead7@users.noreply.github.com> Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Diffstat (limited to 'packages/upgrade/test/install.test.js')
-rw-r--r--packages/upgrade/test/install.test.js211
1 files changed, 211 insertions, 0 deletions
diff --git a/packages/upgrade/test/install.test.js b/packages/upgrade/test/install.test.js
new file mode 100644
index 000000000..05c46cdce
--- /dev/null
+++ b/packages/upgrade/test/install.test.js
@@ -0,0 +1,211 @@
+import { expect } from 'chai';
+import { setup } from './utils.js';
+import { install } from '../dist/index.js';
+
+describe('install', () => {
+ const fixture = setup();
+ const ctx = {
+ cwd: '',
+ version: 'latest',
+ packageManager: 'npm',
+ dryRun: true,
+ };
+
+ it('up to date', async () => {
+ const context = {
+ ...ctx,
+ packages: [
+ {
+ name: 'astro',
+ currentVersion: '1.0.0',
+ targetVersion: '1.0.0',
+ },
+ ],
+ };
+ await install(context);
+ expect(fixture.hasMessage('◼ astro is up to date on v1.0.0')).to.be.true;
+ });
+
+ it('patch', async () => {
+ const context = {
+ ...ctx,
+ packages: [
+ {
+ name: 'astro',
+ currentVersion: '1.0.0',
+ targetVersion: '1.0.1',
+ },
+ ],
+ };
+ await install(context);
+ expect(fixture.hasMessage('● astro can be updated to v1.0.1')).to.be.true;
+ });
+
+ it('minor', async () => {
+ const context = {
+ ...ctx,
+ packages: [
+ {
+ name: 'astro',
+ currentVersion: '1.0.0',
+ targetVersion: '1.2.0',
+ },
+ ],
+ };
+ await install(context);
+ expect(fixture.hasMessage('● astro can be updated to v1.2.0')).to.be.true;
+ });
+
+ it('major (reject)', async () => {
+ let prompted = false;
+ let exitCode;
+ const context = {
+ ...ctx,
+ prompt: () => {
+ prompted = true;
+ return { proceed: false };
+ },
+ exit: (code) => {
+ exitCode = code;
+ },
+ packages: [
+ {
+ name: 'astro',
+ currentVersion: '1.0.0',
+ targetVersion: '2.0.0',
+ isMajor: true,
+ changelogTitle: 'CHANGELOG',
+ changelogURL: 'https://example.com',
+ },
+ ],
+ };
+ await install(context);
+ expect(fixture.hasMessage('▲ astro can be updated to v2.0.0')).to.be.true;
+ expect(prompted).to.be.true;
+ expect(exitCode).to.eq(0);
+ expect(fixture.hasMessage('check Be sure to follow the CHANGELOG.')).to.be.false;
+ });
+
+ it('major (accept)', async () => {
+ let prompted = false;
+ let exitCode;
+ const context = {
+ ...ctx,
+ prompt: () => {
+ prompted = true;
+ return { proceed: true };
+ },
+ exit: (code) => {
+ exitCode = code;
+ },
+ packages: [
+ {
+ name: 'astro',
+ currentVersion: '1.0.0',
+ targetVersion: '2.0.0',
+ isMajor: true,
+ changelogTitle: 'CHANGELOG',
+ changelogURL: 'https://example.com',
+ },
+ ],
+ };
+ await install(context);
+ expect(fixture.hasMessage('▲ astro can be updated to v2.0.0')).to.be.true;
+ expect(prompted).to.be.true;
+ expect(exitCode).to.be.undefined;
+ expect(fixture.hasMessage('check Be sure to follow the CHANGELOG.')).to.be.true;
+ });
+
+ it('multiple major', async () => {
+ let prompted = false;
+ let exitCode;
+ const context = {
+ ...ctx,
+ prompt: () => {
+ prompted = true;
+ return { proceed: true };
+ },
+ exit: (code) => {
+ exitCode = code;
+ },
+ packages: [
+ {
+ name: 'a',
+ currentVersion: '1.0.0',
+ targetVersion: '2.0.0',
+ isMajor: true,
+ changelogTitle: 'CHANGELOG',
+ changelogURL: 'https://example.com',
+ },
+ {
+ name: 'b',
+ currentVersion: '6.0.0',
+ targetVersion: '7.0.0',
+ isMajor: true,
+ changelogTitle: 'CHANGELOG',
+ changelogURL: 'https://example.com',
+ },
+ ],
+ };
+ await install(context);
+ expect(fixture.hasMessage('▲ a can be updated to v2.0.0')).to.be.true;
+ expect(fixture.hasMessage('▲ b can be updated to v7.0.0')).to.be.true;
+ expect(prompted).to.be.true;
+ expect(exitCode).to.be.undefined;
+ const [changelog, a, b] = fixture.messages().slice(-5);
+ expect(changelog).to.match(/^check/);
+ expect(a).to.match(/^a/);
+ expect(b).to.match(/^b/);
+ });
+
+ it('current patch minor major', async () => {
+ let prompted = false;
+ let exitCode;
+ const context = {
+ ...ctx,
+ prompt: () => {
+ prompted = true;
+ return { proceed: true };
+ },
+ exit: (code) => {
+ exitCode = code;
+ },
+ packages: [
+ {
+ name: 'current',
+ currentVersion: '1.0.0',
+ targetVersion: '1.0.0',
+ },
+ {
+ name: 'patch',
+ currentVersion: '1.0.0',
+ targetVersion: '1.0.1',
+ },
+ {
+ name: 'minor',
+ currentVersion: '1.0.0',
+ targetVersion: '1.2.0',
+ },
+ {
+ name: 'major',
+ currentVersion: '1.0.0',
+ targetVersion: '3.0.0',
+ isMajor: true,
+ changelogTitle: 'CHANGELOG',
+ changelogURL: 'https://example.com',
+ },
+ ],
+ };
+ await install(context);
+ expect(fixture.hasMessage('◼ current is up to date on v1.0.0')).to.be.true;
+ expect(fixture.hasMessage('● patch can be updated to v1.0.1')).to.be.true;
+ expect(fixture.hasMessage('● minor can be updated to v1.2.0')).to.be.true;
+ expect(fixture.hasMessage('▲ major can be updated to v3.0.0')).to.be.true;
+ expect(prompted).to.be.true;
+ expect(exitCode).to.be.undefined;
+ expect(fixture.hasMessage('check Be sure to follow the CHANGELOG.')).to.be.true;
+ const [changelog, major] = fixture.messages().slice(-4);
+ expect(changelog).to.match(/^check/);
+ expect(major).to.match(/^major/);
+ });
+});