/ tests / create-drip-list.spec.ts
create-drip-list.spec.ts
  1  import { test as base, expect } from '@playwright/test';
  2  import { ConnectedSession, TEST_ADDRESSES } from './fixtures/ConnectedSession';
  3  
  4  const test = base.extend<{ connectedSession: ConnectedSession }>({
  5    connectedSession: async ({ page }, use) => {
  6      const connectedSession = new ConnectedSession(page, TEST_ADDRESSES[0]);
  7      await connectedSession.goto();
  8      await connectedSession.connect();
  9  
 10      await use(connectedSession);
 11    },
 12  });
 13  
 14  test('create a drip list', async ({ page, connectedSession }) => {
 15    test.setTimeout(240_000);
 16  
 17    await page.goto('http://localhost:5173/app/drip-lists');
 18    await connectedSession.connect();
 19  
 20    await page.getByRole('button', { name: 'Create Drip List' }).click();
 21    await page.getByRole('textbox', { name: 'Title*' }).press('ControlOrMeta+a');
 22    await page.getByRole('textbox', { name: 'Title*' }).fill('E2E test list');
 23    await page.getByRole('textbox', { name: 'Description' }).click();
 24    await page
 25      .getByRole('textbox', { name: 'Description' })
 26      .fill('This is the description right here!');
 27    await page
 28      .getByRole('radio', {
 29        name: 'Collaborate on recipients Invite collaborators to decide together Set a voting period Publish your list after voting Recipients*',
 30        exact: true,
 31      })
 32      .click();
 33    await page.getByRole('button', { name: 'Continue' }).nth(0).click();
 34    await page.getByTestId('list-editor-input').click();
 35    await page.getByTestId('list-editor-input').fill('github.com/efstajas/drips-test-repo-10');
 36    await page.getByTestId('list-editor-input').press('Enter');
 37    await page.getByTestId('list-editor-input').click();
 38    await page.getByTestId('list-editor-input').fill('0x70997970C51812dc3A010C7d01b50e0d17dc79C8');
 39    await page.getByTestId('list-editor-input').press('Enter');
 40    await page.getByRole('button', { name: 'Clear' }).click();
 41    await page
 42      .getByTestId('item-642829559307850963015472508762062935916233390536')
 43      .getByText('0', { exact: true })
 44      .click();
 45    await page
 46      .getByTestId('item-642829559307850963015472508762062935916233390536')
 47      .getByRole('spinbutton')
 48      .fill('60');
 49    await page
 50      .getByTestId('item-642829559307850963015472508762062935916233390536')
 51      .getByRole('spinbutton')
 52      .press('Enter');
 53    await page.getByText('0', { exact: true }).nth(0).click();
 54    await page
 55      .getByTestId('item-80921553623925136102837120782793736893291544351678576578072673071408')
 56      .getByRole('spinbutton')
 57      .fill('40');
 58    await page
 59      .getByTestId('item-80921553623925136102837120782793736893291544351678576578072673071408')
 60      .getByRole('spinbutton')
 61      .press('Enter');
 62    await page.getByRole('button', { name: 'Continue' }).nth(0).click();
 63    await page.getByRole('button', { name: 'Confirm in wallet' }).click();
 64    await page.getByRole('button', { name: 'Continue' }).nth(0).click({ timeout: 120_000 });
 65    await page.getByRole('link', { name: 'View your Drip List' }).click();
 66  
 67    await page.waitForURL('http://localhost:5173/app/drip-lists/*');
 68  
 69    await expect(page.getByText('drips-test-repo-10').nth(0)).toBeVisible();
 70    await expect(page.getByText('E2E test list').nth(0)).toBeVisible();
 71    await expect(page.getByText('This is the description right here!').nth(0)).toBeVisible();
 72    await expect(page.getByText('60%').nth(0)).toBeVisible();
 73    await expect(page.getByText('40%').nth(0)).toBeVisible();
 74  });
 75  
 76  test('create collaborative drip list', async ({ page, connectedSession }) => {
 77    test.setTimeout(240_000);
 78  
 79    await page.goto('http://localhost:5173/app/drip-lists');
 80    await connectedSession.connect();
 81  
 82    await page.getByRole('button', { name: 'Create Drip List' }).click();
 83    await page.getByRole('textbox', { name: 'Title*' }).press('ControlOrMeta+a');
 84    await page.getByRole('textbox', { name: 'Title*' }).fill('Test collaborative list');
 85    await page.getByRole('textbox', { name: 'Title*' }).press('Tab');
 86    await page
 87      .getByRole('textbox', { name: 'Description' })
 88      .fill('This is a test for a collaborative drip list');
 89    await page
 90      .getByRole('radio', {
 91        name: 'Collaborate on recipients Invite collaborators to decide together Set a voting period Publish your list after voting',
 92        exact: true,
 93      })
 94      .click();
 95    await page.getByRole('button', { name: 'Continue' }).nth(0).click();
 96    await page.getByRole('textbox', { name: 'Add Collaborators* Import' }).click();
 97    await page.getByRole('textbox', { name: 'Add Collaborators* Import' }).click();
 98    await page
 99      .getByRole('textbox', { name: 'Add Collaborators* Import' })
100      .fill('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266');
101    await page.getByRole('textbox', { name: 'Add Collaborators* Import' }).press('Enter');
102  
103    const currentTime = new Date();
104    const in15Seconds = new Date(currentTime.getTime() + 15 * 1000);
105    const inCurrentTimezone = new Date(
106      in15Seconds.getTime() - in15Seconds.getTimezoneOffset() * 60000,
107    );
108  
109    // fill in the date and time in `YYYY-MM-DD HH:MM:SS` format
110    await page
111      .getByTestId('date-time-field')
112      .fill(inCurrentTimezone.toISOString().slice(0, 19).replace('T', ' '));
113  
114    await page.getByRole('button', { name: 'Continue' }).nth(0).click();
115    await page.getByRole('button', { name: 'Confirm in wallet' }).click();
116  
117    await page.getByRole('link', { name: 'View your Drip List' }).click();
118  
119    await page.getByRole('button', { name: 'Cast your vote' }).click();
120    await page.getByRole('textbox', { name: 'Add' }).click();
121    await page.getByRole('textbox', { name: 'Add' }).fill('github.com/efstajas/drips-test-repo-10');
122    await page.getByRole('textbox', { name: 'Add' }).press('Enter');
123    await page
124      .getByRole('textbox', { name: 'Add' })
125      .fill('0x70997970C51812dc3A010C7d01b50e0d17dc79C8');
126    await page.getByRole('textbox', { name: 'Add' }).press('Enter');
127    await page.getByRole('button', { name: 'Clear' }).click();
128    await page
129      .getByTestId('item-642829559307850963015472508762062935916233390536')
130      .getByText('0', { exact: true })
131      .click();
132    await page
133      .getByTestId('item-642829559307850963015472508762062935916233390536')
134      .getByRole('spinbutton')
135      .fill('30');
136    await page
137      .getByTestId('item-80921553623925136102837120782793736893291544351678576578072673071408')
138      .getByText('0', { exact: true })
139      .click();
140    await page
141      .getByTestId('item-80921553623925136102837120782793736893291544351678576578072673071408')
142      .getByRole('spinbutton')
143      .fill('70');
144    await page
145      .getByTestId('item-80921553623925136102837120782793736893291544351678576578072673071408')
146      .getByRole('spinbutton')
147      .press('Enter');
148    await page.getByRole('button', { name: 'Confirm in wallet' }).click();
149    await page.getByRole('button', { name: 'Got it' }).click();
150    await page.getByRole('button', { name: 'Share with collaborators' }).click();
151    await page.getByRole('button', { name: 'Copy link' }).click();
152    await page.getByLabel('Close modal').click();
153  
154    await page.getByRole('button', { name: 'Publish Drip List' }).nth(1).click({ timeout: 120_000 });
155    await page.getByRole('button', { name: 'Confirm in wallet' }).click();
156    await page.getByRole('button', { name: 'Continue' }).nth(0).click({ timeout: 120_000 });
157    await page.getByRole('button', { name: 'Got it' }).click();
158  
159    await expect(page.getByText('this list is in voting').nth(0)).not.toBeVisible();
160    await expect(page.getByText('Test collaborative list').nth(0)).toBeVisible();
161    await expect(page.getByText('This is a test for a collaborative drip list').nth(0)).toBeVisible();
162  });