2024-09-18 00:19:33 -07:00
|
|
|
import planData from '../fixtures/Plan_data_opt_in_trial.json';
|
2023-12-21 06:06:54 -08:00
|
|
|
import {
|
|
|
|
BannerStack,
|
|
|
|
MainSidebar,
|
|
|
|
WorkflowPage,
|
|
|
|
visitPublicApiPage,
|
|
|
|
getPublicApiUpgradeCTA,
|
|
|
|
} from '../pages';
|
|
|
|
|
|
|
|
const mainSidebar = new MainSidebar();
|
|
|
|
const bannerStack = new BannerStack();
|
|
|
|
const workflowPage = new WorkflowPage();
|
|
|
|
|
2024-06-11 05:45:15 -07:00
|
|
|
describe('Cloud', () => {
|
2023-12-21 06:06:54 -08:00
|
|
|
before(() => {
|
|
|
|
const now = new Date();
|
|
|
|
const fiveDaysFromNow = new Date(now.getTime() + 5 * 24 * 60 * 60 * 1000);
|
|
|
|
planData.expirationDate = fiveDaysFromNow.toJSON();
|
|
|
|
});
|
|
|
|
|
2024-06-03 03:51:40 -07:00
|
|
|
beforeEach(() => {
|
2024-06-11 05:45:15 -07:00
|
|
|
cy.overrideSettings({
|
|
|
|
deployment: { type: 'cloud' },
|
|
|
|
n8nMetadata: { userId: '1' },
|
|
|
|
});
|
|
|
|
cy.intercept('GET', '/rest/admin/cloud-plan', planData).as('getPlanData');
|
|
|
|
cy.intercept('GET', '/rest/cloud/proxy/user/me', {}).as('getCloudUserInfo');
|
2024-06-03 03:51:40 -07:00
|
|
|
cy.intercept('GET', new RegExp('/rest/projects*')).as('projects');
|
|
|
|
cy.intercept('GET', new RegExp('/rest/roles')).as('roles');
|
|
|
|
});
|
2023-12-21 06:06:54 -08:00
|
|
|
|
2024-06-03 03:51:40 -07:00
|
|
|
function visitWorkflowPage() {
|
|
|
|
cy.visit(workflowPage.url);
|
|
|
|
cy.wait('@getPlanData');
|
|
|
|
cy.wait('@projects');
|
|
|
|
cy.wait('@roles');
|
|
|
|
}
|
2023-12-21 06:06:54 -08:00
|
|
|
|
2024-06-03 03:51:40 -07:00
|
|
|
describe('BannerStack', () => {
|
|
|
|
it('should render trial banner for opt-in cloud user', () => {
|
|
|
|
visitWorkflowPage();
|
2023-12-21 06:06:54 -08:00
|
|
|
|
|
|
|
bannerStack.getters.banner().should('be.visible');
|
|
|
|
|
|
|
|
mainSidebar.actions.signout();
|
|
|
|
|
2024-06-03 03:51:40 -07:00
|
|
|
bannerStack.getters.banner().should('not.be.visible');
|
2023-12-21 06:06:54 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Admin Home', () => {
|
|
|
|
it('Should show admin button', () => {
|
2024-06-03 03:51:40 -07:00
|
|
|
visitWorkflowPage();
|
2023-12-21 06:06:54 -08:00
|
|
|
|
|
|
|
mainSidebar.getters.adminPanel().should('be.visible');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Public API', () => {
|
|
|
|
it('Should show upgrade CTA for Public API if user is trialing', () => {
|
|
|
|
visitPublicApiPage();
|
2024-06-03 03:51:40 -07:00
|
|
|
cy.wait(['@loadSettings', '@projects', '@roles', '@getPlanData']);
|
2023-12-21 06:06:54 -08:00
|
|
|
|
|
|
|
getPublicApiUpgradeCTA().should('be.visible');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|