feat(editor): Support autologin for upgrade path (#7316)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Ricardo Espinoza
2023-10-06 13:16:27 +02:00
committed by GitHub
parent ab647b231d
commit 1dfa052301
26 changed files with 101 additions and 54 deletions

View File

@@ -47,26 +47,53 @@ function setupOwnerAndCloudDeployment() {
}
describe('UI store', () => {
let mockedCloudStore;
beforeEach(() => {
setActivePinia(createPinia());
uiStore = useUIStore();
settingsStore = useSettingsStore();
rootStore = useRootStore();
cloudPlanStore = useCloudPlanStore();
mockedCloudStore = vi.spyOn(cloudPlanStore, 'getAutoLoginCode');
mockedCloudStore.mockImplementationOnce(async () => ({
code: '123',
}));
global.window = Object.create(window);
const url = 'https://test.app.n8n.cloud';
Object.defineProperty(window, 'location', {
value: {
href: url,
},
writable: true,
});
});
test.each([
['default', 'production', 'https://n8n.io/pricing/?ref=test_source'],
['default', 'development', 'https://n8n.io/pricing/?ref=test_source'],
[
'desktop_win',
'default',
'production',
'https://n8n.io/pricing/?utm_source=n8n-internal&utm_medium=desktop&utm_campaign=utm-test-campaign',
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
[
'default',
'development',
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
[
'cloud',
'production',
`https://app.n8n.cloud/login?code=123&returnPath=${encodeURIComponent(
'/account/change-plan',
)}&utm_campaign=utm-test-campaign&source=test_source`,
],
['cloud', 'production', 'https://app.n8n.cloud/account/change-plan'],
])(
'"upgradeLinkUrl" should generate the correct URL for "%s" deployment and "%s" license environment',
(type, environment, expectation) => {
async (type, environment, expectation) => {
settingsStore.setSettings(
merge({}, SETTINGS_STORE_DEFAULT_STATE.settings, {
deployment: {
@@ -80,7 +107,9 @@ describe('UI store', () => {
}),
);
expect(uiStore.upgradeLinkUrl('test_source', 'utm-test-campaign')).toBe(expectation);
const updateLinkUrl = await uiStore.upgradeLinkUrl('test_source', 'utm-test-campaign', type);
expect(updateLinkUrl).toBe(expectation);
},
);