2023-04-04 10:46:28 +02:00
|
|
|
///<reference path="../../global.d.ts" />
|
|
|
|
|
|
|
|
const EDITOR = 2;
|
2023-03-08 11:47:42 +01:00
|
|
|
|
|
|
|
describe('notifications', () => {
|
2023-04-05 13:20:58 +02:00
|
|
|
const randomId = String(Math.random()).split('.')[1];
|
|
|
|
const featureToggleName = `notifications_test-${randomId}`;
|
|
|
|
const baseUrl = Cypress.config().baseUrl;
|
|
|
|
let userIds: number[] = [];
|
|
|
|
let userCredentials: Cypress.UserCredentials[] = [];
|
|
|
|
const userName = `notifications_user-${randomId}`;
|
|
|
|
const projectName = `default`;
|
|
|
|
|
2023-03-08 11:47:42 +01:00
|
|
|
before(() => {
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.runBefore();
|
2023-03-08 11:47:42 +01:00
|
|
|
});
|
|
|
|
|
2023-04-05 10:20:50 +02:00
|
|
|
// This one is failing on CI: https://github.com/Unleash/unleash/actions/runs/4609305167/jobs/8160244872#step:4:193
|
|
|
|
it.skip('should create a notification when a feature is created in a project', () => {
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.login_UI();
|
|
|
|
cy.createUser_API(userName, EDITOR).then(value => {
|
|
|
|
userIds = value.userIds;
|
|
|
|
userCredentials = value.userCredentials;
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.login_UI();
|
|
|
|
cy.visit(`/projects/${projectName}`);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.createFeature_UI(featureToggleName);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//Should not show own notifications
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_BUTTON']").click();
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//then
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_MODAL']").should('exist');
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
const credentials = userCredentials[0];
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//Sign in as a different user
|
|
|
|
cy.login_UI(credentials.email, credentials.password);
|
|
|
|
cy.visit(`/projects/${projectName}`);
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_BUTTON']").click();
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//then
|
2023-04-05 13:20:58 +02:00
|
|
|
// cy.get("[data-testid='UNREAD_NOTIFICATIONS']").should('exist');
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_LIST']").should(
|
|
|
|
'contain.text',
|
|
|
|
`New feature ${featureToggleName}`
|
|
|
|
);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//clean
|
|
|
|
// We need to login as admin for cleanup
|
|
|
|
cy.login_UI();
|
|
|
|
userIds.forEach(id =>
|
|
|
|
cy.request('DELETE', `${baseUrl}/api/admin/user-admin/${id}`)
|
|
|
|
);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.deleteFeature_API(featureToggleName);
|
|
|
|
});
|
2023-03-08 11:47:42 +01:00
|
|
|
});
|
|
|
|
});
|